Only validate the shader program after it's set up. Avoids false alarm.

--HG--
branch : gsoc2013-dfighter
hg/feature/gsoc2013-dfighter
dfighter1985 11 years ago
parent 5bc7ecf799
commit 888812e72d

@ -41,6 +41,8 @@ namespace NL3D
virtual bool link( std::string &log ) = 0; virtual bool link( std::string &log ) = 0;
virtual bool validate( std::string &log ) = 0;
bool isLinked() const{ return linked; } bool isLinked() const{ return linked; }
protected: protected:

@ -21,7 +21,7 @@
#include "stdopengl.h" #include "stdopengl.h"
#include "driver_opengl_extension.h" #include "driver_opengl_extension.h"
#define MAX_PROGRAM_LINK_ERROR_LOG 1024 #define MAX_PROGRAM_LOG 1024
namespace NL3D namespace NL3D
{ {
@ -145,8 +145,8 @@ namespace NL3D
nglGetProgramiv( programId, GL_LINK_STATUS, &ok ); nglGetProgramiv( programId, GL_LINK_STATUS, &ok );
if( ok == 0 ) if( ok == 0 )
{ {
char errorLog[ MAX_PROGRAM_LINK_ERROR_LOG ]; char errorLog[ MAX_PROGRAM_LOG ];
nglGetProgramInfoLog( programId, MAX_PROGRAM_LINK_ERROR_LOG, NULL, errorLog ); nglGetProgramInfoLog( programId, MAX_PROGRAM_LOG, NULL, errorLog );
log.assign( errorLog ); log.assign( errorLog );
return false; return false;
} }
@ -156,6 +156,22 @@ namespace NL3D
return true; return true;
} }
bool CGLSLProgram::validate( std::string &log )
{
nglValidateProgram( programId );
GLint ok;
nglGetProgramiv( programId, GL_VALIDATE_STATUS, &ok );
if( ok != GL_TRUE )
{
char errorLog[ MAX_PROGRAM_LOG ];
nglGetProgramInfoLog( programId, MAX_PROGRAM_LOG, NULL, errorLog );
log.assign( errorLog );
return false;
}
return true;
}
void CGLSLProgram::deleteShaders() void CGLSLProgram::deleteShaders()
{ {

@ -39,6 +39,8 @@ namespace NL3D
bool link( std::string &log ); bool link( std::string &log );
bool validate( std::string &log );
private: private:
void deleteShaders(); void deleteShaders();

@ -22,19 +22,6 @@ namespace NL3D
if( !program->isLinked() ) if( !program->isLinked() )
return false; return false;
/*
nglValidateProgram( program->getProgramId() );
GLint ok;
nglGetProgramiv( program->getProgramId(), GL_VALIDATE_STATUS, &ok );
if( ok != GL_TRUE )
{
char errorLog[ 1024 ];
nglGetProgramInfoLog( program->getProgramId(), 1024, NULL, errorLog );
return false;
}
*/
nglUseProgram( program->getProgramId() ); nglUseProgram( program->getProgramId() );
GLenum error = glGetError(); GLenum error = glGetError();
@ -230,6 +217,17 @@ namespace NL3D
setupSpecularPass( 0 ); setupSpecularPass( 0 );
break; break;
} }
if( !p->validate( log ) )
{
vp = NULL;
pp = NULL;
delete p;
p = NULL;
nlinfo( "%s", log.c_str() );
return false;
}
#endif #endif
return true; return true;

Loading…
Cancel
Save