Implement new WebGL interfaces and methods

This commit implements:
* WebGLFramebuffer
* WebGLRenderbuffer
* WebGLTexture

And adds the following methods to `WebGLRenderingContext`:
* create{Texture,Framebuffer,Renderbuffer}
* bind{Texture,Framebuffer,Renderbuffer}
* destroy{Buffer,Texture,Framebuffer,Renderbuffer}

Fixes:
* WebGLUniform location shouldn't inherit from WebGLObject.

Known Issues:
* WebGL objects have to be destroyed on drop, we may want to keep a reference to the context, or maybe a clone of the renderer to achieve this

Also refactors a huge part of the current implementation, to allow
failing on creation of different WebGL objects.

Blocked on https://github.com/servo/gleam/pull/22

A reftest for most of the added functionality is not doable right now,
we need a few more functions in order to upload a texture, for example.
This commit is contained in:
ecoal95 2015-06-05 15:44:03 +02:00
parent ad5846f2e1
commit 9f94d39c9e
14 changed files with 469 additions and 102 deletions

View file

@ -6,34 +6,33 @@
use dom::bindings::codegen::Bindings::WebGLUniformLocationBinding;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{Temporary, JSRef};
use dom::bindings::utils::reflect_dom_object;
use dom::webglobject::WebGLObject;
use dom::bindings::utils::{Reflector,reflect_dom_object};
#[dom_struct]
pub struct WebGLUniformLocation {
webgl_object: WebGLObject,
id: u32,
reflector_: Reflector,
id: i32,
}
impl WebGLUniformLocation {
fn new_inherited(id: u32) -> WebGLUniformLocation {
fn new_inherited(id: i32) -> WebGLUniformLocation {
WebGLUniformLocation {
webgl_object: WebGLObject::new_inherited(),
reflector_: Reflector::new(),
id: id,
}
}
pub fn new(global: GlobalRef, id: u32) -> Temporary<WebGLUniformLocation> {
pub fn new(global: GlobalRef, id: i32) -> Temporary<WebGLUniformLocation> {
reflect_dom_object(box WebGLUniformLocation::new_inherited(id), global, WebGLUniformLocationBinding::Wrap)
}
}
pub trait WebGLUniformLocationHelpers {
fn get_id(&self) -> u32;
fn get_id(&self) -> i32;
}
impl<'a> WebGLUniformLocationHelpers for JSRef<'a, WebGLUniformLocation> {
fn get_id(&self) -> u32 {
fn get_id(&self) -> i32 {
self.id
}
}