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")
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;
}
f = fopen(filename, "r");
if (!f) {
fprintf(stderr, "Unable to open shader file %s\n", filename);
+ free(buffer);
return 0;
}
shader = CompileShaderText(shaderType, buffer);
}
else {
+ fclose(f);
+ free(buffer);
return 0;
}
}
+GLboolean
+ValidateShaderProgram(GLuint program)
+{
+ GLint stat;
+ glValidateProgramARB(program);
+ glGetProgramiv(program, GL_VALIDATE_STATUS, &stat);
+
+ if (!stat) {
+ GLchar log[1000];
+ GLsizei len;
+ glGetProgramInfoLog(program, 1000, &len, log);
+ fprintf(stderr, "Program validation error:\n%s\n", log);
+ return 0;
+ }
+
+ return (GLboolean) stat;
+}
+
+
GLdouble
GetShaderCompileTime(void)
{
case GL_SAMPLER_3D:
case GL_SAMPLER_CUBE:
case GL_SAMPLER_2D_RECT_ARB:
+ assert(uniforms[i].value[0] >= 0.0F);
glUniform1i(uniforms[i].location,
(GLint) uniforms[i].value[0]);
break;