Example/GLSL Program Link Error Testing: Difference between revisions
< Example
Using bad coding style (ie: not initializing variables) is NOT simplifying. |
m Simply undoing changes because you can't handle criticism is immature. And initializing a local variable (it should be GL_FALSE btw) that you created purely for the following two lines is redundant. |
||
Line 25: | Line 25: | ||
glDeleteProgram(program); | glDeleteProgram(program); | ||
//Provide the infolog in whatever | //Provide the infolog in whatever manner you deem best. | ||
//Exit with failure. | //Exit with failure. | ||
return; | return; |
Revision as of 18:41, 12 December 2014
Program Linking error checking.
GLuint program = glCreateProgram();
//Attach shaders as necessary.
glAttachShader(program, ...);
...
//Link the program.
glLinkProgram(program);
GLint isLinked = 0;
glGetProgramiv(program, GL_LINK_STATUS, &isLinked);
if(isLinked == GL_FALSE)
{
GLint maxLength = 0;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength);
//The maxLength includes the NULL character
std::vector<GLchar> infoLog(maxLength);
glGetProgramInfoLog(program, maxLength, &maxLength, &infoLog[0]);
//The program is useless now. So delete it.
glDeleteProgram(program);
//Provide the infolog in whatever manner you deem best.
//Exit with failure.
return;
}