### Method

# Cogl Pipeline set_layer_combine

#### Declaration [src]

    gboolean
    cogl_pipeline_set_layer_combine (
      CoglPipeline* pipeline,
      int layer_index,
      const char* blend_string,
      GError** error
    )

#### Description [src]

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

The valid source names for texture combining are:

- `TEXTURE`: Use the color from the current texture layer
- `TEXTURE_0, TEXTURE_1, etc`: Use the color from the specified texture layer
- `CONSTANT`: Use the color from the constant given with `cogl_pipeline_set_layer_combine_constant()`
- `PRIMARY`: Use the color of the pipeline as set with `cogl_pipeline_set_color()`
- `PREVIOUS`: Either use the texture color from the previous layer, or if this is layer 0, use the color of the pipeline as set with `cogl_pipeline_set_color()`

Layer Combine Examples:

This is effectively what the default blending is:

    RGBA = MODULATE (PREVIOUS, TEXTURE)

This could be used to cross-fade between two images, using the alpha component of a constant as the interpolator. The constant color is given by calling `cogl_pipeline_set_layer_combine_constant()`.

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

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

#### Parameters

`layer_index`

  Type: `int`

  Specifies the layer you want define a combine function for.

`blend_string`

  Type: `const char*`

  A Cogl blend string describing the desired texture combine function.

  The data is owned by the caller of the method.
  The value is a NUL terminated UTF-8 string.

`error`

  Type: `GError **`

  The return location for a recoverable error.

  The argument can be `NULL`.
  If the return location is not `NULL`, then you must initialize it to a `NULL` `GError*`.
  The argument will be left initialized to `NULL` by the method if there are no errors.
  In case of error, the argument will be set to a newly allocated `GError`; the caller will take ownership of the data, and be responsible for freeing it.

#### Return value

Type: `gboolean`

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