~oem-solutions-group/unity-2d/clutter-1.0

« back to all changes in this revision

Viewing changes to clutter/cogl/cogl/cogl-shader.h

  • Committer: Bazaar Package Importer
  • Author(s): Emilio Pozuelo Monfort
  • Date: 2010-03-21 13:27:56 UTC
  • mto: (2.1.3 experimental)
  • mto: This revision was merged to the branch mainline in revision 8.
  • Revision ID: james.westby@ubuntu.com-20100321132756-nf8yd30yxo3zzwcm
Tags: upstream-1.2.2
ImportĀ upstreamĀ versionĀ 1.2.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Cogl
 
3
 *
 
4
 * An object oriented GL/GLES Abstraction/Utility Layer
 
5
 *
 
6
 * Copyright (C) 2008,2009 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 <http://www.gnu.org/licenses/>.
 
20
 *
 
21
 *
 
22
 */
 
23
 
 
24
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
 
25
#error "Only <cogl/cogl.h> can be included directly."
 
26
#endif
 
27
 
 
28
#ifndef __COGL_SHADER_H__
 
29
#define __COGL_SHADER_H__
 
30
 
 
31
#include <cogl/cogl-types.h>
 
32
#include <cogl/cogl-defines.h>
 
33
 
 
34
G_BEGIN_DECLS
 
35
 
 
36
/**
 
37
 * SECTION:cogl-shaders
 
38
 * @short_description: Fuctions for accessing the programmable GL pipeline
 
39
 *
 
40
 * COGL allows accessing the GL programmable pipeline in order to create
 
41
 * vertex and fragment shaders.
 
42
 *
 
43
 * The only supported format is GLSL shaders.
 
44
 */
 
45
 
 
46
/**
 
47
 * CoglShaderType:
 
48
 * @COGL_SHADER_TYPE_VERTEX: A program for proccessing vertices
 
49
 * @COGL_SHADER_TYPE_FRAGMENT: A program for processing fragments
 
50
 *
 
51
 * Types of shaders
 
52
 *
 
53
 * Since: 1.0
 
54
 */
 
55
typedef enum {
 
56
  COGL_SHADER_TYPE_VERTEX,
 
57
  COGL_SHADER_TYPE_FRAGMENT
 
58
} CoglShaderType;
 
59
 
 
60
/**
 
61
 * cogl_create_shader:
 
62
 * @shader_type: COGL_SHADER_TYPE_VERTEX or COGL_SHADER_TYPE_FRAGMENT.
 
63
 *
 
64
 * Create a new shader handle, use #cogl_shader_source to set the source code
 
65
 * to be used on it.
 
66
 *
 
67
 * Returns: a new shader handle.
 
68
 */
 
69
CoglHandle
 
70
cogl_create_shader (CoglShaderType shader_type);
 
71
 
 
72
#ifndef COGL_DISABLE_DEPRECATED
 
73
 
 
74
/**
 
75
 * cogl_shader_ref:
 
76
 * @handle: A #CoglHandle to a shader.
 
77
 *
 
78
 * Add an extra reference to a shader.
 
79
 *
 
80
 * Returns: @handle
 
81
 */
 
82
CoglHandle
 
83
cogl_shader_ref (CoglHandle handle) G_GNUC_DEPRECATED;
 
84
 
 
85
/**
 
86
 * cogl_shader_unref:
 
87
 * @handle: A #CoglHandle to a shader.
 
88
 *
 
89
 * Removes a reference to a shader. If it was the last reference the
 
90
 * shader object will be destroyed.
 
91
 */
 
92
void
 
93
cogl_shader_unref (CoglHandle handle) G_GNUC_DEPRECATED;
 
94
 
 
95
#endif /* COGL_DISABLE_DEPRECATED */
 
96
 
 
97
/**
 
98
 * cogl_is_shader:
 
99
 * @handle: A CoglHandle
 
100
 *
 
101
 * Gets whether the given handle references an existing shader object.
 
102
 *
 
103
 * Returns: %TRUE if the handle references a shader,
 
104
 *   %FALSE otherwise
 
105
 */
 
106
gboolean cogl_is_shader (CoglHandle handle);
 
107
 
 
108
/**
 
109
 * cogl_shader_source:
 
110
 * @shader: #CoglHandle for a shader.
 
111
 * @source: GLSL shader source.
 
112
 *
 
113
 * Replaces the current GLSL source associated with a shader with a new
 
114
 * one.
 
115
 */
 
116
void
 
117
cogl_shader_source (CoglHandle  shader,
 
118
                    const char *source);
 
119
/**
 
120
 * cogl_shader_compile:
 
121
 * @handle: #CoglHandle for a shader.
 
122
 *
 
123
 * Compiles the shader, no return value, but the shader is now ready for
 
124
 * linking into a program.
 
125
 */
 
126
void
 
127
cogl_shader_compile (CoglHandle handle);
 
128
 
 
129
/**
 
130
 * cogl_shader_get_info_log:
 
131
 * @handle: #CoglHandle for a shader.
 
132
 *
 
133
 * Retrieves the information log for a coglobject, can be used in conjunction
 
134
 * with cogl_shader_get_parameteriv() to retrieve the compiler warnings/error
 
135
 * messages that caused a shader to not compile correctly, mainly useful for
 
136
 * debugging purposes.
 
137
 *
 
138
 * Return value: a newly allocated string containing the info log. Use
 
139
 *   g_free() to free it
 
140
 */
 
141
char *
 
142
cogl_shader_get_info_log (CoglHandle handle);
 
143
 
 
144
/**
 
145
 * cogl_shader_get_type:
 
146
 * @handle: #CoglHandle for a shader.
 
147
 *
 
148
 * Retrieves the type of a shader #CoglHandle
 
149
 *
 
150
 * Return value: %COGL_SHADER_TYPE_VERTEX if the shader is a vertex processor
 
151
 *          or %COGL_SHADER_TYPE_FRAGMENT if the shader is a frament processor
 
152
 */
 
153
CoglShaderType
 
154
cogl_shader_get_type (CoglHandle handle);
 
155
 
 
156
/**
 
157
 * cogl_shader_is_compiled:
 
158
 * @handle: #CoglHandle for a shader.
 
159
 *
 
160
 * Retrieves whether a shader #CoglHandle has been compiled
 
161
 *
 
162
 * Return value: %TRUE if the shader object has sucessfully be compiled
 
163
 */
 
164
gboolean
 
165
cogl_shader_is_compiled (CoglHandle handle);
 
166
 
 
167
/**
 
168
 * cogl_create_program:
 
169
 *
 
170
 * Create a new cogl program object that can be used to replace parts of the GL
 
171
 * rendering pipeline with custom code.
 
172
 *
 
173
 * Returns: a new cogl program.
 
174
 */
 
175
CoglHandle
 
176
cogl_create_program (void);
 
177
 
 
178
/**
 
179
 * cogl_program_ref:
 
180
 * @handle: A #CoglHandle to a program.
 
181
 *
 
182
 * Add an extra reference to a program.
 
183
 *
 
184
 * Returns: @handle
 
185
 */
 
186
CoglHandle
 
187
cogl_program_ref (CoglHandle handle);
 
188
 
 
189
/**
 
190
 * cogl_program_unref:
 
191
 * @handle: A #CoglHandle to a program.
 
192
 *
 
193
 * Removes a reference to a program. If it was the last reference the
 
194
 * program object will be destroyed.
 
195
 */
 
196
void
 
197
cogl_program_unref (CoglHandle handle);
 
198
 
 
199
/**
 
200
 * cogl_is_program:
 
201
 * @handle: A CoglHandle
 
202
 *
 
203
 * Gets whether the given handle references an existing program object.
 
204
 *
 
205
 * Returns: %TRUE if the handle references a program,
 
206
 *   %FALSE otherwise
 
207
 */
 
208
gboolean
 
209
cogl_is_program (CoglHandle handle);
 
210
 
 
211
/**
 
212
 * cogl_program_attach_shader:
 
213
 * @program_handle: a #CoglHandle for a shdaer program.
 
214
 * @shader_handle: a #CoglHandle for a vertex of fragment shader.
 
215
 *
 
216
 * Attaches a shader to a program object, a program can have one vertex shader
 
217
 * and one fragment shader attached.
 
218
 */
 
219
void
 
220
cogl_program_attach_shader (CoglHandle program_handle,
 
221
                            CoglHandle shader_handle);
 
222
 
 
223
 
 
224
/**
 
225
 * cogl_program_link:
 
226
 * @handle: a #CoglHandle for a shader program.
 
227
 *
 
228
 * Links a program making it ready for use.
 
229
 */
 
230
void
 
231
cogl_program_link (CoglHandle handle);
 
232
 
 
233
/**
 
234
 * cogl_program_use:
 
235
 * @handle: a #CoglHandle for a shader program or %COGL_INVALID_HANDLE.
 
236
 *
 
237
 * Activate a specific shader program replacing that part of the GL
 
238
 * rendering pipeline, if passed in %COGL_INVALID_HANDLE the default
 
239
 * behavior of GL is reinstated.
 
240
 */
 
241
void
 
242
cogl_program_use (CoglHandle handle);
 
243
 
 
244
/**
 
245
 * cogl_program_get_uniform_location:
 
246
 * @handle: a #CoglHandle for a shader program.
 
247
 * @uniform_name: the name of a uniform.
 
248
 *
 
249
 * Retrieve the location (offset) of a uniform variable in a shader program,
 
250
 * a uniform is a variable that is constant for all vertices/fragments for a
 
251
 * shader object and is possible to modify as an external parameter.
 
252
 *
 
253
 * Return value: the offset of a uniform in a specified program.
 
254
 *   This uniform can be set using cogl_program_uniform_1f() when the
 
255
 *   program is in use.
 
256
 */
 
257
int
 
258
cogl_program_get_uniform_location (CoglHandle  handle,
 
259
                                   const char *uniform_name);
 
260
 
 
261
/**
 
262
 * cogl_program_uniform_1f:
 
263
 * @uniform_no: the unform to set.
 
264
 * @value: the new value of the uniform.
 
265
 *
 
266
 * Changes the value of a floating point uniform in the currently
 
267
 * used (see cogl_program_use()) shader program.
 
268
 */
 
269
void
 
270
cogl_program_uniform_1f (int   uniform_no,
 
271
                         float value);
 
272
 
 
273
/**
 
274
 * cogl_program_uniform_1i:
 
275
 * @uniform_no: the unform to set.
 
276
 * @value: the new value of the uniform.
 
277
 *
 
278
 * Changes the value of an integer uniform in the currently
 
279
 * used (see cogl_program_use()) shader program.
 
280
 */
 
281
void
 
282
cogl_program_uniform_1i (int uniform_no,
 
283
                         int value);
 
284
 
 
285
 /**
 
286
 * cogl_program_uniform_float:
 
287
 * @uniform_no: the uniform to set.
 
288
 * @size: Size of float vector.
 
289
 * @count: Size of array of uniforms.
 
290
 * @value: (array length=count): the new value of the uniform.
 
291
 *
 
292
 * Changes the value of a float vector uniform, or uniform array in the
 
293
 * currently used (see cogl_program_use()) shader program.
 
294
 */
 
295
void
 
296
cogl_program_uniform_float (int            uniform_no,
 
297
                            int            size,
 
298
                            int            count,
 
299
                            const GLfloat *value);
 
300
 
 
301
/**
 
302
 * cogl_program_uniform_int:
 
303
 * @uniform_no: the uniform to set.
 
304
 * @size: Size of int vector.
 
305
 * @count: Size of array of uniforms.
 
306
 * @value: (array length=count): the new value of the uniform.
 
307
 *
 
308
 * Changes the value of a int vector uniform, or uniform array in the
 
309
 * currently used (see cogl_program_use()) shader program.
 
310
 */
 
311
void
 
312
cogl_program_uniform_int (int        uniform_no,
 
313
                          int        size,
 
314
                          int        count,
 
315
                          const int *value);
 
316
 
 
317
/**
 
318
 * cogl_program_uniform_matrix:
 
319
 * @uniform_no: the uniform to set.
 
320
 * @size: Size of matrix.
 
321
 * @count: Size of array of uniforms.
 
322
 * @transpose: Whether to transpose the matrix when setting the uniform.
 
323
 * @value: (array length=count): the new value of the uniform.
 
324
 *
 
325
 * Changes the value of a matrix uniform, or uniform array in the
 
326
 * currently used (see cogl_program_use()) shader program. The @size
 
327
 * parameter is used to determine the square size of the matrix.
 
328
 */
 
329
void
 
330
cogl_program_uniform_matrix (int          uniform_no,
 
331
                             int          size,
 
332
                             int          count,
 
333
                             gboolean     transpose,
 
334
                             const float *value);
 
335
 
 
336
G_END_DECLS
 
337
 
 
338
#endif /* __COGL_SHADER_H__ */