Browse Source

Fixed a bug where some Android devices would not print the infolog after a shader compile error.

Darryl Gough 13 years ago
parent
commit
92572e7a3f
1 changed files with 14 additions and 2 deletions
  1. 14 2
      gameplay/src/Effect.cpp

+ 14 - 2
gameplay/src/Effect.cpp

@@ -245,6 +245,10 @@ Effect* Effect::createFromSource(const char* vshPath, const char* vshSource, con
     if (success != GL_TRUE)
     {
         GL_ASSERT( glGetShaderiv(vertexShader, GL_INFO_LOG_LENGTH, &length) );
+        if (length == 0)
+        {
+            length = 4096;
+        }
         if (length > 0)
         {
             infoLog = new char[length];
@@ -256,7 +260,7 @@ Effect* Effect::createFromSource(const char* vshPath, const char* vshSource, con
         if (vshPath)
             writeShaderToErrorFile(vshPath, shaderSource[2]);
 
-        GP_ERROR("Compile failed for vertex shader '%s' with error '%s'.", vshPath == NULL ? "NULL" : vshPath, infoLog == NULL ? "" : infoLog);
+        GP_ERROR("Compile failed for vertex shader '%s' with error '%s'.", vshPath == NULL ? vshSource : vshPath, infoLog == NULL ? "" : infoLog);
         SAFE_DELETE_ARRAY(infoLog);
 
         // Clean up.
@@ -284,6 +288,10 @@ Effect* Effect::createFromSource(const char* vshPath, const char* vshSource, con
     if (success != GL_TRUE)
     {
         GL_ASSERT( glGetShaderiv(fragmentShader, GL_INFO_LOG_LENGTH, &length) );
+        if (length == 0)
+        {
+            length = 4096;
+        }
         if (length > 0)
         {
             infoLog = new char[length];
@@ -295,7 +303,7 @@ Effect* Effect::createFromSource(const char* vshPath, const char* vshSource, con
         if (fshPath)
             writeShaderToErrorFile(fshPath, shaderSource[2]);
 
-        GP_ERROR("Compile failed for fragment shader (%s): %s", fshPath == NULL ? "NULL" : fshPath, infoLog == NULL ? "" : infoLog);
+        GP_ERROR("Compile failed for fragment shader (%s): %s", fshPath == NULL ? fshSource : fshPath, infoLog == NULL ? "" : infoLog);
         SAFE_DELETE_ARRAY(infoLog);
 
         // Clean up.
@@ -320,6 +328,10 @@ Effect* Effect::createFromSource(const char* vshPath, const char* vshSource, con
     if (success != GL_TRUE)
     {
         GL_ASSERT( glGetProgramiv(program, GL_INFO_LOG_LENGTH, &length) );
+        if (length == 0)
+        {
+            length = 4096;
+        }
         if (length > 0)
         {
             infoLog = new char[length];