Example/GLSL Program Link Error Testing: Difference between revisions
< Example
Example page for program linking error testing. |
categorization |
||
Line 30: | Line 30: | ||
} | } | ||
</source> | </source> | ||
<noinclude>[[Category:Example Code]]</noinclude> |
Revision as of 01:29, 21 March 2013
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 manor you deem best.
//Exit with failure.
return;
}