![]() |
![]() |
![]() |
COGL 0.8.2 Reference Manual | ![]() |
---|---|---|---|---|
Shaders and Programmable PipelineShaders and Programmable Pipeline — Fuctions for accessing the programmable GL pipeline |
CoglHandle cogl_create_shader (COGLenum shader_type); CoglHandle cogl_shader_ref (CoglHandle handle); void cogl_shader_unref (CoglHandle handle); gboolean cogl_is_shader (CoglHandle handle); void cogl_shader_source (CoglHandle shader, const gchar *source); void cogl_shader_compile (CoglHandle handle); void cogl_shader_get_info_log (CoglHandle handle, guint size, gchar *buffer); void cogl_shader_get_parameteriv (CoglHandle handle, COGLenum pname, COGLint *dest); CoglHandle cogl_create_program (void); CoglHandle cogl_program_ref (CoglHandle handle); void cogl_program_unref (CoglHandle handle); gboolean cogl_is_program (CoglHandle handle); void cogl_program_attach_shader (CoglHandle program_handle, CoglHandle shader_handle); void cogl_program_link (CoglHandle handle); void cogl_program_use (CoglHandle handle); COGLint cogl_program_get_uniform_location (CoglHandle handle, const gchar *uniform_name); void cogl_program_uniform_1f (COGLint uniform_no, gfloat value);
COGL allows accessing the GL programmable pipeline in order to create vertex and fragment shaders.
The only supported format is GLSL shaders.
CoglHandle cogl_create_shader (COGLenum shader_type);
Create a new shader handle, use cogl_shader_source to set the source code to be used on it.
|
CGL_VERTEX_SHADER or CGL_FRAGMENT_SHADER. |
Returns : |
a new shader handle. |
CoglHandle cogl_shader_ref (CoglHandle handle);
Add an extra reference to a shader.
|
A CoglHandle to a shader. |
Returns : |
handle
|
void cogl_shader_unref (CoglHandle handle);
Removes a reference to a shader. If it was the last reference the shader object will be destroyed.
|
A CoglHandle to a shader. |
gboolean cogl_is_shader (CoglHandle handle);
Gets whether the given handle references an existing shader object.
void cogl_shader_source (CoglHandle shader, const gchar *source);
Replaces the current GLSL source associated with a shader with a new one.
|
CoglHandle for a shader. |
|
GLSL shader source. |
void cogl_shader_compile (CoglHandle handle);
Compiles the shader, no return value, but the shader is now ready for linking into a program.
|
CoglHandle for a shader. |
void cogl_shader_get_info_log (CoglHandle handle, guint size, gchar *buffer);
Retrieves the information log for a coglobject, can be used in conjunction with cogl_shader_get_parameteriv to retrieve the compiler warnings/error messages that caused a shader to not compile correctly, mainly useful for debugging purposes.
|
CoglHandle for a shader. |
|
maximum number of bytes to retrieve. |
|
location for info log. |
void cogl_shader_get_parameteriv (CoglHandle handle, COGLenum pname, COGLint *dest);
Retrieve a named parameter from a shader can be used to query to compile
satus of a shader by passing in CGL_OBJECT_COMPILE_STATUS for pname
.
|
CoglHandle for a shader. |
|
the named COGL parameter to retrieve. |
|
storage location for COGLint return value. |
CoglHandle cogl_create_program (void);
Create a new cogl program object that can be used to replace parts of the GL rendering pipeline with custom code.
Returns : |
a new cogl program. |
CoglHandle cogl_program_ref (CoglHandle handle);
Add an extra reference to a program.
|
A CoglHandle to a program. |
Returns : |
handle
|
void cogl_program_unref (CoglHandle handle);
Removes a reference to a program. If it was the last reference the program object will be destroyed.
|
A CoglHandle to a program. |
gboolean cogl_is_program (CoglHandle handle);
Gets whether the given handle references an existing program object.
void cogl_program_attach_shader (CoglHandle program_handle, CoglHandle shader_handle);
Attaches a shader to a program object, a program can have one vertex shader and one fragment shader attached.
|
a CoglHandle for a shdaer program. |
|
a CoglHandle for a vertex of fragment shader. |
void cogl_program_link (CoglHandle handle);
Links a program making it ready for use.
|
a CoglHandle for a shader program. |
void cogl_program_use (CoglHandle handle);
Activate a specific shader program replacing that part of the GL rendering pipeline, if passed in COGL_INVALID_HANDLE the default behavior of GL is reinstated.
|
a CoglHandle for a shader program or COGL_INVALID_HANDLE. |
COGLint cogl_program_get_uniform_location (CoglHandle handle, const gchar *uniform_name);
Retrieve the location (offset) of a uniform variable in a shader program, a uniform is a variable that is constant for all vertices/fragments for a shader object and is possible to modify as an external parameter.
|
a CoglHandle for a shader program. |
|
the name of a uniform. |
Returns : |
the offset of a uniform in a specified program, this uniform can be set using cogl_program_uniform_1f when the program is in use. |
void cogl_program_uniform_1f (COGLint uniform_no, gfloat value);
Changes the value of a uniform in the currently used (see cogl_program_use) shader program.
|
the unform to set. |
|
the new value of the uniform. |