## Materials

Materials — Fuctions for creating and manipulating materials

## Functions

CoglBool | (*CoglMaterialLayerCallback) ()
CoglMaterial * | cogl_material_new ()
CoglMaterial * | cogl_material_copy ()
CoglBool | cogl_is_material ()
void | cogl_material_set_color ()
void | cogl_material_set_color4ub ()
void | cogl_material_set_color4f ()
void | cogl_material_get_color ()
void | cogl_material_set_ambient ()
void | cogl_material_get_ambient ()
void | cogl_material_set_diffuse ()
void | cogl_material_get_diffuse ()
void | cogl_material_set_ambient_and_diffuse ()
void | cogl_material_set_emission ()
void | cogl_material_get_emission ()
void | cogl_material_set_specular ()
void | cogl_material_get_specular ()
void | cogl_material_set_shininess ()
float | cogl_material_get_shininess ()
void | cogl_material_set_alpha_test_function ()
CoglBool | cogl_material_set_blend ()
void | cogl_material_set_blend_constant ()
void | cogl_material_set_point_size ()
float | cogl_material_get_point_size ()
void | cogl_material_set_layer ()
void | cogl_material_remove_layer ()
CoglBool | cogl_material_set_layer_combine ()
void | cogl_material_set_layer_combine_constant ()
void | cogl_material_set_layer_matrix ()
CoglBool | cogl_material_set_layer_point_sprite_coords_enabled ()
CoglBool | cogl_material_get_layer_point_sprite_coords_enabled ()
int | cogl_material_get_n_layers ()
void | cogl_material_set_layer_filters ()
CoglMaterialLayerType | cogl_material_layer_get_type ()
CoglHandle | cogl_material_layer_get_texture ()
CoglMaterialFilter | cogl_material_layer_get_min_filter ()
CoglMaterialFilter | cogl_material_layer_get_mag_filter ()
void | cogl_material_set_layer_wrap_mode ()
void | cogl_material_set_layer_wrap_mode_s ()
void | cogl_material_set_layer_wrap_mode_t ()
void | cogl_material_set_layer_wrap_mode_p ()
CoglMaterialWrapMode | cogl_material_get_layer_wrap_mode_s ()
CoglMaterialWrapMode | cogl_material_get_layer_wrap_mode_t ()
CoglMaterialWrapMode | cogl_material_get_layer_wrap_mode_p ()
GType | cogl_material_wrap_mode_get_type ()
void | cogl_material_set_user_program ()
CoglHandle | cogl_material_get_user_program ()
void | cogl_material_foreach_layer ()

## Types and Values

| CoglMaterial
| CoglMaterialLayer
enum | CoglMaterialAlphaFunc
#define | COGL_BLEND_STRING_ERROR
enum | CoglBlendStringError
enum | CoglMaterialFilter
enum | CoglMaterialLayerType
enum | CoglMaterialWrapMode

## Description

COGL allows creating and manipulating materials used to fill in geometry. Materials may simply be lighting attributes (such as an ambient and diffuse colour) or might represent one or more textures blended together.

## Functions

### CoglMaterialLayerCallback ()

    CoglBool
    (*CoglMaterialLayerCallback) (CoglMaterial *material,
                                  int layer_index,
                                  void *user_data);

`CoglMaterialLayerCallback` has been deprecated since version 1.16 and should not be used in newly-written code.

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

#### Parameters

material | The CoglMaterial whos layers are being iterated |
layer_index | The current layer index |
user_data | The private data passed to `cogl_material_foreach_layer()` |

Since: 1.4

Stability Level: Unstable

### cogl_material_new ()

    CoglMaterial *
    cogl_material_new (void);

`cogl_material_new` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_new()` instead

Allocates and initializes a blank white material

#### Returns

a pointer to a new CoglMaterial

### cogl_material_copy ()

    CoglMaterial *
    cogl_material_copy (CoglMaterial *source);

`cogl_material_copy` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_copy()` instead

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

We would strongly advise developers to always aim to use `cogl_material_copy()` instead of `cogl_material_new()` whenever there will be any similarity between two materials. Copying a material helps Cogl keep track of a materials ancestry which we may use to help minimize GPU state changes.

#### Parameters

source | a CoglMaterial object to copy |

#### Returns

a pointer to the newly allocated CoglMaterial

Since: 1.2

### cogl_is_material ()

    CoglBool
    cogl_is_material (CoglHandle handle);

`cogl_is_material` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_is_pipeline()` instead

Gets whether the given handle references an existing material object.

#### Parameters

handle | A CoglHandle |

#### Returns

`TRUE` if the handle references a CoglMaterial, `FALSE` otherwise

### cogl_material_set_color ()

    void
    cogl_material_set_color (CoglMaterial *material,
                             const CoglColor *color);

`cogl_material_set_color` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_color()` instead

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

Note that if you don't add any layers to the material 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

material | A CoglMaterial object |
color | The components of the color |

Since: 1.0

### cogl_material_set_color4ub ()

    void
    cogl_material_set_color4ub (CoglMaterial *material,
                                uint8_t red,
                                uint8_t green,
                                uint8_t blue,
                                uint8_t alpha);

`cogl_material_set_color4ub` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_color4ub()` instead

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

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

#### Parameters

material | A CoglMaterial object |
red | The red component |
green | The green component |
blue | The blue component |
alpha | The alpha component |

Since: 1.0

### cogl_material_set_color4f ()

    void
    cogl_material_set_color4f (CoglMaterial *material,
                               float red,
                               float green,
                               float blue,
                               float alpha);

`cogl_material_set_color4f` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_color4f()` instead

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

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

#### Parameters

material | A CoglMaterial object |
red | The red component |
green | The green component |
blue | The blue component |
alpha | The alpha component |

Since: 1.0

### cogl_material_get_color ()

    void
    cogl_material_get_color (CoglMaterial *material,
                             CoglColor *color);

`cogl_material_get_color` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_get_color()` instead

Retrieves the current material color.

#### Parameters

material | A CoglMaterial object |
color | The location to store the color. | [out]

Since: 1.0

### cogl_material_set_ambient ()

    void
    cogl_material_set_ambient (CoglMaterial *material,
                               const CoglColor *ambient);

`cogl_material_set_ambient` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Sets the material'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

material | A CoglMaterial object |
ambient | The components of the desired ambient color |

Since: 1.0

### cogl_material_get_ambient ()

    void
    cogl_material_get_ambient (CoglMaterial *material,
                               CoglColor *ambient);

`cogl_material_get_ambient` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Retrieves the current ambient color for `material`

#### Parameters

material | A CoglMaterial object |
ambient | The location to store the ambient color |

Since: 1.0

### cogl_material_set_diffuse ()

    void
    cogl_material_set_diffuse (CoglMaterial *material,
                               const CoglColor *diffuse);

`cogl_material_set_diffuse` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Sets the material'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

material | A CoglMaterial object |
diffuse | The components of the desired diffuse color |

Since: 1.0

### cogl_material_get_diffuse ()

    void
    cogl_material_get_diffuse (CoglMaterial *material,
                               CoglColor *diffuse);

`cogl_material_get_diffuse` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Retrieves the current diffuse color for `material`

#### Parameters

material | A CoglMaterial object |
diffuse | The location to store the diffuse color |

Since: 1.0

### cogl_material_set_ambient_and_diffuse ()

    void
    cogl_material_set_ambient_and_diffuse (CoglMaterial *material,
                                           const CoglColor *color);

`cogl_material_set_ambient_and_diffuse` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Conveniently sets the diffuse and ambient color of `material` at the same time. See `cogl_material_set_ambient()` and `cogl_material_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

material | A CoglMaterial object |
color | The components of the desired ambient and diffuse colors |

Since: 1.0

### cogl_material_set_emission ()

    void
    cogl_material_set_emission (CoglMaterial *material,
                                const CoglColor *emission);

`cogl_material_set_emission` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Sets the material'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

material | A CoglMaterial object |
emission | The components of the desired emissive color |

Since: 1.0

### cogl_material_get_emission ()

    void
    cogl_material_get_emission (CoglMaterial *material,
                                CoglColor *emission);

`cogl_material_get_emission` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Retrieves the materials current emission color.

#### Parameters

material | A CoglMaterial object |
emission | The location to store the emission color |

Since: 1.0

### cogl_material_set_specular ()

    void
    cogl_material_set_specular (CoglMaterial *material,
                                const CoglColor *specular);

`cogl_material_set_specular` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Sets the material'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

material | A CoglMaterial object |
specular | The components of the desired specular color |

Since: 1.0

### cogl_material_get_specular ()

    void
    cogl_material_get_specular (CoglMaterial *material,
                                CoglColor *specular);

`cogl_material_get_specular` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Retrieves the materials current specular color.

#### Parameters

material | A CoglMaterial object |
specular | The location to store the specular color |

Since: 1.0

### cogl_material_set_shininess ()

    void
    cogl_material_set_shininess (CoglMaterial *material,
                                 float shininess);

`cogl_material_set_shininess` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Sets the shininess of the material, 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

material | A CoglMaterial object |
shininess | The desired shininess; must be >= 0.0 |

Since: 1.0

### cogl_material_get_shininess ()

    float
    cogl_material_get_shininess (CoglMaterial *material);

`cogl_material_get_shininess` has been deprecated since version 1.16 and should not be used in newly-written code.

Use the CoglSnippet shader api for lighting

Retrieves the materials current emission color.

#### Parameters

material | A CoglMaterial object |

#### Returns

The materials current shininess value

Since: 1.0

### cogl_material_set_alpha_test_function ()

    void
    cogl_material_set_alpha_test_function (CoglMaterial *material,
                                           CoglMaterialAlphaFunc alpha_func,
                                           float alpha_reference);

`cogl_material_set_alpha_test_function` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_alpha_test_function()` instead

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

#### Parameters

material | A CoglMaterial object |
alpha_func | A `CoglMaterialAlphaFunc` constant |
alpha_reference | A reference point that the chosen alpha function uses to compare incoming fragments to. |

Since: 1.0

### cogl_material_set_blend ()

    CoglBool
    cogl_material_set_blend (CoglMaterial *material,
                             const char *blend_string,
                             CoglError **error);

`cogl_material_set_blend` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_blend()` instead

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

The brackets around blend factors are currently not optional!

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_material_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 material is in premultiplied form.

#### Parameters

material | A CoglMaterial 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: 1.0

### cogl_material_set_blend_constant ()

    void
    cogl_material_set_blend_constant (CoglMaterial *material,
                                      const CoglColor *constant_color);

`cogl_material_set_blend_constant` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_blend_constant()` instead

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

#### Parameters

material | A CoglMaterial object |
constant_color | The constant color you want |

Since: 1.0

### cogl_material_set_point_size ()

    void
    cogl_material_set_point_size (CoglMaterial *material,
                                  float point_size);

`cogl_material_set_point_size` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_point_size()` instead

Changes the size of points drawn when `COGL_VERTICES_MODE_POINTS` is used with the vertex 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. The default point size is 1.0.

#### Parameters

material | a material. |
point_size | the new point size. |

Since: 1.4

### cogl_material_get_point_size ()

    float
    cogl_material_get_point_size (CoglMaterial *material);

`cogl_material_get_point_size` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_get_point_size()` instead

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

#### Parameters

material | a CoglHandle to a material. |

#### Returns

the point size of the material.

Since: 1.4

### cogl_material_set_layer ()

    void
    cogl_material_set_layer (CoglMaterial *material,
                             int layer_index,
                             CoglHandle texture);

`cogl_material_set_layer` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer()` instead

In addition to the standard OpenGL lighting model a Cogl material may have one or more layers comprised of textures that can be blended together in order, with a number of different texture combine modes. This function defines a new texture layer.

The index values of multiple layers do not have to be consecutive; it is only their relative order that is important.

In the future, we may define other types of material layers, such as purely GLSL based layers.

#### Parameters

material | A CoglMaterial object |
layer_index | the index of the layer |
texture | a CoglHandle for the layer object |

Since: 1.0

### cogl_material_remove_layer ()

    void
    cogl_material_remove_layer (CoglMaterial *material,
                                int layer_index);

`cogl_material_remove_layer` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_remove_layer()` instead

This function removes a layer from your material

#### Parameters

material | A CoglMaterial object |
layer_index | Specifies the layer you want to remove |

### cogl_material_set_layer_combine ()

    CoglBool
    cogl_material_set_layer_combine (CoglMaterial *material,
                                     int layer_index,
                                     const char *blend_string,
                                     CoglError **error);

`cogl_material_set_layer_combine` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer_combine()` instead

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_material_set_layer_constant()`
PRIMARY | Use the color of the material as set with `cogl_material_set_color()`
PREVIOUS | Either use the texture color from the previous layer, or if this is layer 0, use the color of the material as set with `cogl_material_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_material_set_layer_constant.

    1

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

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

#### Parameters

material | A CoglMaterial 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: 1.0

### cogl_material_set_layer_combine_constant ()

    void
    cogl_material_set_layer_combine_constant
                                   (CoglMaterial *material,
                                    int layer_index,
                                    const CoglColor *constant);

`cogl_material_set_layer_combine_constant` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer_combine_constant()` instead

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

#### Parameters

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

Since: 1.0

### cogl_material_set_layer_matrix ()

    void
    cogl_material_set_layer_matrix (CoglMaterial *material,
                                    int layer_index,
                                    const CoglMatrix *matrix);

`cogl_material_set_layer_matrix` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer_matrix()` instead

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

#### Parameters

material | A CoglMaterial object |
layer_index | the index for the layer inside `material` |
matrix | the transformation matrix for the layer |

### cogl_material_set_layer_point_sprite_coords_enabled ()

    CoglBool
    cogl_material_set_layer_point_sprite_coords_enabled
                                   (CoglMaterial *material,
                                    int layer_index,
                                    CoglBool enable,
                                    CoglError **error);

`cogl_material_set_layer_point_sprite_coords_enabled` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer_point_sprite_coords_enabled()` instead

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

#### Parameters

material | a CoglHandle to a material. |
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: 1.4

### cogl_material_get_layer_point_sprite_coords_enabled ()

    CoglBool
    cogl_material_get_layer_point_sprite_coords_enabled
                                   (CoglMaterial *material,
                                    int layer_index);

`cogl_material_get_layer_point_sprite_coords_enabled` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_get_layer_point_sprite_coords_enabled()` instead

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

#### Parameters

material | a CoglHandle to a material. |
layer_index | the layer number to check. |

#### Returns

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

Since: 1.4

### cogl_material_get_n_layers ()

    int
    cogl_material_get_n_layers (CoglMaterial *material);

`cogl_material_get_n_layers` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_get_n_layers()` instead

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

#### Parameters

material | A CoglMaterial object |

#### Returns

the number of layers

Since: 1.0

### cogl_material_set_layer_filters ()

    void
    cogl_material_set_layer_filters (CoglMaterial *material,
                                     int layer_index,
                                     CoglMaterialFilter min_filter,
                                     CoglMaterialFilter mag_filter);

`cogl_material_set_layer_filters` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer_filters()` instead

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

#### Parameters

material | A CoglMaterial 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. |

### cogl_material_layer_get_type ()

    CoglMaterialLayerType
    cogl_material_layer_get_type (CoglMaterialLayer *layer);

`cogl_material_layer_get_type` has been deprecated since version 1.16 and should not be used in newly-written code.

No replacement

Retrieves the type of the layer

Currently there is only one type of layer defined: `COGL_MATERIAL_LAYER_TYPE_TEXTURE`, but considering we may add purely GLSL based layers in the future, you should write code that checks the type first.

#### Parameters

layer | A CoglMaterialLayer object |

#### Returns

the type of the layer

### cogl_material_layer_get_texture ()

    CoglHandle
    cogl_material_layer_get_texture (CoglMaterialLayer *layer);

`cogl_material_layer_get_texture` has been deprecated since version 1.16 and should not be used in newly-written code.

No replacement

Extracts a texture handle for a specific layer.

In the future Cogl may support purely GLSL based layers; for those layers this function which will likely return `COGL_INVALID_HANDLE` if you try to get the texture handle from them. Considering this scenario, you should call `cogl_material_layer_get_type()` first in order check it is of type `COGL_MATERIAL_LAYER_TYPE_TEXTURE` before calling this function.

#### Parameters

layer | A CoglMaterialLayer object |

#### Returns

a CoglHandle for the texture inside the layer.

[transfer none]

### cogl_material_layer_get_min_filter ()

    CoglMaterialFilter
    cogl_material_layer_get_min_filter (CoglMaterialLayer *layer);

`cogl_material_layer_get_min_filter` has been deprecated since version 1.16 and should not be used in newly-written code.

No replacement

Queries the currently set downscaling filter for a material layer

#### Parameters

layer | a CoglHandle for a material layer |

#### Returns

the current downscaling filter

### cogl_material_layer_get_mag_filter ()

    CoglMaterialFilter
    cogl_material_layer_get_mag_filter (CoglMaterialLayer *layer);

`cogl_material_layer_get_mag_filter` has been deprecated since version 1.16 and should not be used in newly-written code.

No replacement

Queries the currently set downscaling filter for a material later

#### Parameters

layer | A CoglMaterialLayer object |

#### Returns

the current downscaling filter

### cogl_material_set_layer_wrap_mode ()

    void
    cogl_material_set_layer_wrap_mode (CoglMaterial *material,
                                       int layer_index,
                                       CoglMaterialWrapMode mode);

`cogl_material_set_layer_wrap_mode` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer_wrap_mode()` instead

Sets the wrap mode for all three coordinates of texture lookups on this layer. This is equivalent to calling `cogl_material_set_layer_wrap_mode_s()`, `cogl_material_set_layer_wrap_mode_t()` and `cogl_material_set_layer_wrap_mode_p()` separately.

#### Parameters

material | A CoglMaterial object |
layer_index | the layer number to change. |
mode | the new wrap mode |

Since: 1.4

### cogl_material_set_layer_wrap_mode_s ()

    void
    cogl_material_set_layer_wrap_mode_s (CoglMaterial *material,
                                         int layer_index,
                                         CoglMaterialWrapMode mode);

`cogl_material_set_layer_wrap_mode_s` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer_wrap_mode_s()` instead

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

#### Parameters

material | A CoglMaterial object |
layer_index | the layer number to change. |
mode | the new wrap mode |

Since: 1.4

### cogl_material_set_layer_wrap_mode_t ()

    void
    cogl_material_set_layer_wrap_mode_t (CoglMaterial *material,
                                         int layer_index,
                                         CoglMaterialWrapMode mode);

`cogl_material_set_layer_wrap_mode_t` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer_wrap_mode_t()` instead

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

#### Parameters

material | A CoglMaterial object |
layer_index | the layer number to change. |
mode | the new wrap mode |

Since: 1.4

### cogl_material_set_layer_wrap_mode_p ()

    void
    cogl_material_set_layer_wrap_mode_p (CoglMaterial *material,
                                         int layer_index,
                                         CoglMaterialWrapMode mode);

`cogl_material_set_layer_wrap_mode_p` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_set_layer_wrap_mode_p()` instead

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

#### Parameters

material | A CoglMaterial object |
layer_index | the layer number to change. |
mode | the new wrap mode |

Since: 1.4

### cogl_material_get_layer_wrap_mode_s ()

    CoglMaterialWrapMode
    cogl_material_get_layer_wrap_mode_s (CoglMaterial *material,
                                         int layer_index);

`cogl_material_get_layer_wrap_mode_s` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_get_layer_wrap_mode_s()` instead

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

#### Parameters

material | A CoglMaterial object |
layer_index | the layer number to change. |

#### Returns

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

Since: 1.6

### cogl_material_get_layer_wrap_mode_t ()

    CoglMaterialWrapMode
    cogl_material_get_layer_wrap_mode_t (CoglMaterial *material,
                                         int layer_index);

`cogl_material_get_layer_wrap_mode_t` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_get_layer_wrap_mode_t()` instead

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

#### Parameters

material | A CoglMaterial object |
layer_index | the layer number to change. |

#### Returns

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

Since: 1.6

### cogl_material_get_layer_wrap_mode_p ()

    CoglMaterialWrapMode
    cogl_material_get_layer_wrap_mode_p (CoglMaterial *material,
                                         int layer_index);

`cogl_material_get_layer_wrap_mode_p` has been deprecated since version 1.16 and should not be used in newly-written code.

Use `cogl_pipeline_get_layer_wrap_mode_p()` instead

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

#### Parameters

material | A CoglMaterial object |
layer_index | the layer number to change. |

#### Returns

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

Since: 1.6

### cogl_material_wrap_mode_get_type ()

    GType
    cogl_material_wrap_mode_get_type (void);

### cogl_material_set_user_program ()

    void
    cogl_material_set_user_program (CoglMaterial *material,
                                    CoglHandle program);

`cogl_material_set_user_program` has been deprecated since version 1.16 and should not be used in newly-written code.

Use CoglSnippet api instead instead

Associates a linked CoglProgram with the given material 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 CoglMaterial:

    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20

    CoglHandle shader;
    CoglHandle program;
    CoglMaterial *material;

    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);

    material = cogl_material_new ();
    cogl_material_set_user_program (material, 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_FEATURE_SHADERS_GLSL` or `COGL_FEATURE_SHADERS_ARBFP` before using the cogl_program or cogl_shader API.

#### Parameters

material | a CoglMaterial object. |
program | A CoglHandle to a linked CoglProgram |

Since: 1.4

### cogl_material_get_user_program ()

    CoglHandle
    cogl_material_get_user_program (CoglMaterial *material);

`cogl_material_get_user_program` has been deprecated since version 1.16 and should not be used in newly-written code.

Use CoglSnippet api instead instead

Queries what user program has been associated with the given `material` using `cogl_material_set_user_program()`.

#### Parameters

material | a CoglMaterial object. |

#### Returns

The current user program or `COGL_INVALID_HANDLE`.

[transfer none]

Since: 1.4

### cogl_material_foreach_layer ()

    void
    cogl_material_foreach_layer (CoglMaterial *material,
                                 CoglMaterialLayerCallback callback,
                                 void *user_data);

`cogl_material_foreach_layer` has been deprecated since version 1.16 and should not be used in newly-written code.

No replacement

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

#### Parameters

material | A CoglMaterial object |
callback | A CoglMaterialLayerCallback to be called for each layer index |
user_data | Private data that will be passed to the callback |

Since: 1.4

Stability Level: Unstable

## Types and Values

### CoglMaterial

    typedef struct _CoglMaterial CoglMaterial;

### CoglMaterialLayer

    typedef struct _CoglMaterialLayer CoglMaterialLayer;

### enum CoglMaterialAlphaFunc

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 CoglMaterialAlphaFunc determines how the comparison is done.

#### Members

COGL_MATERIAL_ALPHA_FUNC_NEVER | Never let the fragment through. |
COGL_MATERIAL_ALPHA_FUNC_LESS | Let the fragment through if the incoming alpha value is less than the reference alpha value |
COGL_MATERIAL_ALPHA_FUNC_EQUAL | Let the fragment through if the incoming alpha value equals the reference alpha value |
COGL_MATERIAL_ALPHA_FUNC_LEQUAL | Let the fragment through if the incoming alpha value is less than or equal to the reference alpha value |
COGL_MATERIAL_ALPHA_FUNC_GREATER | Let the fragment through if the incoming alpha value is greater than the reference alpha value |
COGL_MATERIAL_ALPHA_FUNC_NOTEQUAL | Let the fragment through if the incoming alpha value does not equal the reference alpha value |
COGL_MATERIAL_ALPHA_FUNC_GEQUAL | Let the fragment through if the incoming alpha value is greater than or equal to the reference alpha value. |
COGL_MATERIAL_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 CoglMaterialFilter

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_MATERIAL_FILTER_NEAREST | Measuring in manhatten distance from the, current pixel center, use the nearest texture texel |
COGL_MATERIAL_FILTER_LINEAR | Use the weighted average of the 4 texels nearest the current pixel center |
COGL_MATERIAL_FILTER_NEAREST_MIPMAP_NEAREST | Select the mimap level whose texel size most closely matches the current pixel, and use the `COGL_MATERIAL_FILTER_NEAREST` criterion |
COGL_MATERIAL_FILTER_LINEAR_MIPMAP_NEAREST | Select the mimap level whose texel size most closely matches the current pixel, and use the `COGL_MATERIAL_FILTER_LINEAR` criterion |
COGL_MATERIAL_FILTER_NEAREST_MIPMAP_LINEAR | Select the two mimap levels whose texel size most closely matches the current pixel, use the `COGL_MATERIAL_FILTER_NEAREST` criterion on each one and take their weighted average |
COGL_MATERIAL_FILTER_LINEAR_MIPMAP_LINEAR | Select the two mimap levels whose texel size most closely matches the current pixel, use the `COGL_MATERIAL_FILTER_LINEAR` criterion on each one and take their weighted average |

### enum CoglMaterialLayerType

Available types of layers for a CoglMaterial. This enumeration might be expanded in later versions.

#### Members

COGL_MATERIAL_LAYER_TYPE_TEXTURE | The layer represents a texture |

Since: 1.0

### enum CoglMaterialWrapMode

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_MATERIAL_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_MATERIAL_WRAP_MODE_REPEAT | The texture will be repeated. This is useful for example to draw a tiled background. |
COGL_MATERIAL_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_MATERIAL_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: 1.4