mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Implement gl.getParameter(gl.VIEWPORT)
This commit is contained in:
parent
cb6fa6e6b0
commit
e34b19c42c
5 changed files with 120 additions and 27 deletions
|
@ -860,8 +860,12 @@ impl WebGLImpl {
|
|||
ctx.gl().vertex_attrib_pointer_f32(attrib_id, size, normalized, stride, offset),
|
||||
WebGLCommand::VertexAttribPointer(attrib_id, size, data_type, normalized, stride, offset) =>
|
||||
ctx.gl().vertex_attrib_pointer(attrib_id, size, data_type, normalized, stride, offset),
|
||||
WebGLCommand::Viewport(x, y, width, height) =>
|
||||
ctx.gl().viewport(x, y, width, height),
|
||||
WebGLCommand::GetViewport(sender) => {
|
||||
sender.send(ctx.gl().get_viewport()).unwrap();
|
||||
}
|
||||
WebGLCommand::SetViewport(x, y, width, height) => {
|
||||
ctx.gl().viewport(x, y, width, height);
|
||||
}
|
||||
WebGLCommand::TexImage2D(target, level, internal, width, height, format, data_type, data) =>
|
||||
ctx.gl().tex_image_2d(target, level, internal, width, height,
|
||||
/*border*/0, format, data_type, Some(&data)),
|
||||
|
@ -1055,8 +1059,7 @@ impl WebGLImpl {
|
|||
|
||||
// Int32Array
|
||||
gl::MAX_VIEWPORT_DIMS |
|
||||
gl::SCISSOR_BOX |
|
||||
gl::VIEWPORT => Err(WebGLError::InvalidEnum),
|
||||
gl::SCISSOR_BOX => Err(WebGLError::InvalidEnum),
|
||||
|
||||
// Invalid parameters
|
||||
_ => Err(WebGLError::InvalidEnum)
|
||||
|
|
|
@ -260,7 +260,8 @@ pub enum WebGLCommand {
|
|||
VertexAttrib(u32, f32, f32, f32, f32),
|
||||
VertexAttribPointer(u32, i32, u32, bool, i32, u32),
|
||||
VertexAttribPointer2f(u32, i32, bool, i32, u32),
|
||||
Viewport(i32, i32, i32, i32),
|
||||
GetViewport(WebGLSender<(i32, i32, i32, i32)>),
|
||||
SetViewport(i32, i32, i32, i32),
|
||||
TexImage2D(u32, i32, i32, i32, i32, u32, u32, Vec<u8>),
|
||||
TexParameteri(u32, u32, i32),
|
||||
TexParameterf(u32, u32, f32),
|
||||
|
@ -532,7 +533,8 @@ impl fmt::Debug for WebGLCommand {
|
|||
VertexAttrib(..) => "VertexAttrib",
|
||||
VertexAttribPointer2f(..) => "VertexAttribPointer2f",
|
||||
VertexAttribPointer(..) => "VertexAttribPointer",
|
||||
Viewport(..) => "Viewport",
|
||||
GetViewport(..) => "GetViewport",
|
||||
SetViewport(..) => "SetViewport",
|
||||
TexImage2D(..) => "TexImage2D",
|
||||
TexParameteri(..) => "TexParameteri",
|
||||
TexParameterf(..) => "TexParameterf",
|
||||
|
|
|
@ -1305,6 +1305,14 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
return Int32Value(constants::UNSIGNED_BYTE as i32);
|
||||
}
|
||||
}
|
||||
constants::VIEWPORT => {
|
||||
let (sender, receiver) = webgl_channel().unwrap();
|
||||
self.send_command(WebGLCommand::GetViewport(sender));
|
||||
let (x, y, width, height) = receiver.recv().unwrap();
|
||||
rooted!(in(cx) let mut rval = UndefinedValue());
|
||||
[x, y, width, height].to_jsval(cx, rval.handle_mut());
|
||||
return rval.get();
|
||||
}
|
||||
_ => {
|
||||
if !self.extension_manager.is_get_parameter_name_enabled(parameter) {
|
||||
self.webgl_error(WebGLError::InvalidEnum);
|
||||
|
@ -3236,7 +3244,7 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
return self.webgl_error(InvalidValue)
|
||||
}
|
||||
|
||||
self.send_command(WebGLCommand::Viewport(x, y, width, height))
|
||||
self.send_command(WebGLCommand::SetViewport(x, y, width, height))
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue