Add WebGL function glGetTexParameter

Set the expected result of the test `tex-input-validation.html` to CRASH, since
that is caused by unrelated problems. The test was previously not executing
completely, because it stopped when it didn't find the implementation of
getTexParameter.
This commit is contained in:
Martina Kollarova 2018-02-28 16:03:48 +02:00
parent 7931df716d
commit 288ef50fb7
11 changed files with 156 additions and 264 deletions

View file

@ -115,6 +115,12 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
self.base.GetParameter(cx, parameter)
}
#[allow(unsafe_code)]
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
unsafe fn GetTexParameter(&self, cx: *mut JSContext, target: u32, pname: u32) -> JSVal {
self.base.GetTexParameter(cx, target, pname)
}
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
fn GetError(&self) -> u32 {
self.base.GetError()

View file

@ -1336,6 +1336,37 @@ impl WebGLRenderingContextMethods for WebGLRenderingContext {
}
}
#[allow(unsafe_code)]
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.8
unsafe fn GetTexParameter(&self, _cx: *mut JSContext, target: u32, pname: u32) -> JSVal {
let texture = match target {
constants::TEXTURE_2D |
constants::TEXTURE_CUBE_MAP => self.bound_texture(target),
_ => {
self.webgl_error(InvalidEnum);
return NullValue();
}
};
if texture.is_some() {
let (sender, receiver) = webgl_channel().unwrap();
self.send_command(WebGLCommand::GetTexParameter(target, pname, sender));
match handle_potential_webgl_error!(self, receiver.recv().unwrap(), WebGLParameter::Invalid) {
WebGLParameter::Int(val) => Int32Value(val),
WebGLParameter::Bool(_) => panic!("Texture parameter should not be bool"),
WebGLParameter::Float(_) => panic!("Texture parameter should not be float"),
WebGLParameter::FloatArray(_) => panic!("Texture parameter should not be float array"),
WebGLParameter::String(_) => panic!("Texture parameter should not be string"),
WebGLParameter::Invalid => {
self.webgl_error(InvalidEnum);
NullValue()
}
}
} else {
self.webgl_error(InvalidOperation);
NullValue()
}
}
// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.3
fn GetError(&self) -> u32 {
let error_code = if let Some(error) = self.last_error.get() {

View file

@ -600,7 +600,7 @@ interface WebGLRenderingContextBase
DOMString? getShaderSource(WebGLShader? shader);
//any getTexParameter(GLenum target, GLenum pname);
any getTexParameter(GLenum target, GLenum pname);
//any getUniform(WebGLProgram? program, WebGLUniformLocation? location);