58 ClutterShaderEffect

58.1 Overview

<clutter-shader-effect> is a class that implements all the
plumbing for creating <clutter-effect>s using GLSL shaders.

<clutter-shader-effect> creates an offscreen buffer and then
applies the GLSL shader (after checking whether the compilation and
linking were successfull) to the buffer before painting it on screen.

58.2 Implementing a ClutterShaderEffect

Creating a sub-class of <clutter-shader-effect> requires the
overriding of the paint-target virtual function from the
<clutter-offscreen-effect> class as well as the
get-static-shader-source virtual from the
<clutter-shader-effect> class.

The get-static-shader-source function should return a copy
of the shader source to use. This function is only called once per
subclass of <clutter-shader-effect> regardless of how many
instances of the effect are created. The source for the shader is
typically stored in a static const string which is returned from this
function via g-strdup.

The paint-target should set the shader's uniforms if any.
This is done by calling clutter-shader-effect-set-uniform-value
or clutter-shader-effect-set-uniform. The sub-class should then
chain up to the <clutter-shader-effect> implementation.

The example below shows a typical implementation of the
get-static-shader-source and paint-target
phases of a <clutter-shader-effect> sub-class.