4
* An object oriented GL/GLES Abstraction/Utility Layer
6
* Copyright (C) 2008,2009 Intel Corporation.
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.
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.
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/>.
24
#if !defined(__COGL_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
25
#error "Only <cogl/cogl.h> can be included directly."
28
#ifndef __COGL_SHADER_H__
29
#define __COGL_SHADER_H__
31
#include <cogl/cogl-types.h>
32
#include <cogl/cogl-defines.h>
37
* SECTION:cogl-shaders
38
* @short_description: Fuctions for accessing the programmable GL pipeline
40
* COGL allows accessing the GL programmable pipeline in order to create
41
* vertex and fragment shaders.
43
* The only supported format is GLSL shaders.
48
* @COGL_SHADER_TYPE_VERTEX: A program for proccessing vertices
49
* @COGL_SHADER_TYPE_FRAGMENT: A program for processing fragments
56
COGL_SHADER_TYPE_VERTEX,
57
COGL_SHADER_TYPE_FRAGMENT
62
* @shader_type: COGL_SHADER_TYPE_VERTEX or COGL_SHADER_TYPE_FRAGMENT.
64
* Create a new shader handle, use #cogl_shader_source to set the source code
67
* Returns: a new shader handle.
70
cogl_create_shader (CoglShaderType shader_type);
72
#ifndef COGL_DISABLE_DEPRECATED
76
* @handle: A #CoglHandle to a shader.
78
* Add an extra reference to a shader.
83
cogl_shader_ref (CoglHandle handle) G_GNUC_DEPRECATED;
87
* @handle: A #CoglHandle to a shader.
89
* Removes a reference to a shader. If it was the last reference the
90
* shader object will be destroyed.
93
cogl_shader_unref (CoglHandle handle) G_GNUC_DEPRECATED;
95
#endif /* COGL_DISABLE_DEPRECATED */
99
* @handle: A CoglHandle
101
* Gets whether the given handle references an existing shader object.
103
* Returns: %TRUE if the handle references a shader,
106
gboolean cogl_is_shader (CoglHandle handle);
109
* cogl_shader_source:
110
* @shader: #CoglHandle for a shader.
111
* @source: GLSL shader source.
113
* Replaces the current GLSL source associated with a shader with a new
117
cogl_shader_source (CoglHandle shader,
120
* cogl_shader_compile:
121
* @handle: #CoglHandle for a shader.
123
* Compiles the shader, no return value, but the shader is now ready for
124
* linking into a program.
127
cogl_shader_compile (CoglHandle handle);
130
* cogl_shader_get_info_log:
131
* @handle: #CoglHandle for a shader.
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.
138
* Return value: a newly allocated string containing the info log. Use
139
* g_free() to free it
142
cogl_shader_get_info_log (CoglHandle handle);
145
* cogl_shader_get_type:
146
* @handle: #CoglHandle for a shader.
148
* Retrieves the type of a shader #CoglHandle
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
154
cogl_shader_get_type (CoglHandle handle);
157
* cogl_shader_is_compiled:
158
* @handle: #CoglHandle for a shader.
160
* Retrieves whether a shader #CoglHandle has been compiled
162
* Return value: %TRUE if the shader object has sucessfully be compiled
165
cogl_shader_is_compiled (CoglHandle handle);
168
* cogl_create_program:
170
* Create a new cogl program object that can be used to replace parts of the GL
171
* rendering pipeline with custom code.
173
* Returns: a new cogl program.
176
cogl_create_program (void);
180
* @handle: A #CoglHandle to a program.
182
* Add an extra reference to a program.
187
cogl_program_ref (CoglHandle handle);
190
* cogl_program_unref:
191
* @handle: A #CoglHandle to a program.
193
* Removes a reference to a program. If it was the last reference the
194
* program object will be destroyed.
197
cogl_program_unref (CoglHandle handle);
201
* @handle: A CoglHandle
203
* Gets whether the given handle references an existing program object.
205
* Returns: %TRUE if the handle references a program,
209
cogl_is_program (CoglHandle handle);
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.
216
* Attaches a shader to a program object, a program can have one vertex shader
217
* and one fragment shader attached.
220
cogl_program_attach_shader (CoglHandle program_handle,
221
CoglHandle shader_handle);
226
* @handle: a #CoglHandle for a shader program.
228
* Links a program making it ready for use.
231
cogl_program_link (CoglHandle handle);
235
* @handle: a #CoglHandle for a shader program or %COGL_INVALID_HANDLE.
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.
242
cogl_program_use (CoglHandle handle);
245
* cogl_program_get_uniform_location:
246
* @handle: a #CoglHandle for a shader program.
247
* @uniform_name: the name of a uniform.
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.
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
258
cogl_program_get_uniform_location (CoglHandle handle,
259
const char *uniform_name);
262
* cogl_program_uniform_1f:
263
* @uniform_no: the unform to set.
264
* @value: the new value of the uniform.
266
* Changes the value of a floating point uniform in the currently
267
* used (see cogl_program_use()) shader program.
270
cogl_program_uniform_1f (int uniform_no,
274
* cogl_program_uniform_1i:
275
* @uniform_no: the unform to set.
276
* @value: the new value of the uniform.
278
* Changes the value of an integer uniform in the currently
279
* used (see cogl_program_use()) shader program.
282
cogl_program_uniform_1i (int uniform_no,
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.
292
* Changes the value of a float vector uniform, or uniform array in the
293
* currently used (see cogl_program_use()) shader program.
296
cogl_program_uniform_float (int uniform_no,
299
const GLfloat *value);
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.
308
* Changes the value of a int vector uniform, or uniform array in the
309
* currently used (see cogl_program_use()) shader program.
312
cogl_program_uniform_int (int uniform_no,
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.
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.
330
cogl_program_uniform_matrix (int uniform_no,
338
#endif /* __COGL_SHADER_H__ */