Cogl.Pipeline

g Cogl.Object Cogl.Object Cogl.Pipeline Cogl.Pipeline Cogl.Object->Cogl.Pipeline

Subclasses:

None

Methods

Inherited:

Cogl.Object (2)

class

new (context)

add_layer_snippet (layer, snippet)

add_snippet (snippet)

copy ()

foreach_layer (callback, *user_data)

get_alpha_test_function ()

get_alpha_test_reference ()

get_ambient (ambient)

get_color ()

get_color_mask ()

get_cull_face_mode ()

get_depth_state ()

get_diffuse (diffuse)

get_emission (emission)

get_front_face_winding ()

get_layer_mag_filter (layer_index)

get_layer_min_filter (layer_index)

get_layer_point_sprite_coords_enabled (layer_index)

get_layer_texture (layer_index)

get_layer_wrap_mode_p (layer_index)

get_layer_wrap_mode_s (layer_index)

get_layer_wrap_mode_t (layer_index)

get_n_layers ()

get_per_vertex_point_size ()

get_point_size ()

get_shininess ()

get_specular (specular)

get_uniform_location (uniform_name)

get_user_program ()

remove_layer (layer_index)

set_alpha_test_function (alpha_func, alpha_reference)

set_ambient (ambient)

set_ambient_and_diffuse (color)

set_blend (blend_string)

set_blend_constant (constant_color)

set_color (color)

set_color4f (red, green, blue, alpha)

set_color4ub (red, green, blue, alpha)

set_color_mask (color_mask)

set_cull_face_mode (cull_face_mode)

set_depth_state (state)

set_diffuse (diffuse)

set_emission (emission)

set_front_face_winding (front_winding)

set_layer_combine (layer_index, blend_string)

set_layer_combine_constant (layer_index, constant)

set_layer_filters (layer_index, min_filter, mag_filter)

set_layer_matrix (layer_index, matrix)

set_layer_null_texture (layer_index, texture_type)

set_layer_point_sprite_coords_enabled (layer_index, enable)

set_layer_texture (layer_index, texture)

set_layer_wrap_mode (layer_index, mode)

set_layer_wrap_mode_p (layer_index, mode)

set_layer_wrap_mode_s (layer_index, mode)

set_layer_wrap_mode_t (layer_index, mode)

set_per_vertex_point_size (enable)

set_point_size (point_size)

set_shininess (shininess)

set_specular (specular)

set_uniform_1f (uniform_location, value)

set_uniform_1i (uniform_location, value)

set_uniform_float (uniform_location, n_components, count, value)

set_uniform_int (uniform_location, n_components, count, value)

set_uniform_matrix (uniform_location, dimensions, count, transpose, value)

set_user_program (program)

Virtual Methods

None

Fields

None

Class Details

class Cogl.Pipeline
Bases:

Cogl.Object

Abstract:

No

classmethod new(context)
Parameters:

context (Cogl.Context) – a Cogl.Context

Returns:

a pointer to a new Cogl.Pipeline

Return type:

Cogl.Pipeline

Allocates and initializes a default simple pipeline that will color a primitive white.

New in version 2.0.

add_layer_snippet(layer, snippet)
Parameters:

Adds a shader snippet that will hook on to the given layer of the pipeline. The exact part of the pipeline that the snippet wraps around depends on the hook that is given to Cogl.Snippet.new(). Note that some hooks can’t be used with a layer and need to be added with Cogl.Pipeline.add_snippet() instead.

New in version 1.10.

add_snippet(snippet)
Parameters:

snippet (Cogl.Snippet) – The Cogl.Snippet to add to the vertex processing hook

Adds a shader snippet to self. The snippet will wrap around or replace some part of the pipeline as defined by the hook point in snippet. Note that some hook points are specific to a layer and must be added with Cogl.Pipeline.add_layer_snippet() instead.

New in version 1.10.

copy()
Returns:

a pointer to the newly allocated Cogl.Pipeline

Return type:

Cogl.Pipeline

Creates a new pipeline with the configuration copied from the source pipeline.

We would strongly advise developers to always aim to use Cogl.Pipeline.copy() instead of Cogl.Pipeline.new() whenever there will be any similarity between two pipelines. Copying a pipeline helps Cogl keep track of a pipelines ancestry which we may use to help minimize GPU state changes.

New in version 2.0.

foreach_layer(callback, *user_data)
Parameters:

Iterates all the layer indices of the given self.

New in version 2.0.

get_alpha_test_function()
Returns:

The alpha test function of self.

Return type:

Cogl.PipelineAlphaFunc

New in version 2.0.

get_alpha_test_reference()
Returns:

The alpha test reference value of self.

Return type:

float

New in version 2.0.

get_ambient(ambient)
Parameters:

ambient (Cogl.Color) – The location to store the ambient color

Retrieves the current ambient color for self

New in version 2.0.

get_color()
Returns:

The location to store the color

Return type:

color: Cogl.Color

Retrieves the current pipeline color.

New in version 2.0.

get_color_mask()
Returns:

A Cogl.ColorMask

Return type:

Cogl.ColorMask

Gets the current Cogl.ColorMask of which channels would be written to the current framebuffer. Each bit set in the mask means that the corresponding color would be written.

New in version 1.8.

get_cull_face_mode()
Returns:

the cull face mode that was previously set with Cogl.Pipeline.set_cull_face_mode().

Status: Unstable

Return type:

Cogl.PipelineCullFaceMode

New in version 2.0.

get_depth_state()
Returns:

A destination Cogl.DepthState struct

Return type:

state_out: Cogl.DepthState

Retrieves the current depth state configuration for the given self as previously set using Cogl.Pipeline.set_depth_state().

New in version 2.0.

get_diffuse(diffuse)
Parameters:

diffuse (Cogl.Color) – The location to store the diffuse color

Retrieves the current diffuse color for self

New in version 2.0.

get_emission(emission)
Parameters:

emission (Cogl.Color) – The location to store the emission color

Retrieves the pipelines current emission color.

New in version 2.0.

get_front_face_winding()
Returns:

The self front face winding

Status: Unstable

Return type:

Cogl.Winding

The order of the vertices within a primitive specifies whether it is considered to be front or back facing. This function specifies which order is considered to be the front faces. Cogl.Winding.COUNTER_CLOCKWISE sets the front faces to primitives with vertices in a counter-clockwise order and Cogl.Winding.CLOCKWISE sets them to be clockwise. The default is Cogl.Winding.COUNTER_CLOCKWISE.

New in version 2.0.

get_layer_mag_filter(layer_index)
Parameters:

layer_index (int) – the layer number to change.

Returns:

The magnification Cogl.PipelineFilter for the specified layer.

Return type:

Cogl.PipelineFilter

Retrieves the currently set magnification Cogl.PipelineFilter set on the specified layer. The magnification filter determines how the layer should be sampled when up-scaled.

The default filter is Cogl.PipelineFilter.LINEAR but this can be changed using Cogl.Pipeline.set_layer_filters().

New in version 1.10.

get_layer_min_filter(layer_index)
Parameters:

layer_index (int) – the layer number to change.

Returns:

The minification Cogl.PipelineFilter for the specified layer.

Return type:

Cogl.PipelineFilter

Retrieves the currently set minification Cogl.PipelineFilter set on the specified layer. The miniifcation filter determines how the layer should be sampled when down-scaled.

The default filter is Cogl.PipelineFilter.LINEAR but this can be changed using Cogl.Pipeline.set_layer_filters().

New in version 1.10.

get_layer_point_sprite_coords_enabled(layer_index)
Parameters:

layer_index (int) – the layer number to check.

Returns:

whether the texture coordinates will be replaced with point sprite coordinates.

Return type:

int

Gets whether point sprite coordinate generation is enabled for this texture layer.

New in version 2.0.

get_layer_texture(layer_index)
Parameters:

layer_index (int) – the index of the layer

Returns:

the texture that was set for the given layer of the pipeline or None if no texture was set.

Return type:

Cogl.Texture

New in version 1.10.

get_layer_wrap_mode_p(layer_index)
Parameters:

layer_index (int) – the layer number to change.

Returns:

the wrap mode for the ‘p’ coordinate of texture lookups on this layer.

Return type:

Cogl.PipelineWrapMode

Returns the wrap mode for the ‘p’ coordinate of texture lookups on this layer.

New in version 1.6.

get_layer_wrap_mode_s(layer_index)
Parameters:

layer_index (int) – the layer number to change.

Returns:

the wrap mode for the ‘s’ coordinate of texture lookups on this layer.

Return type:

Cogl.PipelineWrapMode

Returns the wrap mode for the ‘s’ coordinate of texture lookups on this layer.

New in version 1.6.

get_layer_wrap_mode_t(layer_index)
Parameters:

layer_index (int) – the layer number to change.

Returns:

the wrap mode for the ‘t’ coordinate of texture lookups on this layer.

Return type:

Cogl.PipelineWrapMode

Returns the wrap mode for the ‘t’ coordinate of texture lookups on this layer.

New in version 1.6.

get_n_layers()
Returns:

the number of layers

Return type:

int

Retrieves the number of layers defined for the given self

New in version 2.0.

get_per_vertex_point_size()
Returns:

True if the pipeline has per-vertex point size enabled or False otherwise. The per-vertex point size can be enabled with Cogl.Pipeline.set_per_vertex_point_size().

Return type:

int

New in version 2.0.

get_point_size()
Returns:

the point size of the self.

Return type:

float

Get the size of points drawn when Cogl.VerticesMode.POINTS is used with the vertex buffer API.

New in version 2.0.

get_shininess()
Returns:

The pipelines current shininess value

Return type:

float

Retrieves the pipelines current emission color.

New in version 2.0.

get_specular(specular)
Parameters:

specular (Cogl.Color) – The location to store the specular color

Retrieves the pipelines current specular color.

New in version 2.0.

get_uniform_location(uniform_name)
Parameters:

uniform_name (str) – The name of a uniform

Returns:

A integer representing the location of the given uniform.

Return type:

int

This is used to get an integer representing the uniform with the name uniform_name. The integer can be passed to functions such as Cogl.Pipeline.set_uniform_1f() to set the value of a uniform.

This function will always return a valid integer. Ie, unlike OpenGL, it does not return -1 if the uniform is not available in this pipeline so it can not be used to test whether uniforms are present. It is not necessary to set the program on the pipeline before calling this function.

New in version 2.0.

get_user_program()
Returns:

The current user program or %COGL_INVALID_HANDLE.

Return type:

object

Queries what user program has been associated with the given self using Cogl.Pipeline.set_user_program().

New in version 2.0.

remove_layer(layer_index)
Parameters:

layer_index (int) – Specifies the layer you want to remove

This function removes a layer from your pipeline

New in version 1.10.

set_alpha_test_function(alpha_func, alpha_reference)
Parameters:
  • alpha_func (Cogl.PipelineAlphaFunc) – A CoglPipelineAlphaFunc constant

  • alpha_reference (float) – A reference point that the chosen alpha function uses to compare incoming fragments to.

Before a primitive is blended with the framebuffer, it goes through an alpha test stage which lets you discard fragments based on the current alpha value. This function lets you change the function used to evaluate the alpha channel, and thus determine which fragments are discarded and which continue on to the blending stage.

The default is Cogl.PipelineAlphaFunc.ALWAYS

New in version 2.0.

set_ambient(ambient)
Parameters:

ambient (Cogl.Color) – The components of the desired ambient color

Sets the pipeline’s ambient color, in the standard OpenGL lighting model. The ambient color affects the overall color of the object.

Since the diffuse color will be intense when the light hits the surface directly, the ambient will be most apparent where the light hits at a slant.

The default value is (0.2, 0.2, 0.2, 1.0)

New in version 2.0.

set_ambient_and_diffuse(color)
Parameters:

color (Cogl.Color) – The components of the desired ambient and diffuse colors

Conveniently sets the diffuse and ambient color of self at the same time. See Cogl.Pipeline.set_ambient() and Cogl.Pipeline.set_diffuse().

The default ambient color is (0.2, 0.2, 0.2, 1.0)

The default diffuse color is (0.8, 0.8, 0.8, 1.0)

New in version 2.0.

set_blend(blend_string)
Parameters:

blend_string (str) – A ‘Cogl blend string [cogl-Blend-Strings]’ describing the desired blend function.

Raises:

GLib.Error

Returns:

True if the blend string was successfully parsed, and the described blending is supported by the underlying driver/hardware. If there was an error, False is returned and error is set accordingly (if present).

Return type:

int

If not already familiar; please refer ‘here [cogl-Blend-Strings]’ for an overview of what blend strings are, and their syntax.

Blending occurs after the alpha test function, and combines fragments with the framebuffer.

Currently the only blend function Cogl exposes is ADD(). So any valid blend statements will be of the form:

<channel-mask>=ADD(SRC_COLOR*(<factor>), DST_COLOR*(<factor>))

This is the list of source-names usable as blend factors:

The source names can be used according to the

‘color-source and factor syntax [cogl-Blend-String-syntax]’, so for example “(1-SRC_COLOR[A])” would be a valid factor, as would “(CONSTANT[RGB])”

These can also be used as factors:

  • 0: (0, 0, 0, 0)

  • 1: (1, 1, 1, 1)

  • SRC_ALPHA_SATURATE_FACTOR: (f,f,f,1) where f = MIN(SRC_COLOR[A],1-DST_COLOR[A])

Remember; all color components are normalized to the range [0, 1] before computing the result of blending.

Blend Strings/1

Blend a non-premultiplied source over a destination with premultiplied alpha:

"RGB = ADD(SRC_COLOR*(SRC_COLOR[A]), DST_COLOR*(1-SRC_COLOR[A]))"
"A   = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"
Blend Strings/2

Blend a premultiplied source over a destination with premultiplied alpha

"RGBA = ADD(SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))"

The default blend string is:

RGBA = ADD (SRC_COLOR, DST_COLOR*(1-SRC_COLOR[A]))

That gives normal alpha-blending when the calculated color for the pipeline is in premultiplied form.

New in version 2.0.

set_blend_constant(constant_color)
Parameters:

constant_color (Cogl.Color) – The constant color you want

When blending is setup to reference a CONSTANT blend factor then blending will depend on the constant set with this function.

New in version 2.0.

set_color(color)
Parameters:

color (Cogl.Color) – The components of the color

Sets the basic color of the pipeline, used when no lighting is enabled.

Note that if you don’t add any layers to the pipeline then the color will be blended unmodified with the destination; the default blend expects premultiplied colors: for example, use (0.5, 0.0, 0.0, 0.5) for semi-transparent red. See Cogl.Color.premultiply().

The default value is (1.0, 1.0, 1.0, 1.0)

New in version 2.0.

set_color4f(red, green, blue, alpha)
Parameters:
  • red (float) – The red component

  • green (float) – The green component

  • blue (float) – The blue component

  • alpha (float) – The alpha component

Sets the basic color of the pipeline, used when no lighting is enabled.

The default value is (1.0, 1.0, 1.0, 1.0)

New in version 2.0.

set_color4ub(red, green, blue, alpha)
Parameters:
  • red (int) – The red component

  • green (int) – The green component

  • blue (int) – The blue component

  • alpha (int) – The alpha component

Sets the basic color of the pipeline, used when no lighting is enabled.

The default value is (0xff, 0xff, 0xff, 0xff)

New in version 2.0.

set_color_mask(color_mask)
Parameters:

color_mask (Cogl.ColorMask) – A Cogl.ColorMask of which color channels to write to the current framebuffer.

Defines a bit mask of which color channels should be written to the current framebuffer. If a bit is set in color_mask that means that color will be written.

New in version 1.8.

set_cull_face_mode(cull_face_mode)
Parameters:

cull_face_mode (Cogl.PipelineCullFaceMode) – The new mode to set

Sets which faces will be culled when drawing. Face culling can be used to increase efficiency by avoiding drawing faces that would get overridden. For example, if a model has gaps so that it is impossible to see the inside then faces which are facing away from the screen will never be seen so there is no point in drawing them. This can be acheived by setting the cull face mode to Cogl.PipelineCullFaceMode.BACK.

Face culling relies on the primitives being drawn with a specific order to represent which faces are facing inside and outside the model. This order can be specified by calling Cogl.Pipeline.set_front_face_winding().

Status: Unstable

New in version 2.0.

set_depth_state(state)
Parameters:

state (Cogl.DepthState) – A Cogl.DepthState struct

Raises:

GLib.Error

Returns:

True if the GPU supports all the given state else False and returns an error.

Return type:

int

This commits all the depth state configured in state struct to the given self. The configuration values are copied into the pipeline so there is no requirement to keep the Cogl.DepthState struct around if you don’t need it any more.

Note: Since some platforms do not support the depth range feature it is possible for this function to fail and report an error.

New in version 2.0.

set_diffuse(diffuse)
Parameters:

diffuse (Cogl.Color) – The components of the desired diffuse color

Sets the pipeline’s diffuse color, in the standard OpenGL lighting model. The diffuse color is most intense where the light hits the surface directly - perpendicular to the surface.

The default value is (0.8, 0.8, 0.8, 1.0)

New in version 2.0.

set_emission(emission)
Parameters:

emission (Cogl.Color) – The components of the desired emissive color

Sets the pipeline’s emissive color, in the standard OpenGL lighting model. It will look like the surface is a light source emitting this color.

The default value is (0.0, 0.0, 0.0, 1.0)

New in version 2.0.

set_front_face_winding(front_winding)
Parameters:

front_winding (Cogl.Winding) – the winding order

The order of the vertices within a primitive specifies whether it is considered to be front or back facing. This function specifies which order is considered to be the front faces. Cogl.Winding.COUNTER_CLOCKWISE sets the front faces to primitives with vertices in a counter-clockwise order and Cogl.Winding.CLOCKWISE sets them to be clockwise. The default is Cogl.Winding.COUNTER_CLOCKWISE.

Status: Unstable

New in version 2.0.

set_layer_combine(layer_index, blend_string)
Parameters:
  • layer_index (int) – Specifies the layer you want define a combine function for

  • blend_string (str) – A ‘Cogl blend string [cogl-Blend-Strings]’ describing the desired texture combine function.

Raises:

GLib.Error

Returns:

True if the blend string was successfully parsed, and the described texture combining is supported by the underlying driver and or hardware. On failure, False is returned and error is set

Return type:

int

If not already familiar; you can refer

‘here [cogl-Blend-Strings]’ for an overview of what blend strings are and there syntax.

These are all the functions available for texture combining:

  • REPLACE(arg0) = arg0

  • MODULATE(arg0, arg1) = arg0 x arg1

  • ADD(arg0, arg1) = arg0 + arg1

  • ADD_SIGNED(arg0, arg1) = arg0 + arg1 - 0.5

  • INTERPOLATE(arg0, arg1, arg2) = arg0 x arg2 + arg1 x (1 - arg2)

  • SUBTRACT(arg0, arg1) = arg0 - arg1

  • DOT3_RGB(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) +
    (arg0[G] - 0.5)) * (arg1[G] - 0.5) +
    (arg0[B] - 0.5)) * (arg1[B] - 0.5))
    
  • DOT3_RGBA(arg0, arg1) = 4 x ((arg0[R] - 0.5)) * (arg1[R] - 0.5) +
    (arg0[G] - 0.5)) * (arg1[G] - 0.5) +
    (arg0[B] - 0.5)) * (arg1[B] - 0.5))
    

Refer to the

‘color-source syntax [cogl-Blend-String-syntax]’ for describing the arguments. The valid source names for texture combining are:

TEXTURE

Use the color from the current texture layer

TEXTURE_0, TEXTURE_1, etc

Use the color from the specified texture layer

CONSTANT

Use the color from the constant given with Cogl.Pipeline.set_layer_combine_constant()

PRIMARY

Use the color of the pipeline as set with Cogl.Pipeline.set_color()

PREVIOUS

Either use the texture color from the previous layer, or if this is layer 0, use the color of the pipeline as set with Cogl.Pipeline.set_color()

Layer Combine Examples

This is effectively what the default blending is:

RGBA = MODULATE (PREVIOUS, TEXTURE) This could be used to cross-fade between two images, using the alpha component of a constant as the interpolator. The constant color is given by calling Cogl.Pipeline.set_layer_combine_constant().

RGBA = INTERPOLATE (PREVIOUS, TEXTURE, CONSTANT[A])

You can’t give a multiplication factor for arguments as you can with blending.

New in version 2.0.

set_layer_combine_constant(layer_index, constant)
Parameters:
  • layer_index (int) – Specifies the layer you want to specify a constant used for texture combining

  • constant (Cogl.Color) – The constant color you want

When you are using the ‘CONSTANT’ color source in a layer combine description then you can use this function to define its value.

New in version 2.0.

set_layer_filters(layer_index, min_filter, mag_filter)
Parameters:
  • layer_index (int) – the layer number to change.

  • min_filter (Cogl.PipelineFilter) – the filter used when scaling a texture down.

  • mag_filter (Cogl.PipelineFilter) – the filter used when magnifying a texture.

Changes the decimation and interpolation filters used when a texture is drawn at other scales than 100%.

It is an error to pass anything other than Cogl.PipelineFilter.NEAREST or Cogl.PipelineFilter.LINEAR as magnification filters since magnification doesn’t ever need to reference values stored in the mipmap chain.

New in version 1.10.

set_layer_matrix(layer_index, matrix)
Parameters:
  • layer_index (int) – the index for the layer inside self

  • matrix (Cogl.Matrix) – the transformation matrix for the layer

This function lets you set a matrix that can be used to e.g. translate and rotate a single layer of a pipeline used to fill your geometry.

New in version 1.10.

set_layer_null_texture(layer_index, texture_type)
Parameters:
  • layer_index (int) – The layer number to modify

  • texture_type (Cogl.TextureType) – The type of the default texture to use

Sets the texture for this layer to be the default texture for the given type. This is equivalent to calling Cogl.Pipeline.set_layer_texture() with None for the texture argument except that you can also specify the type of default texture to use. The default texture is a 1x1 pixel white texture.

This function is mostly useful if you want to create a base pipeline that you want to create multiple copies from using Cogl.Pipeline.copy(). In that case this function can be used to specify the texture type so that any pipeline copies can share the internal texture type state for efficiency.

New in version 1.10.

set_layer_point_sprite_coords_enabled(layer_index, enable)
Parameters:
  • layer_index (int) – the layer number to change.

  • enable (int) – whether to enable point sprite coord generation.

Raises:

GLib.Error

Returns:

True if the function succeeds, False otherwise.

Return type:

int

When rendering points, if enable is True then the texture coordinates for this layer will be replaced with coordinates that vary from 0.0 to 1.0 across the primitive. The top left of the point will have the coordinates 0.0,0.0 and the bottom right will have 1.0,1.0. If enable is False then the coordinates will be fixed for the entire point.

This function will only work if Cogl.FeatureID.OGL_FEATURE_ID_POINT_SPRITE is available. If the feature is not available then the function will return False and set error.

New in version 2.0.

set_layer_texture(layer_index, texture)
Parameters:
set_layer_wrap_mode(layer_index, mode)
Parameters:

Sets the wrap mode for all three coordinates of texture lookups on this layer. This is equivalent to calling Cogl.Pipeline.set_layer_wrap_mode_s(), Cogl.Pipeline.set_layer_wrap_mode_t() and Cogl.Pipeline.set_layer_wrap_mode_p() separately.

New in version 2.0.

set_layer_wrap_mode_p(layer_index, mode)
Parameters:

Sets the wrap mode for the ‘p’ coordinate of texture lookups on this layer. ‘p’ is the third coordinate.

New in version 2.0.

set_layer_wrap_mode_s(layer_index, mode)
Parameters:

Sets the wrap mode for the ‘s’ coordinate of texture lookups on this layer.

New in version 2.0.

set_layer_wrap_mode_t(layer_index, mode)
Parameters:

Sets the wrap mode for the ‘t’ coordinate of texture lookups on this layer.

New in version 2.0.

set_per_vertex_point_size(enable)
Parameters:

enable (int) – whether to enable per-vertex point size

Raises:

GLib.Error

Returns:

True if the change suceeded or False otherwise

Return type:

int

Sets whether to use a per-vertex point size or to use the value set by Cogl.Pipeline.set_point_size(). If per-vertex point size is enabled then the point size can be set for an individual point either by drawing with a Cogl.Attribute with the name ‘cogl_point_size_in’ or by writing to the GLSL builtin ‘cogl_point_size_out’ from a vertex shader snippet.

If per-vertex point size is enabled and this attribute is not used and cogl_point_size_out is not written to then the results are undefined.

Note that enabling this will only work if the Cogl.FeatureID.OGL_FEATURE_ID_PER_VERTEX_POINT_SIZE feature is available. If this is not available then the function will return False and set a #CoglError.

New in version 2.0.

set_point_size(point_size)
Parameters:

point_size (float) – the new point size.

Changes the size of points drawn when Cogl.VerticesMode.POINTS is used with the attribute buffer API. Note that typically the GPU will only support a limited minimum and maximum range of point sizes. If the chosen point size is outside that range then the nearest value within that range will be used instead. The size of a point is in screen space so it will be the same regardless of any transformations.

If the point size is set to 0.0 then drawing points with the pipeline will have undefined results. This is the default value so if an application wants to draw points it must make sure to use a pipeline that has an explicit point size set on it.

New in version 2.0.

set_shininess(shininess)
Parameters:

shininess (float) – The desired shininess; must be >= 0.0

Sets the shininess of the pipeline, in the standard OpenGL lighting model, which determines the size of the specular highlights. A higher shininess will produce smaller highlights which makes the object appear more shiny.

The default value is 0.0

New in version 2.0.

set_specular(specular)
Parameters:

specular (Cogl.Color) – The components of the desired specular color

Sets the pipeline’s specular color, in the standard OpenGL lighting model. The intensity of the specular color depends on the viewport position, and is brightest along the lines of reflection.

The default value is (0.0, 0.0, 0.0, 1.0)

New in version 2.0.

set_uniform_1f(uniform_location, value)
Parameters:
  • uniform_location (int) – The uniform’s location identifier

  • value (float) – The new value for the uniform

Sets a new value for the uniform at uniform_location. If this pipeline has a user program attached and is later used as a source for drawing, the given value will be assigned to the uniform which can be accessed from the shader’s source. The value for uniform_location should be retrieved from the string name of the uniform by calling Cogl.Pipeline.get_uniform_location().

This function should be used to set uniforms that are of type float. It can also be used to set a single member of a float array uniform.

New in version 2.0.

set_uniform_1i(uniform_location, value)
Parameters:
  • uniform_location (int) – The uniform’s location identifier

  • value (int) – The new value for the uniform

Sets a new value for the uniform at uniform_location. If this pipeline has a user program attached and is later used as a source for drawing, the given value will be assigned to the uniform which can be accessed from the shader’s source. The value for uniform_location should be retrieved from the string name of the uniform by calling Cogl.Pipeline.get_uniform_location().

This function should be used to set uniforms that are of type int. It can also be used to set a single member of a int array uniform or a sampler uniform.

New in version 2.0.

set_uniform_float(uniform_location, n_components, count, value)
Parameters:
  • uniform_location (int) – The uniform’s location identifier

  • n_components (int) – The number of components in the corresponding uniform’s type

  • count (int) – The number of values to set

  • value (float) – Pointer to the new values to set

Sets new values for the uniform at uniform_location. If this pipeline has a user program attached and is later used as a source for drawing, the given values will be assigned to the uniform which can be accessed from the shader’s source. The value for uniform_location should be retrieved from the string name of the uniform by calling Cogl.Pipeline.get_uniform_location().

This function can be used to set any floating point type uniform, including float arrays and float vectors. For example, to set a single vec4 uniform you would use 4 for n_components and 1 for count. To set an array of 8 float values, you could use 1 for n_components and 8 for count.

New in version 2.0.

set_uniform_int(uniform_location, n_components, count, value)
Parameters:
  • uniform_location (int) – The uniform’s location identifier

  • n_components (int) – The number of components in the corresponding uniform’s type

  • count (int) – The number of values to set

  • value (int) – Pointer to the new values to set

Sets new values for the uniform at uniform_location. If this pipeline has a user program attached and is later used as a source for drawing, the given values will be assigned to the uniform which can be accessed from the shader’s source. The value for uniform_location should be retrieved from the string name of the uniform by calling Cogl.Pipeline.get_uniform_location().

This function can be used to set any integer type uniform, including int arrays and int vectors. For example, to set a single ivec4 uniform you would use 4 for n_components and 1 for count. To set an array of 8 int values, you could use 1 for n_components and 8 for count.

New in version 2.0.

set_uniform_matrix(uniform_location, dimensions, count, transpose, value)
Parameters:
  • uniform_location (int) – The uniform’s location identifier

  • dimensions (int) – The size of the matrix

  • count (int) – The number of values to set

  • transpose (int) – Whether to transpose the matrix

  • value (float) – Pointer to the new values to set

Sets new values for the uniform at uniform_location. If this pipeline has a user program attached and is later used as a source for drawing, the given values will be assigned to the uniform which can be accessed from the shader’s source. The value for uniform_location should be retrieved from the string name of the uniform by calling Cogl.Pipeline.get_uniform_location().

This function can be used to set any matrix type uniform, including matrix arrays. For example, to set a single mat4 uniform you would use 4 for dimensions and 1 for count. To set an array of 8 mat3 values, you could use 3 for dimensions and 8 for count.

If transpose is False then the matrix is expected to be in column-major order or if it is True then the matrix is in row-major order. You can pass a Cogl.Matrix by calling by passing the result of Cogl.Matrix.get_array() in value and setting transpose to False.

New in version 2.0.

set_user_program(program)
Parameters:

program (object) – A #CoglHandle to a linked CoglProgram

Associates a linked CoglProgram with the given pipeline so that the program can take full control of vertex and/or fragment processing.

This is an example of how it can be used to associate an ARBfp program with a Cogl.Pipeline:

CoglHandle shader;
CoglHandle program;
CoglPipeline *pipeline;

shader = cogl_create_shader (COGL_SHADER_TYPE_FRAGMENT);
cogl_shader_source (shader,
                    "!!ARBfp1.0\n"
                    "MOV result.color,fragment.color;\n"
                    "END\n");
cogl_shader_compile (shader);

program = cogl_create_program ();
cogl_program_attach_shader (program, shader);
cogl_program_link (program);

pipeline = cogl_pipeline_new ();
cogl_pipeline_set_user_program (pipeline, program);

cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff);
cogl_rectangle (0, 0, 100, 100);

It is possibly worth keeping in mind that this API is not part of the long term design for how we want to expose shaders to Cogl developers (We are planning on deprecating the cogl_program and cogl_shader APIs in favour of a “snippet” framework) but in the meantime we hope this will handle most practical GLSL and ARBfp requirements.

Also remember you need to check for either the Cogl.FeatureFlags.SHADERS_GLSL or Cogl.FeatureFlags.SHADERS_ARBFP before using the cogl_program or cogl_shader API.

New in version 2.0.