mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
Properly clamp arguments to WebGLRenderingContext.depthRange
This commit is contained in:
parent
7b4d66b621
commit
fb290e9c9e
3 changed files with 6 additions and 10 deletions
|
@ -695,8 +695,9 @@ impl WebGLImpl {
|
|||
ctx.gl().depth_func(func),
|
||||
WebGLCommand::DepthMask(flag) =>
|
||||
ctx.gl().depth_mask(flag),
|
||||
WebGLCommand::DepthRange(near, far) =>
|
||||
ctx.gl().depth_range(near, far),
|
||||
WebGLCommand::DepthRange(near, far) => {
|
||||
ctx.gl().depth_range(near.max(0.).min(1.) as f64, far.max(0.).min(1.) as f64)
|
||||
}
|
||||
WebGLCommand::Disable(cap) =>
|
||||
ctx.gl().disable(cap),
|
||||
WebGLCommand::Enable(cap) =>
|
||||
|
|
|
@ -177,7 +177,7 @@ pub enum WebGLCommand {
|
|||
FrontFace(u32),
|
||||
DepthFunc(u32),
|
||||
DepthMask(bool),
|
||||
DepthRange(f64, f64),
|
||||
DepthRange(f32, f32),
|
||||
Enable(u32),
|
||||
Disable(u32),
|
||||
CompileShader(WebGLShaderId, String),
|
||||
|
|
|
@ -1925,16 +1925,11 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
|
|||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||
fn DepthRange(&self, near: f32, far: f32) {
|
||||
// From the WebGL 1.0 spec, 6.12: Viewport Depth Range:
|
||||
//
|
||||
// "A call to depthRange will generate an
|
||||
// INVALID_OPERATION error if zNear is greater than
|
||||
// zFar."
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#VIEWPORT_DEPTH_RANGE
|
||||
if near > far {
|
||||
return self.webgl_error(InvalidOperation);
|
||||
}
|
||||
|
||||
self.send_command(WebGLCommand::DepthRange(near as f64, far as f64))
|
||||
self.send_command(WebGLCommand::DepthRange(near, far))
|
||||
}
|
||||
|
||||
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue