Graphics Reference
In-Depth Information
int
LinkProgram( GLuint program )
{
glLinkProgram( program );
CheckGlErrors(“LoadShader:Link 1”);
GLchar* infoLog;
GLint infoLogLen;
GLint linkStatus;
glGetProgramiv( program, GL_LINK_STATUS, &linkStatus );
CheckGlErrors(“LoadShader:Link 2”);
if( linkStatus == GL_FALSE )
{
glGetProgramiv( program, GL_INFO_LOG_LENGTH,
&infoLogLen );
fprintf(stderr,”Failed to link program--Info Log
Length = %d\n”, infoLogLen );
if( infoLogLen > 0 )
{
infoLog = new GLchar[infoLogLen+1];
glGetProgramInfoLog( program, infoLogLen,
NULL, infoLog );
infoLog[infoLogLen] = '\0';
fprintf( stderr, “Info Log:\n%s\n”, infoLog );
delete [ ] infoLog;
}
glDeleteProgram( program );
return 0;
}
return 1;
};
If the linking operation is successful, each of the program object's active
uniform and atribute variables is assigned a location that can be queried with
glGetUniformLocation and glGetAttributeLocation , as discussed later in
this chapter.
Activating a Shader Program
Once a shader program is available, it must be activated. Activating the shader
program switches the action of the graphics card so that your shader program
takes over the necessary operations from the fixed-function processing. To
Search WWH ::




Custom Search