## ClutterShader ClutterShader — Programmable pipeline abstraction |

## Synopsis

    enum                ClutterShaderError;
                        ClutterShader;
                        ClutterShaderClass;
    ClutterShader *     clutter_shader_new                  (void);
    void                clutter_shader_set_vertex_source    (ClutterShader *shader,
                                                             const gchar *data,
                                                             gssize length);
    const gchar *       clutter_shader_get_vertex_source    (ClutterShader *shader);
    void                clutter_shader_set_fragment_source  (ClutterShader *shader,
                                                             const gchar *data,
                                                             gssize length);
    const gchar *       clutter_shader_get_fragment_source  (ClutterShader *shader);
    gboolean            clutter_shader_compile              (ClutterShader *shader,
                                                             GError **error);
    void                clutter_shader_release              (ClutterShader *shader);
    gboolean            clutter_shader_is_compiled          (ClutterShader *shader);
    void                clutter_shader_set_is_enabled       (ClutterShader *shader,
                                                             gboolean enabled);
    gboolean            clutter_shader_get_is_enabled       (ClutterShader *shader);
    void                clutter_shader_set_uniform_1f       (ClutterShader *shader,
                                                             const gchar *name,
                                                             gfloat value);

## Object Hierarchy

      GObject
       +----ClutterShader

## Properties

      "compiled"                 gboolean              : Read
      "enabled"                  gboolean              : Read / Write
      "fragment-source"          gchar*                : Read / Write
      "vertex-source"            gchar*                : Read / Write

## Description

ClutterShader is an object providing an abstraction over the OpenGL programmable pipeline. By using ClutterShaders is possible to override the drawing pipeline by using small programs also known as "shaders".

ClutterShader is available since Clutter 0.6

## Details

### enum ClutterShaderError

    typedef enum {
      CLUTTER_SHADER_ERROR_NO_ASM,
      CLUTTER_SHADER_ERROR_NO_GLSL,
      CLUTTER_SHADER_ERROR_COMPILE
    } ClutterShaderError;

ClutterShader error enumeration

`CLUTTER_SHADER_ERROR_NO_ASM` | No ASM shaders support
`CLUTTER_SHADER_ERROR_NO_GLSL` | No GLSL shaders support
`CLUTTER_SHADER_ERROR_COMPILE` | Compilation error

Since 0.6

### ClutterShader

    typedef struct _ClutterShader ClutterShader;

### ClutterShaderClass

    typedef struct {
    } ClutterShaderClass;

### clutter_shader_new ()

    ClutterShader *     clutter_shader_new                  (void);

Create a new ClutterShader instance.

Returns : | a new ClutterShader.

Since 0.6

### clutter_shader_set_vertex_source ()

    void                clutter_shader_set_vertex_source    (ClutterShader *shader,
                                                             const gchar *data,
                                                             gssize length);

Sets the GLSL source code to be used by a ClutterShader for the vertex program.

`shader` : | a ClutterShader
`data` : | GLSL source code.
`length` : | length of source buffer (currently ignored)

Since 0.6

### clutter_shader_get_vertex_source ()

    const gchar *       clutter_shader_get_vertex_source    (ClutterShader *shader);

Query the current GLSL vertex source set on `shader`.

`shader` : | a ClutterShader
Returns : | the source of the vertex shader for this ClutterShader object or `NULL`. The returned string is owned by the shader object and should never be modified or freed

Since 0.6

### clutter_shader_set_fragment_source ()

    void                clutter_shader_set_fragment_source  (ClutterShader *shader,
                                                             const gchar *data,
                                                             gssize length);

Sets the GLSL source code to be used by a ClutterShader for the fragment program.

`shader` : | a ClutterShader
`data` : | GLSL source code.
`length` : | length of source buffer (currently ignored)

Since 0.6

### clutter_shader_get_fragment_source ()

    const gchar *       clutter_shader_get_fragment_source  (ClutterShader *shader);

Query the current GLSL fragment source set on `shader`.

`shader` : | a ClutterShader
Returns : | the source of the fragment shader for this ClutterShader object or `NULL`. The returned string is owned by the shader object and should never be modified or freed

Since 0.6

### clutter_shader_compile ()

    gboolean            clutter_shader_compile              (ClutterShader *shader,
                                                             GError **error);

Compiles and links GLSL sources set for vertex and fragment shaders for a ClutterShader. If the compilation fails and a GError return location is provided the error will contain the errors from the compiler, if any.

`shader` : | a ClutterShader
`error` : | return location for a GError, or `NULL`
Returns : | returns TRUE if the shader was succesfully compiled.

Since 0.8

### clutter_shader_release ()

    void                clutter_shader_release              (ClutterShader *shader);

Frees up any GL context resources held by the shader.

`shader` : | a ClutterShader

Since 0.6

### clutter_shader_is_compiled ()

    gboolean            clutter_shader_is_compiled          (ClutterShader *shader);

Checks whether `shader` is is currently compiled, linked and bound to the GL context.

`shader` : | a ClutterShader
Returns : | `TRUE` if the shader is compiled, linked and ready for use.

Since 0.8

### clutter_shader_set_is_enabled ()

    void                clutter_shader_set_is_enabled       (ClutterShader *shader,
                                                             gboolean enabled);

Enables a shader. This function will attempt to compile and link the shader, if it isn't already.

When `enabled` is `FALSE` the default state of the GL pipeline will be used instead.

`shader` : | a ClutterShader
`enabled` : | The new state of the shader.

Since 0.6

### clutter_shader_get_is_enabled ()

    gboolean            clutter_shader_get_is_enabled       (ClutterShader *shader);

Checks whether `shader` is enabled.

`shader` : | a ClutterShader
Returns : | `TRUE` if the shader is enabled.

Since 0.6

### clutter_shader_set_uniform_1f ()

    void                clutter_shader_set_uniform_1f       (ClutterShader *shader,
                                                             const gchar *name,
                                                             gfloat value);

Sets a user configurable variable in the shader programs attached to a ClutterShader.

`shader` : | a ClutterShader
`name` : | name of uniform in vertex or fragment program to set.
`value` : | the new value of the uniform.

Since 0.6

## Property Details

### The `"compiled"` property

      "compiled"                 gboolean              : Read

Whether the shader is compiled and linked, ready for use in the GL context.

Default value: FALSE

Since 0.8

### The `"enabled"` property

      "enabled"                  gboolean              : Read / Write

Whether the shader is currently used in the GL rendering pipeline.

Default value: FALSE

Since 0.6

### The `"fragment-source"` property

      "fragment-source"          gchar*                : Read / Write

GLSL source code for the fragment shader part of the shader program.

Default value: NULL

Since 0.6

### The `"vertex-source"` property

      "vertex-source"            gchar*                : Read / Write

GLSL source code for the vertex shader part of the shader program, if any.

Default value: NULL

Since 0.6