## Pipeline Pipeline — Functions for creating and manipulating the GPU pipeline |

## Functions

CoglPipeline * | cogl_pipeline_new ()
CoglPipeline * | cogl_pipeline_copy ()
CoglBool | cogl_is_pipeline ()
void | cogl_pipeline_set_color ()
void | cogl_pipeline_set_color4ub ()
void | cogl_pipeline_set_color4f ()
void | cogl_pipeline_get_color ()
void | cogl_pipeline_set_ambient ()
void | cogl_pipeline_get_ambient ()
void | cogl_pipeline_set_diffuse ()
void | cogl_pipeline_get_diffuse ()
void | cogl_pipeline_set_ambient_and_diffuse ()
void | cogl_pipeline_set_emission ()
void | cogl_pipeline_get_emission ()
void | cogl_pipeline_set_specular ()
void | cogl_pipeline_get_specular ()
void | cogl_pipeline_set_shininess ()
float | cogl_pipeline_get_shininess ()
void | cogl_pipeline_set_alpha_test_function ()
CoglBool | cogl_pipeline_set_blend ()
void | cogl_pipeline_set_blend_constant ()
void | cogl_pipeline_set_point_size ()
float | cogl_pipeline_get_point_size ()
CoglBool | cogl_pipeline_set_per_vertex_point_size ()
CoglBool | cogl_pipeline_get_per_vertex_point_size ()
CoglColorMask | cogl_pipeline_get_color_mask ()
void | cogl_pipeline_set_color_mask ()
CoglBool | cogl_pipeline_set_depth_state ()
void | cogl_pipeline_get_depth_state ()
void | cogl_pipeline_set_cull_face_mode ()
void | cogl_pipeline_set_front_face_winding ()
void | cogl_pipeline_set_layer_texture ()
void | cogl_pipeline_set_layer_null_texture ()
CoglTexture * | cogl_pipeline_get_layer_texture ()
void | cogl_pipeline_set_layer_filters ()
CoglPipelineFilter | cogl_pipeline_get_layer_min_filter ()
CoglPipelineFilter | cogl_pipeline_get_layer_mag_filter ()
void | cogl_pipeline_set_layer_wrap_mode ()
void | cogl_pipeline_set_layer_wrap_mode_s ()
void | cogl_pipeline_set_layer_wrap_mode_t ()
void | cogl_pipeline_set_layer_wrap_mode_p ()
CoglBool | cogl_pipeline_set_layer_combine ()
void | cogl_pipeline_set_layer_combine_constant ()
void | cogl_pipeline_set_layer_matrix ()
CoglBool | cogl_pipeline_set_layer_point_sprite_coords_enabled ()
CoglBool | cogl_pipeline_get_layer_point_sprite_coords_enabled ()
void | cogl_pipeline_remove_layer ()
int | cogl_pipeline_get_n_layers ()
CoglBool | (*CoglPipelineLayerCallback) ()
void | cogl_pipeline_foreach_layer ()
int | cogl_pipeline_get_uniform_location ()
void | cogl_pipeline_set_uniform_1f ()
void | cogl_pipeline_set_uniform_1i ()
void | cogl_pipeline_set_uniform_float ()
void | cogl_pipeline_set_uniform_int ()
void | cogl_pipeline_set_uniform_matrix ()
void | cogl_pipeline_add_snippet ()
void | cogl_pipeline_add_layer_snippet ()

## Types and Values

| CoglPipeline
enum | CoglPipelineAlphaFunc
#define | COGL_BLEND_STRING_ERROR
enum | CoglBlendStringError
enum | CoglPipelineCullFaceMode
enum | CoglWinding
enum | CoglPipelineFilter
enum | CoglPipelineWrapMode

## Description

Cogl allows creating and manipulating objects representing the full configuration of the GPU pipeline. In simplified terms the GPU pipeline takes primitive geometry as the input, it first performs vertex processing, allowing you to deform your geometry, then rasterizes that (turning it from pure geometry into fragments) then performs fragment processing including depth testing and texture mapping. Finally it blends the result with the framebuffer.

## Functions

### cogl_pipeline_new ()

    CoglPipeline *
    cogl_pipeline_new (CoglContext *context);

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

#### Parameters

context | a CoglContext |

#### Returns

a pointer to a new CoglPipeline.

[transfer full]

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_copy ()

    CoglPipeline *
    cogl_pipeline_copy (CoglPipeline *source);

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.

#### Parameters

source | a CoglPipeline object to copy |

#### Returns

a pointer to the newly allocated CoglPipeline.

[transfer full]

Since: 2.0

Stability Level: Unstable

### cogl_is_pipeline ()

    CoglBool
    cogl_is_pipeline (void *object);

Gets whether the given `object` references an existing pipeline object.

#### Parameters

object | A CoglObject |

#### Returns

`TRUE` if the `object` references a CoglPipeline, `FALSE` otherwise

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_color ()

    void
    cogl_pipeline_set_color (CoglPipeline *pipeline,
                             const CoglColor *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)

#### Parameters

pipeline | A CoglPipeline object |
color | The components of the color |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_color4ub ()

    void
    cogl_pipeline_set_color4ub (CoglPipeline *pipeline,
                                uint8_t red,
                                uint8_t green,
                                uint8_t blue,
                                uint8_t alpha);

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

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

#### Parameters

pipeline | A CoglPipeline object |
red | The red component |
green | The green component |
blue | The blue component |
alpha | The alpha component |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_color4f ()

    void
    cogl_pipeline_set_color4f (CoglPipeline *pipeline,
                               float red,
                               float green,
                               float blue,
                               float alpha);

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)

#### Parameters

pipeline | A CoglPipeline object |
red | The red component |
green | The green component |
blue | The blue component |
alpha | The alpha component |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_color ()

    void
    cogl_pipeline_get_color (CoglPipeline *pipeline,
                             CoglColor *color);

Retrieves the current pipeline color.

#### Parameters

pipeline | A CoglPipeline object |
color | The location to store the color. | [out]

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_ambient ()

    void
    cogl_pipeline_set_ambient (CoglPipeline *pipeline,
                               const CoglColor *ambient);

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)

#### Parameters

pipeline | A CoglPipeline object |
ambient | The components of the desired ambient color |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_ambient ()

    void
    cogl_pipeline_get_ambient (CoglPipeline *pipeline,
                               CoglColor *ambient);

Retrieves the current ambient color for `pipeline`

#### Parameters

pipeline | A CoglPipeline object |
ambient | The location to store the ambient color |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_diffuse ()

    void
    cogl_pipeline_set_diffuse (CoglPipeline *pipeline,
                               const CoglColor *diffuse);

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)

#### Parameters

pipeline | A CoglPipeline object |
diffuse | The components of the desired diffuse color |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_diffuse ()

    void
    cogl_pipeline_get_diffuse (CoglPipeline *pipeline,
                               CoglColor *diffuse);

Retrieves the current diffuse color for `pipeline`

#### Parameters

pipeline | A CoglPipeline object |
diffuse | The location to store the diffuse color |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_ambient_and_diffuse ()

    void
    cogl_pipeline_set_ambient_and_diffuse (CoglPipeline *pipeline,
                                           const CoglColor *color);

Conveniently sets the diffuse and ambient color of `pipeline` 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)

#### Parameters

pipeline | A CoglPipeline object |
color | The components of the desired ambient and diffuse colors |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_emission ()

    void
    cogl_pipeline_set_emission (CoglPipeline *pipeline,
                                const CoglColor *emission);

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)

#### Parameters

pipeline | A CoglPipeline object |
emission | The components of the desired emissive color |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_emission ()

    void
    cogl_pipeline_get_emission (CoglPipeline *pipeline,
                                CoglColor *emission);

Retrieves the pipelines current emission color.

#### Parameters

pipeline | A CoglPipeline object |
emission | The location to store the emission color |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_specular ()

    void
    cogl_pipeline_set_specular (CoglPipeline *pipeline,
                                const CoglColor *specular);

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)

#### Parameters

pipeline | A CoglPipeline object |
specular | The components of the desired specular color |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_specular ()

    void
    cogl_pipeline_get_specular (CoglPipeline *pipeline,
                                CoglColor *specular);

Retrieves the pipelines current specular color.

#### Parameters

pipeline | A CoglPipeline object |
specular | The location to store the specular color |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_shininess ()

    void
    cogl_pipeline_set_shininess (CoglPipeline *pipeline,
                                 float shininess);

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

#### Parameters

pipeline | A CoglPipeline object |
shininess | The desired shininess; must be >= 0.0 |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_shininess ()

    float
    cogl_pipeline_get_shininess (CoglPipeline *pipeline);

Retrieves the pipelines current emission color.

#### Parameters

pipeline | A CoglPipeline object |

#### Returns

The pipelines current shininess value

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_alpha_test_function ()

    void
    cogl_pipeline_set_alpha_test_function (CoglPipeline *pipeline,
                                           CoglPipelineAlphaFunc alpha_func,
                                           float alpha_reference);

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_PIPELINE_ALPHA_FUNC_ALWAYS`

#### Parameters

pipeline | A CoglPipeline object |
alpha_func | A `CoglPipelineAlphaFunc` constant |
alpha_reference | A reference point that the chosen alpha function uses to compare incoming fragments to. |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_blend ()

    CoglBool
    cogl_pipeline_set_blend (CoglPipeline *pipeline,
                             const char *blend_string,
                             CoglError **error);

If not already familiar; please refer here 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:

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

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

- SRC_COLOR: The color of the in comming fragment

- DST_COLOR: The color of the framebuffer

- CONSTANT: The constant set via `cogl_pipeline_set_blend_constant()`

The source names can be used according to the

color-source and factor 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.

Example 1. 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]))"

Example 2. 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:

    1
    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.

#### Parameters

pipeline | A CoglPipeline object |
blend_string | A Cogl blend string describing the desired blend function. |
error | return location for a CoglError that may report lack of driver support if you give separate blend string statements for the alpha channel and RGB channels since some drivers, or backends such as GLES 1.1, don't support this feature. May be `NULL`, in which case a warning will be printed out using GLib's logging facilities if an error is encountered. |

#### 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).

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_blend_constant ()

    void
    cogl_pipeline_set_blend_constant (CoglPipeline *pipeline,
                                      const CoglColor *constant_color);

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

#### Parameters

pipeline | A CoglPipeline object |
constant_color | The constant color you want |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_point_size ()

    void
    cogl_pipeline_set_point_size (CoglPipeline *pipeline,
                                  float point_size);

Changes the size of points drawn when `COGL_VERTICES_MODE_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.

#### Parameters

pipeline | a CoglPipeline pointer |
point_size | the new point size. |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_point_size ()

    float
    cogl_pipeline_get_point_size (CoglPipeline *pipeline);

Get the size of points drawn when `COGL_VERTICES_MODE_POINTS` is used with the vertex buffer API.

#### Parameters

pipeline | a CoglPipeline pointer |

#### Returns

the point size of the `pipeline` .

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_per_vertex_point_size ()

    CoglBool
    cogl_pipeline_set_per_vertex_point_size
                                   (CoglPipeline *pipeline,
                                    CoglBool enable,
                                    CoglError **error);

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 CoglAttribute 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_FEATURE_ID_PER_VERTEX_POINT_SIZE` feature is available. If this is not available then the function will return `FALSE` and set a CoglError.

#### Parameters

pipeline | a CoglPipeline pointer |
enable | whether to enable per-vertex point size |
error | a location to store a CoglError if the change failed |

#### Returns

`TRUE` if the change suceeded or `FALSE` otherwise

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_per_vertex_point_size ()

    CoglBool
    cogl_pipeline_get_per_vertex_point_size
                                   (CoglPipeline *pipeline);

#### Parameters

pipeline | a CoglPipeline pointer |

#### 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()`.

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_color_mask ()

    CoglColorMask
    cogl_pipeline_get_color_mask (CoglPipeline *pipeline);

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

#### Parameters

pipeline | a CoglPipeline object. |

#### Returns

A CoglColorMask

Since: 1.8

Stability Level: Unstable

### cogl_pipeline_set_color_mask ()

    void
    cogl_pipeline_set_color_mask (CoglPipeline *pipeline,
                                  CoglColorMask color_mask);

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.

#### Parameters

pipeline | a CoglPipeline object. |
color_mask | A CoglColorMask of which color channels to write to the current framebuffer. |

Since: 1.8

Stability Level: Unstable

### cogl_pipeline_set_depth_state ()

    CoglBool
    cogl_pipeline_set_depth_state (CoglPipeline *pipeline,
                                   const CoglDepthState *state,
                                   CoglError **error);

This commits all the depth state configured in `state` struct to the given `pipeline` . The configuration values are copied into the pipeline so there is no requirement to keep the CoglDepthState 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` .

#### Parameters

pipeline | A CoglPipeline object |
state | A CoglDepthState struct |
error | A CoglError to report failures to setup the given `state` . |

#### Returns

TRUE if the GPU supports all the given `state` else `FALSE` and returns an `error` .

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_depth_state ()

    void
    cogl_pipeline_get_depth_state (CoglPipeline *pipeline,
                                   CoglDepthState *state_out);

Retrieves the current depth state configuration for the given `pipeline` as previously set using `cogl_pipeline_set_depth_state()`.

#### Parameters

pipeline | A CoglPipeline object |
state_out | A destination CoglDepthState struct. | [out]

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_cull_face_mode ()

    void
    cogl_pipeline_set_cull_face_mode (CoglPipeline *pipeline,
                                      CoglPipelineCullFaceMode cull_face_mode);

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_PIPELINE_CULL_FACE_MODE_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

#### Parameters

pipeline | A CoglPipeline |
cull_face_mode | The new mode to set |

Since: 2.0

### cogl_pipeline_set_front_face_winding ()

    void
    cogl_pipeline_set_front_face_winding (CoglPipeline *pipeline,
                                          CoglWinding front_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`.

Status: Unstable

#### Parameters

pipeline | a CoglPipeline |
front_winding | the winding order |

Since: 2.0

### cogl_pipeline_set_layer_texture ()

    void
    cogl_pipeline_set_layer_texture (CoglPipeline *pipeline,
                                     int layer_index,
                                     CoglTexture *texture);

### cogl_pipeline_set_layer_null_texture ()

    void
    cogl_pipeline_set_layer_null_texture (CoglPipeline *pipeline,
                                          int layer_index,
                                          CoglTextureType texture_type);

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 `NULL` 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.

#### Parameters

pipeline | A CoglPipeline |
layer_index | The layer number to modify |
texture_type | The type of the default texture to use |

Since: 1.10

Stability Level: Unstable

### cogl_pipeline_get_layer_texture ()

    CoglTexture *
    cogl_pipeline_get_layer_texture (CoglPipeline *pipeline,
                                     int layer_index);

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the index of the layer |

#### Returns

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

[transfer none]

Since: 1.10

Stability Level: Unstable

### cogl_pipeline_set_layer_filters ()

    void
    cogl_pipeline_set_layer_filters (CoglPipeline *pipeline,
                                     int layer_index,
                                     CoglPipelineFilter min_filter,
                                     CoglPipelineFilter mag_filter);

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_PIPELINE_FILTER_NEAREST` or `COGL_PIPELINE_FILTER_LINEAR` as magnification filters since magnification doesn't ever need to reference values stored in the mipmap chain.

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the layer number to change. |
min_filter | the filter used when scaling a texture down. |
mag_filter | the filter used when magnifying a texture. |

Since: 1.10

Stability Level: Unstable

### cogl_pipeline_get_layer_min_filter ()

    CoglPipelineFilter
    cogl_pipeline_get_layer_min_filter (CoglPipeline *pipeline,
                                        int layer_index);

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

The default filter is `COGL_PIPELINE_FILTER_LINEAR` but this can be changed using `cogl_pipeline_set_layer_filters()`.

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the layer number to change. |

#### Returns

The minification CoglPipelineFilter for the specified layer.

Since: 1.10

Stability Level: Unstable

### cogl_pipeline_get_layer_mag_filter ()

    CoglPipelineFilter
    cogl_pipeline_get_layer_mag_filter (CoglPipeline *pipeline,
                                        int layer_index);

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

The default filter is `COGL_PIPELINE_FILTER_LINEAR` but this can be changed using `cogl_pipeline_set_layer_filters()`.

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the layer number to change. |

#### Returns

The magnification CoglPipelineFilter for the specified layer.

Since: 1.10

Stability Level: Unstable

### cogl_pipeline_set_layer_wrap_mode ()

    void
    cogl_pipeline_set_layer_wrap_mode (CoglPipeline *pipeline,
                                       int layer_index,
                                       CoglPipelineWrapMode mode);

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.

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the layer number to change. |
mode | the new wrap mode |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_layer_wrap_mode_s ()

    void
    cogl_pipeline_set_layer_wrap_mode_s (CoglPipeline *pipeline,
                                         int layer_index,
                                         CoglPipelineWrapMode mode);

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

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the layer number to change. |
mode | the new wrap mode |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_layer_wrap_mode_t ()

    void
    cogl_pipeline_set_layer_wrap_mode_t (CoglPipeline *pipeline,
                                         int layer_index,
                                         CoglPipelineWrapMode mode);

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

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the layer number to change. |
mode | the new wrap mode |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_layer_wrap_mode_p ()

    void
    cogl_pipeline_set_layer_wrap_mode_p (CoglPipeline *pipeline,
                                         int layer_index,
                                         CoglPipelineWrapMode mode);

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

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the layer number to change. |
mode | the new wrap mode |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_layer_combine ()

    CoglBool
    cogl_pipeline_set_layer_combine (CoglPipeline *pipeline,
                                     int layer_index,
                                     const char *blend_string,
                                     CoglError **error);

If not already familiar; you can refer

here 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 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:

    1
    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()`.

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

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

#### Parameters

pipeline | A CoglPipeline object |
layer_index | Specifies the layer you want define a combine function for |
blend_string | A Cogl blend string describing the desired texture combine function. |
error | A CoglError that may report parse errors or lack of GPU/driver support. May be `NULL`, in which case a warning will be printed out if an error is encountered. |

#### 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

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_layer_combine_constant ()

    void
    cogl_pipeline_set_layer_combine_constant
                                   (CoglPipeline *pipeline,
                                    int layer_index,
                                    const CoglColor *constant);

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

#### Parameters

pipeline | A CoglPipeline object |
layer_index | Specifies the layer you want to specify a constant used for texture combining |
constant | The constant color you want |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_layer_matrix ()

    void
    cogl_pipeline_set_layer_matrix (CoglPipeline *pipeline,
                                    int layer_index,
                                    const CoglMatrix *matrix);

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.

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the index for the layer inside `pipeline` |
matrix | the transformation matrix for the layer |

Since: 1.10

Stability Level: Unstable

### cogl_pipeline_set_layer_point_sprite_coords_enabled ()

    CoglBool
    cogl_pipeline_set_layer_point_sprite_coords_enabled
                                   (CoglPipeline *pipeline,
                                    int layer_index,
                                    CoglBool enable,
                                    CoglError **error);

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_FEATURE_ID_POINT_SPRITE` is available. If the feature is not available then the function will return `FALSE` and set `error` .

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the layer number to change. |
enable | whether to enable point sprite coord generation. |
error | A return location for a CoglError, or NULL to ignore errors. |

#### Returns

`TRUE` if the function succeeds, `FALSE` otherwise.

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_layer_point_sprite_coords_enabled ()

    CoglBool
    cogl_pipeline_get_layer_point_sprite_coords_enabled
                                   (CoglPipeline *pipeline,
                                    int layer_index);

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

#### Parameters

pipeline | A CoglPipeline object |
layer_index | the layer number to check. |

#### Returns

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

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_remove_layer ()

    void
    cogl_pipeline_remove_layer (CoglPipeline *pipeline,
                                int layer_index);

This function removes a layer from your pipeline

#### Parameters

pipeline | A CoglPipeline object |
layer_index | Specifies the layer you want to remove |

Since: 1.10

Stability Level: Unstable

### cogl_pipeline_get_n_layers ()

    int
    cogl_pipeline_get_n_layers (CoglPipeline *pipeline);

Retrieves the number of layers defined for the given `pipeline`

#### Parameters

pipeline | A CoglPipeline object |

#### Returns

the number of layers

Since: 2.0

Stability Level: Unstable

### CoglPipelineLayerCallback ()

    CoglBool
    (*CoglPipelineLayerCallback) (CoglPipeline *pipeline,
                                  int layer_index,
                                  void *user_data);

The callback prototype used with `cogl_pipeline_foreach_layer()` for iterating all the layers of a `pipeline` .

#### Parameters

pipeline | The CoglPipeline whos layers are being iterated |
layer_index | The current layer index |
user_data | The private data passed to `cogl_pipeline_foreach_layer()` |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_foreach_layer ()

    void
    cogl_pipeline_foreach_layer (CoglPipeline *pipeline,
                                 CoglPipelineLayerCallback callback,
                                 void *user_data);

Iterates all the layer indices of the given `pipeline` .

#### Parameters

pipeline | A CoglPipeline object |
callback | A CoglPipelineLayerCallback to be called for each layer index. | [scope call]
user_data | Private data that will be passed to the callback. | [closure]

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_get_uniform_location ()

    int
    cogl_pipeline_get_uniform_location (CoglPipeline *pipeline,
                                        const char *uniform_name);

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.

#### Parameters

pipeline | A CoglPipeline object |
uniform_name | The name of a uniform |

#### Returns

A integer representing the location of the given uniform.

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_uniform_1f ()

    void
    cogl_pipeline_set_uniform_1f (CoglPipeline *pipeline,
                                  int uniform_location,
                                  float value);

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.

#### Parameters

pipeline | A CoglPipeline object |
uniform_location | The uniform's location identifier |
value | The new value for the uniform |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_uniform_1i ()

    void
    cogl_pipeline_set_uniform_1i (CoglPipeline *pipeline,
                                  int uniform_location,
                                  int value);

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.

#### Parameters

pipeline | A CoglPipeline object |
uniform_location | The uniform's location identifier |
value | The new value for the uniform |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_uniform_float ()

    void
    cogl_pipeline_set_uniform_float (CoglPipeline *pipeline,
                                     int uniform_location,
                                     int n_components,
                                     int count,
                                     const float *value);

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` .

#### Parameters

pipeline | A CoglPipeline object |
uniform_location | The uniform's location identifier |
n_components | The number of components in the corresponding uniform's type |
count | The number of values to set |
value | Pointer to the new values to set |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_uniform_int ()

    void
    cogl_pipeline_set_uniform_int (CoglPipeline *pipeline,
                                   int uniform_location,
                                   int n_components,
                                   int count,
                                   const int *value);

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` .

#### Parameters

pipeline | A CoglPipeline object |
uniform_location | The uniform's location identifier |
n_components | The number of components in the corresponding uniform's type |
count | The number of values to set |
value | Pointer to the new values to set |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_set_uniform_matrix ()

    void
    cogl_pipeline_set_uniform_matrix (CoglPipeline *pipeline,
                                      int uniform_location,
                                      int dimensions,
                                      int count,
                                      CoglBool transpose,
                                      const float *value);

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 CoglMatrix by calling by passing the result of `cogl_matrix_get_array()` in `value` and setting `transpose` to `FALSE`.

#### Parameters

pipeline | A CoglPipeline object |
uniform_location | The uniform's location identifier |
dimensions | The size of the matrix |
count | The number of values to set |
transpose | Whether to transpose the matrix |
value | Pointer to the new values to set |

Since: 2.0

Stability Level: Unstable

### cogl_pipeline_add_snippet ()

    void
    cogl_pipeline_add_snippet (CoglPipeline *pipeline,
                               CoglSnippet *snippet);

Adds a shader snippet to `pipeline` . 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.

#### Parameters

pipeline | A CoglPipeline |
snippet | The CoglSnippet to add to the vertex processing hook |

Since: 1.10

Stability Level: Unstable

### cogl_pipeline_add_layer_snippet ()

    void
    cogl_pipeline_add_layer_snippet (CoglPipeline *pipeline,
                                     int layer,
                                     CoglSnippet *snippet);

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.

#### Parameters

pipeline | A CoglPipeline |
layer | The layer to hook the snippet to |
snippet | A CoglSnippet |

Since: 1.10

Stability Level: Unstable

## Types and Values

### CoglPipeline

    typedef struct _CoglPipeline CoglPipeline;

### enum CoglPipelineAlphaFunc

Alpha testing happens before blending primitives with the framebuffer and gives an opportunity to discard fragments based on a comparison with the incoming alpha value and a reference alpha value. The CoglPipelineAlphaFunc determines how the comparison is done.

#### Members

COGL_PIPELINE_ALPHA_FUNC_NEVER | Never let the fragment through. |
COGL_PIPELINE_ALPHA_FUNC_LESS | Let the fragment through if the incoming alpha value is less than the reference alpha value |
COGL_PIPELINE_ALPHA_FUNC_EQUAL | Let the fragment through if the incoming alpha value equals the reference alpha value |
COGL_PIPELINE_ALPHA_FUNC_LEQUAL | Let the fragment through if the incoming alpha value is less than or equal to the reference alpha value |
COGL_PIPELINE_ALPHA_FUNC_GREATER | Let the fragment through if the incoming alpha value is greater than the reference alpha value |
COGL_PIPELINE_ALPHA_FUNC_NOTEQUAL | Let the fragment through if the incoming alpha value does not equal the reference alpha value |
COGL_PIPELINE_ALPHA_FUNC_GEQUAL | Let the fragment through if the incoming alpha value is greater than or equal to the reference alpha value. |
COGL_PIPELINE_ALPHA_FUNC_ALWAYS | Always let the fragment through. |

### COGL_BLEND_STRING_ERROR

    #define COGL_BLEND_STRING_ERROR (cogl_blend_string_error_quark ())

CoglError domain for blend string parser errors

Since: 1.0

### enum CoglBlendStringError

Error enumeration for the blend strings parser

#### Members

COGL_BLEND_STRING_ERROR_PARSE_ERROR | Generic parse error |
COGL_BLEND_STRING_ERROR_ARGUMENT_PARSE_ERROR | Argument parse error |
COGL_BLEND_STRING_ERROR_INVALID_ERROR | Internal parser error |
COGL_BLEND_STRING_ERROR_GPU_UNSUPPORTED_ERROR | Blend string not supported by the GPU |

Since: 1.0

### enum CoglPipelineCullFaceMode

Specifies which faces should be culled. This can be set on a pipeline using `cogl_pipeline_set_cull_face_mode()`.

#### Members

COGL_PIPELINE_CULL_FACE_MODE_NONE | Neither face will be culled. This is the default. |
COGL_PIPELINE_CULL_FACE_MODE_FRONT | Front faces will be culled. |
COGL_PIPELINE_CULL_FACE_MODE_BACK | Back faces will be culled. |
COGL_PIPELINE_CULL_FACE_MODE_BOTH | All faces will be culled. |

### enum CoglWinding

Enum used to represent the two directions of rotation. This can be used to set the front face for culling by calling `cogl_pipeline_set_front_face_winding()`.

#### Members

COGL_WINDING_CLOCKWISE | Vertices are in a clockwise order |
COGL_WINDING_COUNTER_CLOCKWISE | Vertices are in a counter-clockwise order |

### enum CoglPipelineFilter

Texture filtering is used whenever the current pixel maps either to more than one texture element (texel) or less than one. These filter enums correspond to different strategies used to come up with a pixel color, by possibly referring to multiple neighbouring texels and taking a weighted average or simply using the nearest texel.

#### Members

COGL_PIPELINE_FILTER_NEAREST | Measuring in manhatten distance from the, current pixel center, use the nearest texture texel |
COGL_PIPELINE_FILTER_LINEAR | Use the weighted average of the 4 texels nearest the current pixel center |
COGL_PIPELINE_FILTER_NEAREST_MIPMAP_NEAREST | Select the mimap level whose texel size most closely matches the current pixel, and use the `COGL_PIPELINE_FILTER_NEAREST` criterion |
COGL_PIPELINE_FILTER_LINEAR_MIPMAP_NEAREST | Select the mimap level whose texel size most closely matches the current pixel, and use the `COGL_PIPELINE_FILTER_LINEAR` criterion |
COGL_PIPELINE_FILTER_NEAREST_MIPMAP_LINEAR | Select the two mimap levels whose texel size most closely matches the current pixel, use the `COGL_PIPELINE_FILTER_NEAREST` criterion on each one and take their weighted average |
COGL_PIPELINE_FILTER_LINEAR_MIPMAP_LINEAR | Select the two mimap levels whose texel size most closely matches the current pixel, use the `COGL_PIPELINE_FILTER_LINEAR` criterion on each one and take their weighted average |

### enum CoglPipelineWrapMode

The wrap mode specifies what happens when texture coordinates outside the range 0→1 are used. Note that if the filter mode is anything but `COGL_PIPELINE_FILTER_NEAREST` then texels outside the range 0→1 might be used even when the coordinate is exactly 0 or 1 because OpenGL will try to sample neighbouring pixels. For example if you are trying to render the full texture then you may get artifacts around the edges when the pixels from the other side are merged in if the wrap mode is set to repeat.

#### Members

COGL_PIPELINE_WRAP_MODE_REPEAT | The texture will be repeated. This is useful for example to draw a tiled background. |
COGL_PIPELINE_WRAP_MODE_MIRRORED_REPEAT |  |
COGL_PIPELINE_WRAP_MODE_CLAMP_TO_EDGE | The coordinates outside the range 0→1 will sample copies of the edge pixels of the texture. This is useful to avoid artifacts if only one copy of the texture is being rendered. |
COGL_PIPELINE_WRAP_MODE_AUTOMATIC | Cogl will try to automatically decide which of the above two to use. For `cogl_rectangle()`, it will use repeat mode if any of the texture coordinates are outside the range 0→1, otherwise it will use clamp to edge. For `cogl_polygon()` it will always use repeat mode. For `cogl_vertex_buffer_draw()` it will use repeat mode except for layers that have point sprite coordinate generation enabled. This is the default value. |

Since: 2.0