diff options
author | José Fonseca <jfonseca@vmware.com> | 2011-06-07 18:45:22 +0100 |
---|---|---|
committer | José Fonseca <jfonseca@vmware.com> | 2011-06-07 18:45:22 +0100 |
commit | 7e152554bd922769f1e41c5fe5264f936cc5e149 (patch) | |
tree | b5e80666c40b2dbd06bd06d65d994d5fa4b7d78b | |
parent | bea0fd1130632fd722d3032f1dd8b3614d281cc2 (diff) |
Fix GL_VERSION checks.
Several demos were mistakenly dismissing version 3.
Simply use GLEW version check mechanism everywhere.
-rw-r--r-- | src/demos/fslight.c | 6 | ||||
-rw-r--r-- | src/demos/spriteblast.c | 3 | ||||
-rw-r--r-- | src/glsl/multinoise.c | 4 | ||||
-rw-r--r-- | src/glsl/shadow_sampler.c | 6 | ||||
-rw-r--r-- | src/glsl/texaaline.c | 7 | ||||
-rw-r--r-- | src/objviewer/objview.c | 11 | ||||
-rw-r--r-- | src/perf/glmain.c | 10 | ||||
-rw-r--r-- | src/tests/drawbuffers.c | 7 | ||||
-rw-r--r-- | src/tests/drawbuffers2.c | 3 | ||||
-rw-r--r-- | src/tests/shader_api.c | 5 | ||||
-rw-r--r-- | src/trivial/fs-tri.c | 6 |
11 files changed, 23 insertions, 45 deletions
diff --git a/src/demos/fslight.c b/src/demos/fslight.c index 191a4e43..773108a4 100644 --- a/src/demos/fslight.c +++ b/src/demos/fslight.c @@ -462,11 +462,9 @@ Init(void) " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" " normal = gl_NormalMatrix * gl_Normal;\n" "}\n"; - const char *version; - version = (const char *) glGetString(GL_VERSION); - if (version[0] == '1') { - printf("This program requires OpenGL 2.x or higher, found %s\n", version); + if (!GLEW_VERSION_2_0) { + printf("This program requires OpenGL 2.x or higher\n"); exit(1); } diff --git a/src/demos/spriteblast.c b/src/demos/spriteblast.c index 20c428c9..0361f28a 100644 --- a/src/demos/spriteblast.c +++ b/src/demos/spriteblast.c @@ -111,10 +111,9 @@ static GLboolean HaveShaders = GL_FALSE; static void makeFragShader(void) { - const char *version = (const char *) glGetString(GL_VERSION); GLint stat; - HaveShaders = (version[0] >= '2' && version[1] == '.'); + HaveShaders = GLEW_VERSION_2_0; if (!HaveShaders) return; diff --git a/src/glsl/multinoise.c b/src/glsl/multinoise.c index 410f0abe..b5ed14cf 100644 --- a/src/glsl/multinoise.c +++ b/src/glsl/multinoise.c @@ -223,11 +223,9 @@ CheckLink(GLuint prog) static void Init(void) { - const char *version; GLint i; - version = (const char *) glGetString(GL_VERSION); - if (version[0] != '2' || version[1] != '.') { + if (!GLEW_VERSION_2_0) { printf("Warning: this program expects OpenGL 2.0\n"); /*exit(1);*/ } diff --git a/src/glsl/shadow_sampler.c b/src/glsl/shadow_sampler.c index 6b9bb677..b830030d 100644 --- a/src/glsl/shadow_sampler.c +++ b/src/glsl/shadow_sampler.c @@ -260,7 +260,6 @@ Init(void) " gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" " gl_TexCoord[0] = gl_MultiTexCoord0; \n" "}\n"; - const char *version; #if USE_RECT if (!glutExtensionSupported("GL_ARB_texture_rectangle")) { @@ -269,9 +268,8 @@ Init(void) } #endif - version = (const char *) glGetString(GL_VERSION); - if (version[0] * 10 + version[2] <= 20) { - printf("This program requires OpenGL 2.x, found %s\n", version); + if (!GLEW_VERSION_2_0) { + printf("This program requires OpenGL 2.x\n"); exit(1); } printf("GL_RENDERER = %s\n",(const char *) glGetString(GL_RENDERER)); diff --git a/src/glsl/texaaline.c b/src/glsl/texaaline.c index e096da6f..315800ad 100644 --- a/src/glsl/texaaline.c +++ b/src/glsl/texaaline.c @@ -321,15 +321,12 @@ MakeMipmap(void) static void Init(void) { - const char *version; - (void) MakeTexture; (void) ramp4; (void) ramp2; - version = (const char *) glGetString(GL_VERSION); - if (version[0] != '2' || version[1] != '.') { - printf("This program requires OpenGL 2.x, found %s\n", version); + if (!GLEW_VERSION_2_0) { + printf("This program requires OpenGL 2.x\n"); exit(1); } diff --git a/src/objviewer/objview.c b/src/objviewer/objview.c index a323a969..64c4a9f0 100644 --- a/src/objviewer/objview.c +++ b/src/objviewer/objview.c @@ -435,22 +435,21 @@ Motion(int x, int y) static void DoFeatureChecks(void) { - char *version = (char *) glGetString(GL_VERSION); - if (version[0] == '1') { + if (!GLEW_VERSION_2_0) { /* check for individual extensions */ - if (!glutExtensionSupported("GL_ARB_texture_cube_map")) { + if (!GLEW_ARB_texture_cube_map) { printf("Sorry, GL_ARB_texture_cube_map is required.\n"); exit(1); } - if (!glutExtensionSupported("GL_ARB_vertex_shader")) { + if (!GLEW_ARB_vertex_shader) { printf("Sorry, GL_ARB_vertex_shader is required.\n"); exit(1); } - if (!glutExtensionSupported("GL_ARB_fragment_shader")) { + if (!GLEW_ARB_fragment_shader) { printf("Sorry, GL_ARB_fragment_shader is required.\n"); exit(1); } - if (!glutExtensionSupported("GL_ARB_vertex_buffer_object")) { + if (!GLEW_ARB_vertex_buffer_object) { printf("Sorry, GL_ARB_vertex_buffer_object is required.\n"); exit(1); } diff --git a/src/perf/glmain.c b/src/perf/glmain.c index d2520243..81c11734 100644 --- a/src/perf/glmain.c +++ b/src/perf/glmain.c @@ -119,13 +119,9 @@ PerfShaderProgram(const char *vertShader, const char *fragShader) GLuint prog; GLint stat; - { - const char *version = (const char *) glGetString(GL_VERSION); - if ((version[0] != '2' && - version[0] != '3') || version[1] != '.') { - fprintf(stderr, "Error: GL version 2.x or better required\n"); - exit(1); - } + if (!GLEW_VERSION_2_0) { + fprintf(stderr, "Error: GL version 2.x or better required\n"); + exit(1); } prog = glCreateProgram(); diff --git a/src/tests/drawbuffers.c b/src/tests/drawbuffers.c index 991bf8d4..fa2f8a7c 100644 --- a/src/tests/drawbuffers.c +++ b/src/tests/drawbuffers.c @@ -156,18 +156,17 @@ Key(unsigned char key, int x, int y) static void CheckExtensions(void) { - const char *version = (const char *) glGetString(GL_VERSION); GLint numBuf; - if (!glutExtensionSupported("GL_EXT_framebuffer_object")) { + if (!GLEW_EXT_framebuffer_object) { printf("Sorry, GL_EXT_framebuffer_object is required!\n"); exit(1); } - if (!glutExtensionSupported("GL_ARB_draw_buffers")) { + if (!GLEW_ARB_draw_buffers) { printf("Sorry, GL_ARB_draw_buffers is required!\n"); exit(1); } - if (version[0] != '2') { + if (!GLEW_VERSION_2_0) { printf("Sorry, OpenGL 2.0 is required!\n"); exit(1); } diff --git a/src/tests/drawbuffers2.c b/src/tests/drawbuffers2.c index 267b1355..5bcf0b21 100644 --- a/src/tests/drawbuffers2.c +++ b/src/tests/drawbuffers2.c @@ -204,7 +204,6 @@ CheckExtensions(void) "GL_EXT_draw_buffers2" }; - const char *version = (const char *) glGetString(GL_VERSION); GLint numBuf; GLint i; @@ -214,7 +213,7 @@ CheckExtensions(void) exit(1); } } - if (version[0] != '2') { + if (!GLEW_VERSION_2_0) { printf("Sorry, OpenGL 2.0 is required!\n"); exit(1); } diff --git a/src/tests/shader_api.c b/src/tests/shader_api.c index e30ee184..fa7741d1 100644 --- a/src/tests/shader_api.c +++ b/src/tests/shader_api.c @@ -321,14 +321,11 @@ static void run_test(const char *name, void (*callback)(void)) int main(int argc, char **argv) { - const char *version; - glutInit(&argc, argv); glutCreateWindow("Mesa bug demo"); glewInit(); - version = (const char *) glGetString(GL_VERSION); - if (version[0] == '1') { + if (!GLEW_VERSION_2_0) { printf("Sorry, this test requires OpenGL 2.x GLSL support\n"); exit(0); } diff --git a/src/trivial/fs-tri.c b/src/trivial/fs-tri.c index 8d754769..3022b097 100644 --- a/src/trivial/fs-tri.c +++ b/src/trivial/fs-tri.c @@ -155,11 +155,9 @@ Init(void) " normal = gl_NormalMatrix * gl_Normal;\n" "}\n"; #endif - const char *version; - version = (const char *) glGetString(GL_VERSION); - if (version[0] != '2' || version[1] != '.') { - printf("This program requires OpenGL 2.x, found %s\n", version); + if (!GLEW_VERSION_2_0) { + printf("This program requires OpenGL 2.x\n"); exit(1); } |