From c475079ef2d901ba4506ebd53e19419cd46793ab Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 3 Nov 2009 14:41:08 -0700 Subject: progs/util: Fix memory leak if fail to load/compile shader Signed-off-by: Brian Paul --- progs/util/shaderutil.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'progs/util/shaderutil.c') diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c index 4db950016b..af50d64f51 100644 --- a/progs/util/shaderutil.c +++ b/progs/util/shaderutil.c @@ -84,6 +84,7 @@ CompileShaderFile(GLenum shaderType, const char *filename) f = fopen(filename, "r"); if (!f) { fprintf(stderr, "Unable to open shader file %s\n", filename); + free(buffer); return 0; } @@ -94,6 +95,7 @@ CompileShaderFile(GLenum shaderType, const char *filename) shader = CompileShaderText(shaderType, buffer); } else { + free(buffer); return 0; } -- cgit v1.2.3 From 11905da8836822f7dd60c84b5eefc72e46c94b50 Mon Sep 17 00:00:00 2001 From: Vinson Lee Date: Tue, 17 Nov 2009 12:00:22 -0800 Subject: progs/util: Fix memory leak if fread returns 0 in CompileShaderFile. --- progs/util/shaderutil.c | 1 + 1 file changed, 1 insertion(+) (limited to 'progs/util/shaderutil.c') diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c index af50d64f51..aebf23a78c 100644 --- a/progs/util/shaderutil.c +++ b/progs/util/shaderutil.c @@ -95,6 +95,7 @@ CompileShaderFile(GLenum shaderType, const char *filename) shader = CompileShaderText(shaderType, buffer); } else { + fclose(f); free(buffer); return 0; } -- cgit v1.2.3 From 6acb82dab0056f0d5f3522c7b063db8024ef81d8 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 17 Nov 2009 19:22:11 -0700 Subject: progs/util: warn when GLSL not supported --- progs/util/shaderutil.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'progs/util/shaderutil.c') diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c index aebf23a78c..4fb3199a19 100644 --- a/progs/util/shaderutil.c +++ b/progs/util/shaderutil.c @@ -34,7 +34,8 @@ ShadersSupported(void) fprintf(stderr, "Warning: Trying ARB GLSL instead of OpenGL 2.x. This may not work.\n"); return GL_TRUE; } - return GL_TRUE; + fprintf(stderr, "Sorry, GLSL not supported with this OpenGL.\n"); + return GL_FALSE; } -- cgit v1.2.3 From da0883114b1dceceff8a38deea1bb870fda40464 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 23 Nov 2009 18:32:27 -0800 Subject: shaderutil: Fix detection of shaders Check for versions >= 2.0 (because some drivers return 3.0), and return GL_FALSE if shaders are not detected. --- progs/util/shaderutil.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) (limited to 'progs/util/shaderutil.c') diff --git a/progs/util/shaderutil.c b/progs/util/shaderutil.c index 4db950016b..629b6f1d97 100644 --- a/progs/util/shaderutil.c +++ b/progs/util/shaderutil.c @@ -25,7 +25,11 @@ GLboolean ShadersSupported(void) { const char *version = (const char *) glGetString(GL_VERSION); - if (version[0] == '2' && version[1] == '.') { + + /* NVIDIA binary drivers will return "3.0.0", and they clearly support + * shaders. + */ + if (version[0] >= '2' && version[1] == '.') { return GL_TRUE; } else if (glutExtensionSupported("GL_ARB_vertex_shader") @@ -34,7 +38,7 @@ ShadersSupported(void) fprintf(stderr, "Warning: Trying ARB GLSL instead of OpenGL 2.x. This may not work.\n"); return GL_TRUE; } - return GL_TRUE; + return GL_FALSE; } -- cgit v1.2.3