# HG changeset patch # User Sam Lantinga # Date 1297225899 28800 # Node ID e82908c86c9ccfbd7546d8f23883a9ace3e519fa # Parent 8efa43b915be9c19a6eb4faae96d440904ffd49d Made the shaders easier to debug when they don't compile diff -r 8efa43b915be -r e82908c86c9c src/render/opengl/SDL_shaders_gl.c --- a/src/render/opengl/SDL_shaders_gl.c Tue Feb 08 20:23:52 2011 -0800 +++ b/src/render/opengl/SDL_shaders_gl.c Tue Feb 08 20:31:39 2011 -0800 @@ -31,6 +31,8 @@ /* OpenGL shader implementation */ +/*#define DEBUG_SHADERS*/ + typedef struct { GLenum program; @@ -74,51 +76,43 @@ /* SHADER_SOLID */ { /* vertex shader */ - " \ -varying vec4 v_color; \ - \ -void main() \ -{ \ - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \ - v_color = gl_Color; \ -} \ -", +"varying vec4 v_color;\n" +"\n" +"void main()\n" +"{\n" +" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +" v_color = gl_Color;\n" +"}", /* fragment shader */ - " \ -varying vec4 v_color; \ - \ -void main() \ -{ \ - gl_FragColor = v_color; \ -} \ -" +"varying vec4 v_color;\n" +"\n" +"void main()\n" +"{\n" +" gl_FragColor = v_color;\n" +"}" }, /* SHADER_RGB */ { /* vertex shader */ - " \ -varying vec4 v_color; \ -varying vec2 v_texCoord; \ - \ -void main() \ -{ \ - gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \ - v_color = gl_Color; \ - v_texCoord = vec2(gl_MultiTexCoord0); \ -} \ -", +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"\n" +"void main()\n" +"{\n" +" gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n" +" v_color = gl_Color;\n" +" v_texCoord = vec2(gl_MultiTexCoord0);\n" +"}", /* fragment shader */ - " \ -varying vec4 v_color; \ -varying vec2 v_texCoord; \ -uniform sampler2D tex0; \ - \ -void main() \ -{ \ - gl_FragColor = texture2D(tex0, v_texCoord) * v_color; \ -} \ -" +"varying vec4 v_color;\n" +"varying vec2 v_texCoord;\n" +"uniform sampler2D tex0;\n" +"\n" +"void main()\n" +"{\n" +" gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n" +"}" }, }; @@ -142,8 +136,11 @@ info = SDL_stack_alloc(char, length+1); ctx->glGetInfoLogARB(shader, length, NULL, info); SDL_LogError(SDL_LOG_CATEGORY_RENDER, - "Failed to compile shader:\n%s\n%s", source, info); -fprintf(stderr, "Failed to compile shader:\n%s\n%s", source, info); + "Failed to compile shader:\n%s%s\n%s", defines, source, info); +#ifdef DEBUG_SHADERS + fprintf(stderr, + "Failed to compile shader:\n%s%s\n%s", defines, source, info); +#endif SDL_stack_free(info); return SDL_FALSE;