diff options
author | Jukka Jylänki <jujjyl@gmail.com> | 2013-11-19 11:37:09 +0200 |
---|---|---|
committer | Jukka Jylänki <jujjyl@gmail.com> | 2013-12-13 18:07:04 +0200 |
commit | 82e6c95c89fb2a4f6668dda3ea40160999a11253 (patch) | |
tree | c498e9e4bc52e1576d6b709a62f658bf41c9a6c2 /tests/gles2_conformance.cpp | |
parent | 3e061d95104b88d6209d892bbda24e18a1539073 (diff) |
Generate an GL_INVALID_VALUE error when user calls glGetXXX() with a null out pointer instead of crashing. Fix glGetIntegerv of GL_SHADER_BINARY_FORMATS to not write anything out to the provided buffer.
Diffstat (limited to 'tests/gles2_conformance.cpp')
-rw-r--r-- | tests/gles2_conformance.cpp | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/tests/gles2_conformance.cpp b/tests/gles2_conformance.cpp index 80539f7f..77681bf4 100644 --- a/tests/gles2_conformance.cpp +++ b/tests/gles2_conformance.cpp @@ -30,6 +30,16 @@ int main(int argc, char *argv[]) glShaderBinary(1, &vs, 0, 0, 0); assert(glGetError() != GL_NO_ERROR); + // Calling any of glGet() with null pointer should be detected and not crash. + // Note that native code can crash when passed a null pointer, and the GL spec does not say anything + // about this, so we spec that Emscripten GLES2 code should generate GL_INVALID_VALUE. + glGetBooleanv(GL_ACTIVE_TEXTURE, 0); + assert(glGetError() == GL_INVALID_VALUE); + glGetIntegerv(GL_ACTIVE_TEXTURE, 0); + assert(glGetError() == GL_INVALID_VALUE); + glGetFloatv(GL_ACTIVE_TEXTURE, 0); + assert(glGetError() == GL_INVALID_VALUE); + GLboolean b = GL_TRUE; GLint i = -1; GLfloat f = -1.f; @@ -44,18 +54,14 @@ int main(int argc, char *argv[]) assert(f == 0.f); // Currently testing that glGetIntegerv(GL_SHADER_BINARY_FORMATS) should be a no-op. - // The spec is somewhat vague here, equally as good could be to return GL_INVALID_ENUM here. - i = 123; - glGetIntegerv(GL_SHADER_BINARY_FORMATS, &i); + int formats[10] = { 123 }; + glGetIntegerv(GL_SHADER_BINARY_FORMATS, formats); assert(glGetError() == GL_NO_ERROR); - assert(i == 0); + assert(formats[0] == 123); - // Spec does not say what to report on the following, but since GL_SHADER_BINARY_FORMATS is supposed - // to return a a pointer to an array representing a list, the pointer can't be converted to bool or float, - // so report a GL_INVALID_ENUM. + // Converting enums to booleans or floats would be odd, so test that the following report a GL_INVALID_ENUM. glGetBooleanv(GL_SHADER_BINARY_FORMATS, &b); - assert(glGetError() == GL_INVALID_ENUM); - + assert(glGetError() == GL_INVALID_ENUM); glGetFloatv(GL_SHADER_BINARY_FORMATS, &f); assert(glGetError() == GL_INVALID_ENUM); |