mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +01:00
Implement various WebGL functions
This commit is contained in:
parent
a1fb12616a
commit
0f4d6d58aa
15 changed files with 530 additions and 190 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue