PDA

View Full Version : checking compile status for GLSL shaders performs different in debug than release



cyrfer
11-28-2006, 04:25 AM
The following code is showing different results. In debug, the shaders appear compiled and the program operates fine, in release, this code fails, and the shaders don't seem to work well either.

bool GLSLShader::IsCompiled() const
{
std::cout << "GLSLShader: checking compile status for id = " << _id << std::endl;
GLint result( GL_FALSE );
glGetObjectParameterivARB( _id , GL_OBJECT_COMPILE_STATUS_ARB , &amp;result );
return( result==GL_TRUE );
}I've verified that the shader source code is being loaded the same for both builds. Does anyone know why the shaders would work in debug builds and not release?

There is one more strange aspect to this. My program has 4 shaders in total, 2 vertex and 2 fragment. The first vertex shader shows no problems when I check the compile status. However, checking all other shaders after this check fails. Again, this only happens in release builds running from the command line. Running from the IDE with either build seems to work.

Relic
11-28-2006, 06:07 AM
That debug code works and release not is normally a sign for a missing variable or memory initialization.
Debug allocations fill memory, release's don't.
Check all your variables for correct initialization.
Crank up the compiler's warning level to the maximum to see if it finds variables accessed before initialization.
The code above looks like it should work in both cases and because you say the shaders itself actually don't work your problem is probably related to the string handling of the shader source. Make sure you use correct null terminated strings and the correct lengths.