cogl-shader-boilerplate: Move the uniforms to the common code
authorNeil Roberts <neil@linux.intel.com>
Wed, 12 Jan 2011 13:47:55 +0000 (13:47 +0000)
committerNeil Roberts <neil@linux.intel.com>
Mon, 24 Jan 2011 12:09:11 +0000 (12:09 +0000)
The builtin uniforms are accessible from either the vertex shader or
the fragment shader so we should define them in the common
section. This doesn't really matter for the current list of uniforms
because it's pretty unlikely that you'd want to access the matrices
from the fragment shader, but for other builtins such as the lighting
material properties it makes sense.

clutter/cogl/cogl/cogl-shader-boilerplate.h

index 115e84b..db7a6b3 100644 (file)
 #include "cogl.h"
 
 
+#ifndef HAVE_COGL_GLES2
+
 #define _COGL_COMMON_SHADER_BOILERPLATE \
   "#define COGL_VERSION 100\n" \
+  "\n" \
+  "#define cogl_modelview_matrix gl_ModelViewMatrix\n" \
+  "#define cogl_modelview_projection_matrix gl_ModelViewProjectionMatrix\n" \
+  "#define cogl_projection_matrix gl_ProjectionMatrix\n" \
+  "#define cogl_texture_matrix gl_TextureMatrix\n" \
   "\n"
 
-#ifndef HAVE_COGL_GLES2
-
 #define _COGL_VERTEX_SHADER_BOILERPLATE \
   _COGL_COMMON_SHADER_BOILERPLATE \
   "#define cogl_position_in gl_Vertex\n" \
   "#define cogl_position_out gl_Position\n" \
   "#define cogl_point_size_out gl_PointSize\n" \
   "#define cogl_color_out gl_FrontColor\n" \
-  "#define cogl_tex_coord_out gl_TexCoord\n" \
-  "\n" \
-  "#define cogl_modelview_matrix gl_ModelViewMatrix\n" \
-  "#define cogl_modelview_projection_matrix gl_ModelViewProjectionMatrix\n" \
-  "#define cogl_projection_matrix gl_ProjectionMatrix\n" \
-  "#define cogl_texture_matrix gl_TextureMatrix\n"
+  "#define cogl_tex_coord_out gl_TexCoord\n"
 
 #define _COGL_FRAGMENT_SHADER_BOILERPLATE \
   _COGL_COMMON_SHADER_BOILERPLATE \
 
 #else /* HAVE_COGL_GLES2 */
 
+#define _COGL_COMMON_SHADER_BOILERPLATE \
+  "#define COGL_VERSION 100\n" \
+  "\n" \
+  "uniform mat4 cogl_modelview_matrix;\n" \
+  "uniform mat4 cogl_modelview_projection_matrix;\n"  \
+  "uniform mat4 cogl_projection_matrix;\n" \
+  "uniform float cogl_point_size_in;\n"
+
 /* This declares all of the variables that we might need. This is
    working on the assumption that the compiler will optimise them out
    if they are not actually used. The GLSL spec for GLES at least
   "attribute vec4 cogl_color_in;\n" \
   "attribute vec4 cogl_position_in;\n" \
   "#define cogl_tex_coord_in cogl_tex_coord0_in;\n" \
-  "attribute vec3 cogl_normal_in;\n" \
-  "\n" \
-  "uniform mat4 cogl_modelview_matrix;\n" \
-  "uniform mat4 cogl_modelview_projection_matrix;\n"  \
-  "uniform mat4 cogl_projection_matrix;\n" \
-  "uniform float cogl_point_size_in;\n"
+  "attribute vec3 cogl_normal_in;\n"
 
 #define _COGL_FRAGMENT_SHADER_BOILERPLATE \
   _COGL_COMMON_SHADER_BOILERPLATE \