diff --git a/code/nel/include/nel/3d/i_program_object.h b/code/nel/include/nel/3d/i_program_object.h index e2d04ffe5..ece8ed8f7 100644 --- a/code/nel/include/nel/3d/i_program_object.h +++ b/code/nel/include/nel/3d/i_program_object.h @@ -41,6 +41,8 @@ namespace NL3D virtual bool link( std::string &log ) = 0; + virtual bool validate( std::string &log ) = 0; + bool isLinked() const{ return linked; } protected: diff --git a/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp b/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp index b1273d5c3..7c5d999f8 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.cpp @@ -21,7 +21,7 @@ #include "stdopengl.h" #include "driver_opengl_extension.h" -#define MAX_PROGRAM_LINK_ERROR_LOG 1024 +#define MAX_PROGRAM_LOG 1024 namespace NL3D { @@ -145,8 +145,8 @@ namespace NL3D nglGetProgramiv( programId, GL_LINK_STATUS, &ok ); if( ok == 0 ) { - char errorLog[ MAX_PROGRAM_LINK_ERROR_LOG ]; - nglGetProgramInfoLog( programId, MAX_PROGRAM_LINK_ERROR_LOG, NULL, errorLog ); + char errorLog[ MAX_PROGRAM_LOG ]; + nglGetProgramInfoLog( programId, MAX_PROGRAM_LOG, NULL, errorLog ); log.assign( errorLog ); return false; } @@ -156,6 +156,22 @@ namespace NL3D 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() { diff --git a/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.h b/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.h index b6789abd9..586ce58c8 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.h +++ b/code/nel/src/3d/driver/OpenGL3/driver_glsl_program.h @@ -39,6 +39,8 @@ namespace NL3D bool link( std::string &log ); + bool validate( std::string &log ); + private: void deleteShaders(); diff --git a/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp b/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp index be5cb1453..cd6bf959f 100644 --- a/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp +++ b/code/nel/src/3d/driver/OpenGL3/driver_opengl_program.cpp @@ -22,19 +22,6 @@ namespace NL3D if( !program->isLinked() ) 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() ); GLenum error = glGetError(); @@ -230,6 +217,17 @@ namespace NL3D setupSpecularPass( 0 ); break; } + + if( !p->validate( log ) ) + { + vp = NULL; + pp = NULL; + delete p; + p = NULL; + nlinfo( "%s", log.c_str() ); + return false; + } + #endif return true;