Files
tubestation/servo/components/script/dom/webglshader.rs
Diego Marcos e7427500b0 servo: Merge #5820 - Implements enough WebGL spec to draw a triangle (from dmarcos:firstTriangle); r=jdm
This is WIP. still have to clean up the code a little bit but I wanted to show the progress. I got really excited when I saw my first triangle on screen ```./mach run tests/ref/webgl-context/triangle.html```

![firsttriangle](https://cloud.githubusercontent.com/assets/39342/7313736/e3fdb41e-ea11-11e4-8c63-78523cd9dcc7.png)

Source-Repo: https://github.com/servo/servo
Source-Revision: b43a2ed80714131db4c92a51c0046245aa43da11
2015-05-02 21:22:28 -05:00

40 lines
1.0 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::WebGLShaderBinding;
use dom::bindings::global::GlobalRef;
use dom::bindings::js::{Temporary, JSRef};
use dom::bindings::utils::{Reflector, reflect_dom_object};
#[dom_struct]
pub struct WebGLShader {
reflector_: Reflector,
id: u32,
}
impl WebGLShader {
fn new_inherited(id: u32) -> WebGLShader {
WebGLShader {
reflector_: Reflector::new(),
id: id,
}
}
pub fn new(global: GlobalRef, id: u32) -> Temporary<WebGLShader> {
reflect_dom_object(box WebGLShader::new_inherited(id), global, WebGLShaderBinding::Wrap)
}
}
pub trait WebGLShaderHelpers {
fn get_id(&self) -> u32;
}
impl<'a> WebGLShaderHelpers for JSRef<'a, WebGLShader> {
fn get_id(&self) -> u32 {
self.id
}
}