Example/GLSL Program Link Error Testing: Difference between revisions
< Example
mNo edit summary |
mNo edit summary |
||
Line 18: | Line 18: | ||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength); | glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength); | ||
//The maxLength includes the NULL character | // The maxLength includes the NULL character | ||
GLchar infoLog[maxLength]; | GLchar infoLog[maxLength]; | ||
glGetProgramInfoLog(program, maxLength, &maxLength, infoLog); | glGetProgramInfoLog(program, maxLength, &maxLength, infoLog); |
Revision as of 23:17, 4 December 2014
Program Linking error checking.
GLuint program = glCreateProgram();
// Attach shaders as necessary.
glAttachShader(program, ...);
...
// Link the program.
glLinkProgram(program);
GLint isLinked;
glGetProgramiv(program, GL_LINK_STATUS, &isLinked);
if(isLinked == GL_FALSE)
{
GLint maxLength;
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength);
// The maxLength includes the NULL character
GLchar infoLog[maxLength];
glGetProgramInfoLog(program, maxLength, &maxLength, infoLog);
// Provide the infolog in whatever manner you deem best.
// The program is useless now. So delete it.
glDeleteProgram(program);
// Exit with failure.
return;
}