GLSL shader errors

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
andyZER0
Posts: 5
Joined: Thu Jan 05, 2006 7:37 am
Location: Irvine, CA, USA
Contact:

GLSL shader errors

Post by andyZER0 »

I was wondering if Irrlicht provides a way to get a more detailed error message for GLSL shaders or just shaders in general. When it says I have a compile error or link error, it's helpful, but just a bit vague. :( Thanks in advance.
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

I think that the following should work. You'll have to make the edits yourself and rebuild the Irrlicht library.

Code: Select all

==== //irrlicht/irrlicht_0.14.0/source/COpenGLDriver.h#1 - s:\Code\irrlicht\source\COpenGLDriver.h ====
***************
*** 189,194 ****
--- 189,195 ----
        void extGlUseProgramObjectARB(GLhandleARB prog); 
        void extGlDeleteObjectARB(GLhandleARB object); 
        void extGlGetObjectParameterivARB(GLhandleARB object, GLenum type, int *param); 
+       void extGlGetInfoLogARB(GLhandleARB obj, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog);
        GLint extGlGetUniformLocationARB(GLhandleARB program, const char *name); 
        void extGlUniform4fvARB(GLint location, GLsizei count, const GLfloat *v); 
        
***************
*** 335,340 ****
--- 336,342 ----
        PFNGLUSEPROGRAMOBJECTARBPROC pGlUseProgramObjectARB; 
        PFNGLDELETEOBJECTARBPROC pGlDeleteObjectARB; 
        PFNGLGETOBJECTPARAMETERIVARBPROC pGlGetObjectParameterivARB; 
+       PFNGLGETINFOLOGARBPROC pGlGetInfoLogARB;
        PFNGLGETUNIFORMLOCATIONARBPROC pGlGetUniformLocationARB; 
        PFNGLUNIFORM4FVARBPROC pGlUniform4fvARB; 
        PFNGLUNIFORM1FVARBPROC pGlUniform1fvARB;


==== //irrlicht/irrlicht_0.14.0/source/COpenGLDriver.cpp#3 - s:\Code\irrlicht\source\COpenGLDriver.cpp ====
***************
*** 42,48 ****
     CurrentRendertargetSize(0,0), pGlCreateShaderObjectARB(0), pGlShaderSourceARB(0),
     pGlCompileShaderARB(0), pGlCreateProgramObjectARB(0), pGlAttachObjectARB(0), 
     pGlLinkProgramARB(0), pGlUseProgramObjectARB(0), pGlDeleteObjectARB(0), 
!    pGlGetObjectParameterivARB(0), pGlGetUniformLocationARB(0), pGlUniform4fvARB(0),
     pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniformMatrix2fvARB(0),
     pGlUniformMatrix3fvARB(0), pGlUniformMatrix4fvARB(0), pGlGetActiveUniformARB(0)
  
--- 42,48 ----
     CurrentRendertargetSize(0,0), pGlCreateShaderObjectARB(0), pGlShaderSourceARB(0),
     pGlCompileShaderARB(0), pGlCreateProgramObjectARB(0), pGlAttachObjectARB(0), 
     pGlLinkProgramARB(0), pGlUseProgramObjectARB(0), pGlDeleteObjectARB(0), 
!    pGlGetObjectParameterivARB(0), pGlGetInfoLogARB(0), pGlGetUniformLocationARB(0), pGlUniform4fvARB(0),
     pGlUniform1fvARB(0), pGlUniform2fvARB(0), pGlUniform3fvARB(0), pGlUniformMatrix2fvARB(0),
     pGlUniformMatrix3fvARB(0), pGlUniformMatrix4fvARB(0), pGlGetActiveUniformARB(0)
  
***************
*** 383,389 ****
        pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) wglGetProcAddress("glLinkProgramARB"); 
        pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) wglGetProcAddress("glUseProgramObjectARB"); 
        pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) wglGetProcAddress("glDeleteObjectARB"); 
!       pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)   wglGetProcAddress("glGetObjectParameterivARB");  
        pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)  wglGetProcAddress("glGetUniformLocationARB");  
        pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) wglGetProcAddress("glUniform4fvARB");  
        pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC)   wglGetProcAddress("glUniform1fvARB");
--- 383,390 ----
        pGlLinkProgramARB = (PFNGLLINKPROGRAMARBPROC) wglGetProcAddress("glLinkProgramARB"); 
        pGlUseProgramObjectARB = (PFNGLUSEPROGRAMOBJECTARBPROC) wglGetProcAddress("glUseProgramObjectARB"); 
        pGlDeleteObjectARB = (PFNGLDELETEOBJECTARBPROC) wglGetProcAddress("glDeleteObjectARB"); 
!       pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)   wglGetProcAddress("glGetObjectParameterivARB"); 
!       pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC) wglGetProcAddress("glGetInfoLogARB");
        pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)  wglGetProcAddress("glGetUniformLocationARB");  
        pGlUniform4fvARB = (PFNGLUNIFORM4FVARBPROC) wglGetProcAddress("glUniform4fvARB");  
        pGlUniform1fvARB = (PFNGLUNIFORM1FVARBPROC)   wglGetProcAddress("glUniform1fvARB");
***************
*** 460,465 ****
--- 461,469 ----
           pGlGetObjectParameterivARB = (PFNGLGETOBJECTPARAMETERIVARBPROC)  
              IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetObjectParameterivARB"));  
  
+          pGlGetInfoLogARB = (PFNGLGETINFOLOGARBPROC)  
+             IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetInfoLogARB"));  
+ 
           pGlGetUniformLocationARB = (PFNGLGETUNIFORMLOCATIONARBPROC)  
              IRR_OGL_LOAD_EXTENSION(reinterpret_cast<const GLubyte*>("glGetUniformLocationARB"));  
  
***************
*** 2089,2094 ****
--- 2093,2106 ----
  #endif 
  } 
  
+ void COpenGLDriver::extGlGetInfoLogARB(GLhandleARB object, GLsizei maxLength, GLsizei *length, GLcharARB *infoLog) 
+ { 
+ #if defined(_IRR_WINDOWS_) || defined(_IRR_LINUX_OPENGL_USE_EXTENSIONS_) 
+    if (pGlGetInfoLogARB) 
+       pGlGetInfoLogARB(object, maxLength, length, infoLog); 
+ #endif 
+ } 
+ 
  GLint COpenGLDriver::extGlGetUniformLocationARB(GLhandleARB program, const char *name) 
  {
  #if defined(_IRR_WINDOWS_) || defined(_IRR_LINUX_OPENGL_USE_EXTENSIONS_) 


==== //irrlicht/irrlicht_0.14.0/source/COpenGLSLMaterialRenderer.cpp#1 - s:\Code\irrlicht\source\COpenGLSLMaterialRenderer.cpp ====
***************
*** 177,183 ****
  
     if (!status)
     {
!       os::Printer::log("GLSL shader failed to compile");
        return false;
     }
  
--- 177,200 ----
  
     if (!status)
     {
!       os::Printer::log("GLSL shader failed to compile:");
!       
!       // figure out size of error message
!       GLsizei bytes = 0;
!       Driver->extGlGetObjectParameterivARB(Program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &bytes);
! 
!       if (bytes != 0)
!       {
!          char* buffer = new char[bytes];
! 
!          // get the error message string
!          Driver->extGlGetInfoLogARB(Program, bytes, &bytes, buffer);
!          if (bytes != 0)
!             os::Printer::log(buffer);
! 
!          delete [] buffer;
!       }
! 
        return false;
     }
  
***************
*** 196,202 ****
  
     if (!status)
     {
!       os::Printer::log("GLSL shader program failed to link");
        return false;
     }
     
--- 213,236 ----
  
     if (!status)
     {
!       os::Printer::log("GLSL shader program failed to link:");
! 
!       // figure out size of error message
!       GLsizei bytes = 0;
!       Driver->extGlGetObjectParameterivARB(Program, GL_OBJECT_INFO_LOG_LENGTH_ARB, &bytes);
! 
!       if (bytes != 0)
!       {
!          char* buffer = new char[bytes];
! 
!          // get the error message string
!          Driver->extGlGetInfoLogARB(Program, bytes, &bytes, buffer);
!          if (bytes != 0)
!             os::Printer::log(buffer);
! 
!          delete [] buffer;
!       }
! 
        return false;
     }
Post Reply