Properly clamp arguments to WebGLRenderingContext.depthRange

This commit is contained in:
Anthony Ramine 2018-04-04 17:14:53 +02:00
parent 7b4d66b621
commit fb290e9c9e
3 changed files with 6 additions and 10 deletions

View file

@ -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