Class
CoglShader
Description [src]
final class Cogl.Shader : GObject.Object
{
/* No available fields */
}
Functions for accessing the programmable GL pipeline
Cogl allows accessing the GL programmable pipeline in order to create vertex and fragment shaders.
When using GLSL Cogl provides replacement names for most of the builtin varyings and uniforms. It is recommended to use these names wherever possible to increase portability between OpenGL 2.0 and GLES 2.0. GLES 2.0 does not have most of the builtins under their original names so they will only work with the Cogl names.
For use in all GLSL shaders, the Cogl builtins are as follows:
uniform mat4 cogl_modelview_matrixThe current modelview matrix. This is equivalent to #gl_ModelViewMatrix.uniform mat4 cogl_projection_matrixThe current projection matrix. This is equivalent to #gl_ProjectionMatrix.uniform mat4 cogl_modelview_projection_matrixThe combined modelview and projection matrix. A vertex shader would typically use this to transform the incoming vertex position. The separate modelview and projection matrices are usually only needed for lighting calculations. This is equivalent to #gl_ModelViewProjectionMatrix.uniform mat4 cogl_texture_matrix[]An array of matrices for transforming the texture coordinates. This is equivalent to #gl_TextureMatrix.
In a vertex shader, the following are also available:
attribute vec4 cogl_position_inThe incoming vertex position. This is equivalent to #gl_Vertex.attribute vec4 cogl_color_inThe incoming vertex color. This is equivalent to #gl_Color.attribute vec4 cogl_tex_coord_inThe texture coordinate for the first texture unit. This is equivalent to #gl_MultiTexCoord0.attribute vec4 cogl_tex_coord0_inThe texture coordinate for the first texture unit. This is equivalent to #gl_MultiTexCoord0. There is also #cogl_tex_coord1_in and so on.attribute vec3 cogl_normal_inThe normal of the vertex. This is equivalent to #gl_Normal.vec4 cogl_position_outThe calculated position of the vertex. This must be written to in all vertex shaders. This is equivalent to #gl_Position.float cogl_point_size_outThe calculated size of a point. This is equivalent to #gl_PointSize.varying vec4 cogl_color_outThe calculated color of a vertex. This is equivalent to #gl_FrontColor.varying vec4 cogl_tex_coord_out[]An array of calculated texture coordinates for a vertex. This is equivalent to #gl_TexCoord.
In a fragment shader, the following are also available:
varying vec4 cogl_color_inThe calculated color of a vertex. This is equivalent to #gl_FrontColor.varying vec4 cogl_tex_coord_in[]An array of calculated texture coordinates for a vertex. This is equivalent to #gl_TexCoord.vec4 cogl_color_outThe final calculated color of the fragment. All fragment shaders must write to this variable. This is equivalent to #gl_FrontColor.float cogl_depth_outAn optional output variable specifying the depth value to use for this fragment. This is equivalent to #gl_FragDepth.bool cogl_front_facingA readonly variable that will be true if the current primitive is front facing. This can be used to implement two-sided coloring algorithms. This is equivalent to #gl_FrontFacing.
It’s worth nothing that this API isn’t what Cogl would like to have
in the long term and it may be removed in Cogl 2.0. The experimental CoglShader API is the proposed replacement.
Constructors
cogl_shader_new
Create a new shader handle, use cogl_shader_source() to set the
source code to be used on it.
deprecated: 1.16
Instance methods
cogl_shader_source
Replaces the current source associated with a shader with a new one.
deprecated: 1.16
Signals
Signals inherited from GObject (1)
GObject::notify
The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.