cogl-shader-boilerplate: Move the uniforms to the common code

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.
This commit is contained in:
Neil Roberts 2011-01-12 13:47:55 +00:00
parent e8d5be0ba7
commit 9ff04e8a99

View File

@ -30,12 +30,17 @@
#include "cogl.h" #include "cogl.h"
#ifndef HAVE_COGL_GLES2
#define _COGL_COMMON_SHADER_BOILERPLATE \ #define _COGL_COMMON_SHADER_BOILERPLATE \
"#define COGL_VERSION 100\n" \ "#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" "\n"
#ifndef HAVE_COGL_GLES2
#define _COGL_VERTEX_SHADER_BOILERPLATE \ #define _COGL_VERTEX_SHADER_BOILERPLATE \
_COGL_COMMON_SHADER_BOILERPLATE \ _COGL_COMMON_SHADER_BOILERPLATE \
"#define cogl_position_in gl_Vertex\n" \ "#define cogl_position_in gl_Vertex\n" \
@ -54,12 +59,7 @@
"#define cogl_position_out gl_Position\n" \ "#define cogl_position_out gl_Position\n" \
"#define cogl_point_size_out gl_PointSize\n" \ "#define cogl_point_size_out gl_PointSize\n" \
"#define cogl_color_out gl_FrontColor\n" \ "#define cogl_color_out gl_FrontColor\n" \
"#define cogl_tex_coord_out gl_TexCoord\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_FRAGMENT_SHADER_BOILERPLATE \ #define _COGL_FRAGMENT_SHADER_BOILERPLATE \
_COGL_COMMON_SHADER_BOILERPLATE \ _COGL_COMMON_SHADER_BOILERPLATE \
@ -79,6 +79,14 @@
#else /* HAVE_COGL_GLES2 */ #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 /* This declares all of the variables that we might need. This is
working on the assumption that the compiler will optimise them out working on the assumption that the compiler will optimise them out
if they are not actually used. The GLSL spec for GLES at least if they are not actually used. The GLSL spec for GLES at least
@ -95,12 +103,7 @@
"attribute vec4 cogl_color_in;\n" \ "attribute vec4 cogl_color_in;\n" \
"attribute vec4 cogl_position_in;\n" \ "attribute vec4 cogl_position_in;\n" \
"#define cogl_tex_coord_in cogl_tex_coord0_in;\n" \ "#define cogl_tex_coord_in cogl_tex_coord0_in;\n" \
"attribute vec3 cogl_normal_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"
#define _COGL_FRAGMENT_SHADER_BOILERPLATE \ #define _COGL_FRAGMENT_SHADER_BOILERPLATE \
_COGL_COMMON_SHADER_BOILERPLATE \ _COGL_COMMON_SHADER_BOILERPLATE \