mirror of
https://github.com/servo/servo.git
synced 2025-06-15 03:44:30 +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.
38 lines
1.1 KiB
Rust
38 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::WebGLUniformLocationBinding;
|
|
use dom::bindings::global::GlobalRef;
|
|
use dom::bindings::js::{Temporary, JSRef};
|
|
use dom::bindings::utils::{Reflector,reflect_dom_object};
|
|
|
|
#[dom_struct]
|
|
pub struct WebGLUniformLocation {
|
|
reflector_: Reflector,
|
|
id: i32,
|
|
}
|
|
|
|
impl WebGLUniformLocation {
|
|
fn new_inherited(id: i32) -> WebGLUniformLocation {
|
|
WebGLUniformLocation {
|
|
reflector_: Reflector::new(),
|
|
id: id,
|
|
}
|
|
}
|
|
|
|
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) -> i32;
|
|
}
|
|
|
|
impl<'a> WebGLUniformLocationHelpers for JSRef<'a, WebGLUniformLocation> {
|
|
fn get_id(&self) -> i32 {
|
|
self.id
|
|
}
|
|
}
|