aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglrenderbuffer.rs
diff options
context:
space:
mode:
authorecoal95 <ecoal95@gmail.com>2015-06-05 15:44:03 +0200
committerecoal95 <ecoal95@gmail.com>2015-06-06 12:14:01 +0200
commit9f94d39c9e3f1b19c5b87b367742307230b55582 (patch)
tree9a1233927c47a1efd2f5fa6265f10c79b717aadb /components/script/dom/webglrenderbuffer.rs
parentad5846f2e14ac15aca9f561975ae9476d0f13244 (diff)
downloadservo-9f94d39c9e3f1b19c5b87b367742307230b55582.tar.gz
servo-9f94d39c9e3f1b19c5b87b367742307230b55582.zip
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.
Diffstat (limited to 'components/script/dom/webglrenderbuffer.rs')
-rw-r--r--components/script/dom/webglrenderbuffer.rs39
1 files changed, 39 insertions, 0 deletions
diff --git a/components/script/dom/webglrenderbuffer.rs b/components/script/dom/webglrenderbuffer.rs
new file mode 100644
index 00000000000..12cdd8240c6
--- /dev/null
+++ b/components/script/dom/webglrenderbuffer.rs
@@ -0,0 +1,39 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+// https://www.khronos.org/registry/webgl/specs/latest/1.0/webgl.idl
+use dom::bindings::codegen::Bindings::WebGLRenderbufferBinding;
+use dom::bindings::global::GlobalRef;
+use dom::bindings::js::{Temporary, JSRef};
+use dom::bindings::utils::reflect_dom_object;
+use dom::webglobject::WebGLObject;
+
+#[dom_struct]
+pub struct WebGLRenderbuffer {
+ webgl_object: WebGLObject,
+ id: u32,
+}
+
+impl WebGLRenderbuffer {
+ fn new_inherited(id: u32) -> WebGLRenderbuffer {
+ WebGLRenderbuffer {
+ webgl_object: WebGLObject::new_inherited(),
+ id: id,
+ }
+ }
+
+ pub fn new(global: GlobalRef, id: u32) -> Temporary<WebGLRenderbuffer> {
+ reflect_dom_object(box WebGLRenderbuffer::new_inherited(id), global, WebGLRenderbufferBinding::Wrap)
+ }
+}
+
+pub trait WebGLRenderbufferHelpers {
+ fn get_id(&self) -> u32;
+}
+
+impl<'a> WebGLRenderbufferHelpers for JSRef<'a, WebGLRenderbuffer> {
+ fn get_id(&self) -> u32 {
+ self.id
+ }
+}