src/render/opengl/SDL_shaders_gl.c
changeset 5231 e82908c86c9c
parent 5230 8efa43b915be
child 5237 55b31686f82b
     1.1 --- a/src/render/opengl/SDL_shaders_gl.c	Tue Feb 08 20:23:52 2011 -0800
     1.2 +++ b/src/render/opengl/SDL_shaders_gl.c	Tue Feb 08 20:31:39 2011 -0800
     1.3 @@ -31,6 +31,8 @@
     1.4  
     1.5  /* OpenGL shader implementation */
     1.6  
     1.7 +/*#define DEBUG_SHADERS*/
     1.8 +
     1.9  typedef struct
    1.10  {
    1.11      GLenum program;
    1.12 @@ -74,51 +76,43 @@
    1.13      /* SHADER_SOLID */
    1.14      {
    1.15          /* vertex shader */
    1.16 -        " \
    1.17 -varying vec4 v_color; \
    1.18 - \
    1.19 -void main() \
    1.20 -{ \
    1.21 -    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \
    1.22 -    v_color = gl_Color; \
    1.23 -} \
    1.24 -",
    1.25 +"varying vec4 v_color;\n"
    1.26 +"\n"
    1.27 +"void main()\n"
    1.28 +"{\n"
    1.29 +"    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
    1.30 +"    v_color = gl_Color;\n"
    1.31 +"}",
    1.32          /* fragment shader */
    1.33 -        " \
    1.34 -varying vec4 v_color; \
    1.35 - \
    1.36 -void main() \
    1.37 -{ \
    1.38 -    gl_FragColor = v_color; \
    1.39 -} \
    1.40 -"
    1.41 +"varying vec4 v_color;\n"
    1.42 +"\n"
    1.43 +"void main()\n"
    1.44 +"{\n"
    1.45 +"    gl_FragColor = v_color;\n"
    1.46 +"}"
    1.47      },
    1.48  
    1.49      /* SHADER_RGB */
    1.50      {
    1.51          /* vertex shader */
    1.52 -        " \
    1.53 -varying vec4 v_color; \
    1.54 -varying vec2 v_texCoord; \
    1.55 - \
    1.56 -void main() \
    1.57 -{ \
    1.58 -    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; \
    1.59 -    v_color = gl_Color; \
    1.60 -    v_texCoord = vec2(gl_MultiTexCoord0); \
    1.61 -} \
    1.62 -",
    1.63 +"varying vec4 v_color;\n"
    1.64 +"varying vec2 v_texCoord;\n"
    1.65 +"\n"
    1.66 +"void main()\n"
    1.67 +"{\n"
    1.68 +"    gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;\n"
    1.69 +"    v_color = gl_Color;\n"
    1.70 +"    v_texCoord = vec2(gl_MultiTexCoord0);\n"
    1.71 +"}",
    1.72          /* fragment shader */
    1.73 -        " \
    1.74 -varying vec4 v_color; \
    1.75 -varying vec2 v_texCoord; \
    1.76 -uniform sampler2D tex0; \
    1.77 - \
    1.78 -void main() \
    1.79 -{ \
    1.80 -    gl_FragColor = texture2D(tex0, v_texCoord) * v_color; \
    1.81 -} \
    1.82 -"
    1.83 +"varying vec4 v_color;\n"
    1.84 +"varying vec2 v_texCoord;\n"
    1.85 +"uniform sampler2D tex0;\n"
    1.86 +"\n"
    1.87 +"void main()\n"
    1.88 +"{\n"
    1.89 +"    gl_FragColor = texture2D(tex0, v_texCoord) * v_color;\n"
    1.90 +"}"
    1.91      },
    1.92  };
    1.93  
    1.94 @@ -142,8 +136,11 @@
    1.95          info = SDL_stack_alloc(char, length+1);
    1.96          ctx->glGetInfoLogARB(shader, length, NULL, info);
    1.97          SDL_LogError(SDL_LOG_CATEGORY_RENDER,
    1.98 -            "Failed to compile shader:\n%s\n%s", source, info);
    1.99 -fprintf(stderr, "Failed to compile shader:\n%s\n%s", source, info);
   1.100 +            "Failed to compile shader:\n%s%s\n%s", defines, source, info);
   1.101 +#ifdef DEBUG_SHADERS
   1.102 +        fprintf(stderr,
   1.103 +            "Failed to compile shader:\n%s%s\n%s", defines, source, info);
   1.104 +#endif
   1.105          SDL_stack_free(info);
   1.106  
   1.107          return SDL_FALSE;