progs/util: added ValidateShaderProgram() to shaderutil.c
authorBrian Paul <brianp@vmware.com>
Tue, 25 Aug 2009 23:36:28 +0000 (17:36 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 25 Aug 2009 23:46:10 +0000 (17:46 -0600)
progs/util/shaderutil.c
progs/util/shaderutil.h

index c58c249831e68e8bc92670a2a71430a90a87f6d0..4db950016b890149506250f2f66c3cb723733edb 100644 (file)
@@ -140,6 +140,25 @@ LinkShaders(GLuint vertShader, GLuint fragShader)
 }
 
 
+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)
 {
@@ -170,6 +189,7 @@ SetUniformValues(GLuint program, struct uniform_info uniforms[])
       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;
index 91c0d4094f8d83b524046b9c14145fa9ceb39218..98c718115694e307a80e9618f7a8d4e3719f115c 100644 (file)
@@ -36,6 +36,9 @@ CompileShaderFile(GLenum shaderType, const char *filename);
 extern GLuint
 LinkShaders(GLuint vertShader, GLuint fragShader);
 
+extern GLboolean
+ValidateShaderProgram(GLuint program);
+
 extern GLdouble
 GetShaderCompileTime(void);