aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/webglprogram.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom/webglprogram.rs')
-rw-r--r--components/script/dom/webglprogram.rs26
1 files changed, 25 insertions, 1 deletions
diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs
index eb822fcaec0..350fc31929c 100644
--- a/components/script/dom/webglprogram.rs
+++ b/components/script/dom/webglprogram.rs
@@ -3,7 +3,7 @@
* 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 canvas_traits::{CanvasMsg, CanvasWebGLMsg, WebGLError, WebGLResult};
+use canvas_traits::{CanvasMsg, CanvasWebGLMsg, WebGLError, WebGLResult, WebGLParameter};
use dom::bindings::codegen::Bindings::WebGLProgramBinding;
use dom::bindings::codegen::Bindings::WebGLRenderingContextBinding::WebGLRenderingContextConstants as constants;
use dom::bindings::global::GlobalRef;
@@ -94,6 +94,23 @@ impl WebGLProgram {
Ok(())
}
+ /// glBindAttribLocation
+ pub fn bind_attrib_location(&self, index: u32, name: DOMString) -> WebGLResult<()> {
+ if name.len() > MAX_UNIFORM_AND_ATTRIBUTE_LEN {
+ return Err(WebGLError::InvalidValue);
+ }
+
+ // Check if the name is reserved
+ if name.starts_with("webgl") || name.starts_with("_webgl_") {
+ return Err(WebGLError::InvalidOperation);
+ }
+
+ self.renderer
+ .send(CanvasMsg::WebGL(CanvasWebGLMsg::BindAttribLocation(self.id, index, String::from(name))))
+ .unwrap();
+ Ok(())
+ }
+
/// glGetAttribLocation
pub fn get_attrib_location(&self, name: DOMString) -> WebGLResult<Option<i32>> {
if name.len() > MAX_UNIFORM_AND_ATTRIBUTE_LEN {
@@ -129,6 +146,13 @@ impl WebGLProgram {
.unwrap();
Ok(receiver.recv().unwrap())
}
+
+ /// glGetProgramParameter
+ pub fn parameter(&self, param_id: u32) -> WebGLResult<WebGLParameter> {
+ let (sender, receiver) = ipc::channel().unwrap();
+ self.renderer.send(CanvasMsg::WebGL(CanvasWebGLMsg::GetProgramParameter(self.id, param_id, sender))).unwrap();
+ receiver.recv().unwrap()
+ }
}
impl Drop for WebGLProgram {