mirror of
https://github.com/servo/servo.git
synced 2025-06-08 16:43:28 +00:00
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.
39 lines
1.1 KiB
Rust
39 lines
1.1 KiB
Rust
/* 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::WebGLFramebufferBinding;
|
|
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 WebGLFramebuffer {
|
|
webgl_object: WebGLObject,
|
|
id: u32,
|
|
}
|
|
|
|
impl WebGLFramebuffer {
|
|
fn new_inherited(id: u32) -> WebGLFramebuffer {
|
|
WebGLFramebuffer {
|
|
webgl_object: WebGLObject::new_inherited(),
|
|
id: id,
|
|
}
|
|
}
|
|
|
|
pub fn new(global: GlobalRef, id: u32) -> Temporary<WebGLFramebuffer> {
|
|
reflect_dom_object(box WebGLFramebuffer::new_inherited(id), global, WebGLFramebufferBinding::Wrap)
|
|
}
|
|
}
|
|
|
|
pub trait WebGLFramebufferHelpers {
|
|
fn get_id(&self) -> u32;
|
|
}
|
|
|
|
impl<'a> WebGLFramebufferHelpers for JSRef<'a, WebGLFramebuffer> {
|
|
fn get_id(&self) -> u32 {
|
|
self.id
|
|
}
|
|
}
|