diff options
author | Brian Paul <brianp@vmware.com> | 2011-03-11 16:53:32 -0700 |
---|---|---|
committer | Brian Paul <brianp@vmware.com> | 2011-03-11 16:58:45 -0700 |
commit | f5f8b86e2edf38886f6ee53280495bb85c129335 (patch) | |
tree | ea28535389686e46ec41925a04f46ba9d532c851 | |
parent | 6db98203b0ab5cd44686561c900de1b7f8ad4c85 (diff) |
gl30basic: test basic GL 3.0 features
-rw-r--r-- | tests/all.tests | 1 | ||||
-rw-r--r-- | tests/general/CMakeLists.gl.txt | 1 | ||||
-rw-r--r-- | tests/general/gl30basic.c | 200 |
3 files changed, 202 insertions, 0 deletions
diff --git a/tests/all.tests b/tests/all.tests index b285b1e14..84874bc35 100644 --- a/tests/all.tests +++ b/tests/all.tests @@ -186,6 +186,7 @@ add_plain_test(general, 'fragment-center') add_plain_test(general, 'framebuffer-srgb') add_plain_test(general, 'geterror-invalid-enum') add_plain_test(general, 'geterror-inside-begin') +add_plain_test(general, 'gl30basic') add_plain_test(general, 'hiz') add_plain_test(general, 'early-z') add_plain_test(general, 'isbufferobj') diff --git a/tests/general/CMakeLists.gl.txt b/tests/general/CMakeLists.gl.txt index 55075c77e..bbe650785 100644 --- a/tests/general/CMakeLists.gl.txt +++ b/tests/general/CMakeLists.gl.txt @@ -49,6 +49,7 @@ IF (UNIX) ENDIF (UNIX) add_executable (geterror-inside-begin geterror-inside-begin.c) add_executable (geterror-invalid-enum geterror-invalid-enum.c) +add_executable (gl30basic gl30basic.c) add_executable (hiz hiz.c) if (UNIX) target_link_libraries (hiz m) diff --git a/tests/general/gl30basic.c b/tests/general/gl30basic.c new file mode 100644 index 000000000..2508d1711 --- /dev/null +++ b/tests/general/gl30basic.c @@ -0,0 +1,200 @@ +/* + * Copyright (c) 2010 VMware, Inc. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS + * IN THE SOFTWARE. + */ + +/** + * @file gl30basic.c + * + * Test basic GL 3.0 features. + * + * Author: + * Brian Paul + */ + + +#include "piglit-util.h" +#include "piglit-framework.h" + +int piglit_width = 100; +int piglit_height = 100; +int piglit_window_mode = GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH | GLUT_STENCIL; + +static const char *Prog = "gl30basic"; + + + +static enum piglit_result +test_version(void) +{ + const GLubyte *version = glGetString(GL_VERSION); + GLuint iversion; + GLint major, minor, k; + +#ifdef GL_VERSION_3_0 + if (!glewIsSupported("GL_VERSION_3_0")) + return PIGLIT_SKIP; +#else + return PIGLIT_SKIP; +#endif + + major = version[0] - '0'; + minor = version[2] - '0'; + + iversion = major * 10 + minor; + + if (iversion < 30) { + return PIGLIT_SKIP; + } + + glGetIntegerv(GL_MAJOR_VERSION, &k); + if (k != major) { + printf("%s: major version mismatch (%d vs. %d)\n", Prog, k, major); + return PIGLIT_FAILURE; + } + + glGetIntegerv(GL_MINOR_VERSION, &k); + if (k != minor) { + printf("%s: minor version mismatch (%d vs. %d)\n", Prog, k, minor); + return PIGLIT_FAILURE; + } + + return PIGLIT_SUCCESS; +} + + +static enum piglit_result +test_extension_list(void) +{ + GLint k, num_ext; + + glGetIntegerv(GL_NUM_EXTENSIONS, &num_ext); + if (num_ext < 1 || num_ext > 10000) { + printf("%s: unreasonable value for GL_NUM_EXTENSIONS: %d\n", Prog, num_ext); + return PIGLIT_FAILURE; + } + + /* check that extension strings are reasonable */ + for (k = 0; k < num_ext; k++) { + const GLubyte *ext = glGetStringi(GL_EXTENSIONS, k); + if (0) + printf("Ext[%d] = %s\n", k, (char *) ext); + if (!ext || + ext[0] != 'G' || + ext[1] != 'L' || + ext[2] != '_') { + printf("%s: bad extension string [%d]: %s\n", Prog, k, ext); + return PIGLIT_FAILURE; + } + if (strchr((char *) ext, ' ')) { + printf("%s: extension string [%d] contains a space: %s\n", Prog, k, ext); + return PIGLIT_FAILURE; + } + } + + return PIGLIT_SUCCESS; +} + + +enum piglit_result +test_clearing(void) +{ + static const GLfloat purple[4] = {1.0, 0.0, 1.0, 1.0}; + GLuint buf = GL_FRONT; + GLfloat color[4], z; + GLint stencil; + GLenum err; + + while (glGetError() != GL_NO_ERROR) + ; + + /* XXX this fails with NVIDIA's driver. Is this test correct?? */ +#if 0 + /* Color */ + glClearBufferfv(GL_COLOR, buf, purple); + err = glGetError(); + if (err) { + printf("%s: glClearBufferfv() generated error 0x%x.\n", Prog, err); + return PIGLIT_FAILURE; + } + + glReadBuffer(buf); + glReadPixels(20, 20, 1, 1, GL_RGBA, GL_FLOAT, color); + if (color[0] != purple[0] || + color[1] != purple[1] || + color[2] != purple[2] || + color[3] != purple[3]) { + printf("%s: glClearBufferfv() failed.\n", Prog); + return PIGLIT_FAILURE; + } +#endif + + /* Depth & Stencil */ + glClearBufferfi(GL_DEPTH_STENCIL, 0, 0.5, 3); + err = glGetError(); + if (err) { + printf("%s: glClearBufferfi() generated error 0x%x.\n", Prog, err); + return PIGLIT_FAILURE; + } + + glReadPixels(20, 20, 1, 1, GL_DEPTH_COMPONENT, GL_FLOAT, &z); + if (fabs(z - 0.5) > 0.001) { + printf("%s: glClearBufferfi() failed (z was %f, expected 0.5).\n", Prog, z); + return PIGLIT_FAILURE; + } + + glReadPixels(20, 20, 1, 1, GL_STENCIL_INDEX, GL_INT, &stencil); + if (stencil != 3) { + printf("%s: glClearBufferfi() failed (stencil was %d, expected 3).\n", + Prog, stencil); + return PIGLIT_FAILURE; + } + + return PIGLIT_SUCCESS; +} + + +enum piglit_result +piglit_display(void) +{ + enum piglit_result res; + + res = test_version(); + if (res != PIGLIT_SUCCESS) + return res; + + res = test_extension_list(); + if (res != PIGLIT_SUCCESS) + return res; + + res = test_clearing(); + if (res != PIGLIT_SUCCESS) + return res; + + return res; +} + + + +void piglit_init(int argc, char**argv) +{ + glewInit(); +} |