This is an automated email from the git hooks/post-receive script.

smcv pushed a commit to branch debian/master
in repository ioquake3.

commit 5252e28163fd0f4cb5dcc0bc073962a87a121cde
Author: SmileTheory <smilethe...@gmail.com>
Date:   Thu Aug 4 20:16:22 2016 -0700

    OpenGL2: Fix shader error logs.
---
 code/renderergl2/tr_glsl.c | 95 ++++++++++++++++++++++++++--------------------
 1 file changed, 53 insertions(+), 42 deletions(-)

diff --git a/code/renderergl2/tr_glsl.c b/code/renderergl2/tr_glsl.c
index d2bfbda..f934942 100644
--- a/code/renderergl2/tr_glsl.c
+++ b/code/renderergl2/tr_glsl.c
@@ -148,8 +148,15 @@ static uniformInfo_t uniformsInfo[] =
        { "u_CubeMapInfo", GLSL_VEC4 },
 };
 
+typedef enum
+{
+       GLSL_PRINTLOG_PROGRAM_INFO,
+       GLSL_PRINTLOG_SHADER_INFO,
+       GLSL_PRINTLOG_SHADER_SOURCE
+}
+glslPrintLog_t;
 
-static void GLSL_PrintInfoLog(GLuint program, qboolean developerOnly)
+static void GLSL_PrintLog(GLuint programOrShader, glslPrintLog_t type, 
qboolean developerOnly)
 {
        char           *msg;
        static char     msgPart[1024];
@@ -157,61 +164,70 @@ static void GLSL_PrintInfoLog(GLuint program, qboolean 
developerOnly)
        int             i;
        int             printLevel = developerOnly ? PRINT_DEVELOPER : 
PRINT_ALL;
 
-       qglGetProgramiv(program, GL_INFO_LOG_LENGTH, &maxLength);
+       switch (type)
+       {
+               case GLSL_PRINTLOG_PROGRAM_INFO:
+                       ri.Printf(printLevel, "Program info log:\n");
+                       qglGetProgramiv(programOrShader, GL_INFO_LOG_LENGTH, 
&maxLength);
+                       break;
+
+               case GLSL_PRINTLOG_SHADER_INFO:
+                       ri.Printf(printLevel, "Shader info log:\n");
+                       qglGetShaderiv(programOrShader, GL_INFO_LOG_LENGTH, 
&maxLength);
+                       break;
+
+               case GLSL_PRINTLOG_SHADER_SOURCE:
+                       ri.Printf(printLevel, "Shader source:\n");
+                       qglGetShaderiv(programOrShader, 
GL_SHADER_SOURCE_LENGTH, &maxLength);
+                       break;
+       }
 
        if (maxLength <= 0)
        {
-               ri.Printf(printLevel, "No compile log.\n");
+               ri.Printf(printLevel, "None.\n");
                return;
        }
 
-       ri.Printf(printLevel, "compile log:\n");
-
        if (maxLength < 1023)
+               msg = msgPart;
+       else
+               msg = ri.Malloc(maxLength);
+
+       switch (type)
        {
-               qglGetProgramInfoLog(program, maxLength, &maxLength, msgPart);
+               case GLSL_PRINTLOG_PROGRAM_INFO:
+                       qglGetProgramInfoLog(programOrShader, maxLength, 
&maxLength, msg);
+                       break;
+
+               case GLSL_PRINTLOG_SHADER_INFO:
+                       qglGetShaderInfoLog(programOrShader, maxLength, 
&maxLength, msg);
+                       break;
 
+               case GLSL_PRINTLOG_SHADER_SOURCE:
+                       qglGetShaderSource(programOrShader, maxLength, 
&maxLength, msg);
+                       break;
+       }
+
+       if (maxLength < 1023)
+       {
                msgPart[maxLength + 1] = '\0';
 
                ri.Printf(printLevel, "%s\n", msgPart);
        }
        else
        {
-               msg = ri.Malloc(maxLength);
-
-               qglGetProgramInfoLog(program, maxLength, &maxLength, msg);
-
-               for(i = 0; i < maxLength; i += 1024)
+               for(i = 0; i < maxLength; i += 1023)
                {
                        Q_strncpyz(msgPart, msg + i, sizeof(msgPart));
 
-                       ri.Printf(printLevel, "%s\n", msgPart);
+                       ri.Printf(printLevel, "%s", msgPart);
                }
 
-               ri.Free(msg);
-       }
-}
+               ri.Printf(printLevel, "\n");
 
-static void GLSL_PrintShaderSource(GLuint shader)
-{
-       char           *msg;
-       static char     msgPart[1024];
-       int             maxLength = 0;
-       int             i;
-
-       qglGetShaderiv(shader, GL_SHADER_SOURCE_LENGTH, &maxLength);
-
-       msg = ri.Malloc(maxLength);
-
-       qglShaderSource(shader, 1, (const GLchar **)&msg, &maxLength);
-
-       for(i = 0; i < maxLength; i += 1024)
-       {
-               Q_strncpyz(msgPart, msg + i, sizeof(msgPart));
-               ri.Printf(PRINT_ALL, "%s\n", msgPart);
+               ri.Free(msg);
        }
 
-       ri.Free(msg);
 }
 
 static void GLSL_GetShaderHeader( GLenum shaderType, const GLchar *extra, char 
*dest, int size )
@@ -365,15 +381,12 @@ static int GLSL_CompileGPUShader(GLuint program, GLuint 
*prevShader, const GLcha
        qglGetShaderiv(shader, GL_COMPILE_STATUS, &compiled);
        if(!compiled)
        {
-               GLSL_PrintShaderSource(shader);
-               GLSL_PrintInfoLog(shader, qfalse);
+               GLSL_PrintLog(shader, GLSL_PRINTLOG_SHADER_SOURCE, qfalse);
+               GLSL_PrintLog(shader, GLSL_PRINTLOG_SHADER_INFO, qfalse);
                ri.Error(ERR_DROP, "Couldn't compile shader");
                return 0;
        }
 
-       //GLSL_PrintInfoLog(shader, qtrue);
-       //GLSL_PrintShaderSource(shader);
-
        if (*prevShader)
        {
                qglDetachShader(program, *prevShader);
@@ -460,8 +473,7 @@ static void GLSL_LinkProgram(GLuint program)
        qglGetProgramiv(program, GL_LINK_STATUS, &linked);
        if(!linked)
        {
-               GLSL_PrintInfoLog(program, qfalse);
-               ri.Printf(PRINT_ALL, "\n");
+               GLSL_PrintLog(program, GLSL_PRINTLOG_PROGRAM_INFO, qfalse);
                ri.Error(ERR_DROP, "shaders failed to link");
        }
 }
@@ -475,8 +487,7 @@ static void GLSL_ValidateProgram(GLuint program)
        qglGetProgramiv(program, GL_VALIDATE_STATUS, &validated);
        if(!validated)
        {
-               GLSL_PrintInfoLog(program, qfalse);
-               ri.Printf(PRINT_ALL, "\n");
+               GLSL_PrintLog(program, GLSL_PRINTLOG_PROGRAM_INFO, qfalse);
                ri.Error(ERR_DROP, "shaders failed to validate");
        }
 }

-- 
Alioth's /usr/local/bin/git-commit-notice on 
/srv/git.debian.org/git/pkg-games/ioquake3.git

_______________________________________________
Pkg-games-commits mailing list
Pkg-games-commits@lists.alioth.debian.org
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/pkg-games-commits

Reply via email to