cleanup specfile for packaging
[profile/ivi/cogl.git] / cogl / cogl-shader-boilerplate.h
1 /*
2  * Cogl
3  *
4  * An object oriented GL/GLES Abstraction/Utility Layer
5  *
6  * Copyright (C) 2010 Intel Corporation.
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library. If not, see
20  * <http://www.gnu.org/licenses/>.
21  *
22  *
23  * Authors:
24  *   Robert Bragg <robert@linux.intel.com>
25  */
26
27 #ifndef __COGL_SHADER_BOILERPLATE_H
28 #define __COGL_SHADER_BOILERPLATE_H
29
30
31 #define _COGL_COMMON_SHADER_BOILERPLATE_GL \
32   "#define COGL_VERSION 100\n" \
33   "\n" \
34   "#define cogl_modelview_matrix gl_ModelViewMatrix\n" \
35   "#define cogl_modelview_projection_matrix gl_ModelViewProjectionMatrix\n" \
36   "#define cogl_projection_matrix gl_ProjectionMatrix\n" \
37   "#define cogl_texture_matrix gl_TextureMatrix\n" \
38   "\n"
39
40 #define _COGL_VERTEX_SHADER_BOILERPLATE_GL \
41   _COGL_COMMON_SHADER_BOILERPLATE_GL \
42   "#define cogl_position_in gl_Vertex\n" \
43   "#define cogl_color_in gl_Color\n" \
44   "#define cogl_tex_coord_in  gl_MultiTexCoord0\n" \
45   "#define cogl_tex_coord0_in gl_MultiTexCoord0\n" \
46   "#define cogl_tex_coord1_in gl_MultiTexCoord1\n" \
47   "#define cogl_tex_coord2_in gl_MultiTexCoord2\n" \
48   "#define cogl_tex_coord3_in gl_MultiTexCoord3\n" \
49   "#define cogl_tex_coord4_in gl_MultiTexCoord4\n" \
50   "#define cogl_tex_coord5_in gl_MultiTexCoord5\n" \
51   "#define cogl_tex_coord6_in gl_MultiTexCoord6\n" \
52   "#define cogl_tex_coord7_in gl_MultiTexCoord7\n" \
53   "#define cogl_normal_in gl_Normal\n" \
54   "\n" \
55   "#define cogl_position_out gl_Position\n" \
56   "#define cogl_point_size_out gl_PointSize\n" \
57   "#define cogl_color_out gl_FrontColor\n" \
58   "#define cogl_tex_coord_out gl_TexCoord\n"
59
60 #define _COGL_FRAGMENT_SHADER_BOILERPLATE_GL \
61   _COGL_COMMON_SHADER_BOILERPLATE_GL \
62   "#define cogl_color_in gl_Color\n" \
63   "#define cogl_tex_coord_in gl_TexCoord\n" \
64   "\n" \
65   "#define cogl_color_out gl_FragColor\n" \
66   "#define cogl_depth_out gl_FragDepth\n" \
67   "\n" \
68   "#define cogl_front_facing gl_FrontFacing\n"
69 #if 0
70   /* GLSL 1.2 has a bottom left origin, though later versions
71    * allow use of an origin_upper_left keyword which would be
72    * more appropriate for Cogl. */
73   "#define coglFragCoord   gl_FragCoord\n"
74 #endif
75
76 #define _COGL_COMMON_SHADER_BOILERPLATE_GLES2 \
77   "#define COGL_VERSION 100\n" \
78   "\n" \
79   "uniform mat4 cogl_modelview_matrix;\n" \
80   "uniform mat4 cogl_modelview_projection_matrix;\n"  \
81   "uniform mat4 cogl_projection_matrix;\n" \
82   "uniform float cogl_point_size_in;\n"
83
84 /* This declares all of the variables that we might need. This is
85    working on the assumption that the compiler will optimise them out
86    if they are not actually used. The GLSL spec for GLES at least
87    implies that this will happen for varyings but it doesn't
88    explicitly so for attributes */
89 #define _COGL_VERTEX_SHADER_BOILERPLATE_GLES2 \
90   _COGL_COMMON_SHADER_BOILERPLATE_GLES2 \
91   "#define cogl_color_out _cogl_color\n" \
92   "varying vec4 _cogl_color;\n" \
93   "#define cogl_tex_coord_out _cogl_tex_coord\n" \
94   "#define cogl_position_out gl_Position\n" \
95   "#define cogl_point_size_out gl_PointSize\n" \
96   "\n" \
97   "attribute vec4 cogl_color_in;\n" \
98   "attribute vec4 cogl_position_in;\n" \
99   "#define cogl_tex_coord_in cogl_tex_coord0_in;\n" \
100   "attribute vec3 cogl_normal_in;\n"
101
102 #define _COGL_FRAGMENT_SHADER_BOILERPLATE_GLES2 \
103   "#if __VERSION__ == 100\n" \
104   "precision highp float;\n" \
105   "#endif\n" \
106   _COGL_COMMON_SHADER_BOILERPLATE_GLES2 \
107   "\n" \
108   "varying vec4 _cogl_color;\n" \
109   "\n" \
110   "#define cogl_color_in _cogl_color\n" \
111   "#define cogl_tex_coord_in _cogl_tex_coord\n" \
112   "\n" \
113   "#define cogl_color_out gl_FragColor\n" \
114   "#define cogl_depth_out gl_FragDepth\n" \
115   "\n" \
116   "#define cogl_front_facing gl_FrontFacing\n"
117
118 #endif /* __COGL_SHADER_BOILERPLATE_H */
119