Blob Blame History Raw
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>ClutterShaderEffect: Clutter Reference Manual</title>
<meta name="generator" content="DocBook XSL Stylesheets Vsnapshot">
<link rel="home" href="index.html" title="Clutter Reference Manual">
<link rel="up" href="ch06.html" title="Effects">
<link rel="prev" href="ClutterOffscreenEffect.html" title="ClutterOffscreenEffect">
<link rel="next" href="ClutterDeformEffect.html" title="ClutterDeformEffect">
<meta name="generator" content="GTK-Doc V1.25.1 (XML mode)">
<link rel="stylesheet" href="style.css" type="text/css">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="5"><tr valign="middle">
<td width="100%" align="left" class="shortcuts">
<a href="#" class="shortcut">Top</a><span id="nav_description">  <span class="dim">|</span> 
                  <a href="#ClutterShaderEffect.description" class="shortcut">Description</a></span><span id="nav_hierarchy">  <span class="dim">|</span> 
                  <a href="#ClutterShaderEffect.object-hierarchy" class="shortcut">Object Hierarchy</a></span><span id="nav_properties">  <span class="dim">|</span> 
                  <a href="#ClutterShaderEffect.properties" class="shortcut">Properties</a></span>
</td>
<td><a accesskey="h" href="index.html"><img src="home.png" width="16" height="16" border="0" alt="Home"></a></td>
<td><a accesskey="u" href="ch06.html"><img src="up.png" width="16" height="16" border="0" alt="Up"></a></td>
<td><a accesskey="p" href="ClutterOffscreenEffect.html"><img src="left.png" width="16" height="16" border="0" alt="Prev"></a></td>
<td><a accesskey="n" href="ClutterDeformEffect.html"><img src="right.png" width="16" height="16" border="0" alt="Next"></a></td>
</tr></table>
<div class="refentry">
<a name="ClutterShaderEffect"></a><div class="titlepage"></div>
<div class="refnamediv"><table width="100%"><tr>
<td valign="top">
<h2><span class="refentrytitle"><a name="ClutterShaderEffect.top_of_page"></a>ClutterShaderEffect</span></h2>
<p>ClutterShaderEffect — Base class for shader effects</p>
</td>
<td class="gallery_image" valign="top" align="right"></td>
</tr></table></div>
<div class="refsect1">
<a name="ClutterShaderEffect.functions"></a><h2>Functions</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="functions_return">
<col class="functions_name">
</colgroup>
<tbody>
<tr>
<td class="function_type">
<a class="link" href="ClutterEffect.html" title="ClutterEffect"><span class="returnvalue">ClutterEffect</span></a> *
</td>
<td class="function_name">
<a class="link" href="ClutterShaderEffect.html#clutter-shader-effect-new" title="clutter_shader_effect_new ()">clutter_shader_effect_new</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform" title="clutter_shader_effect_set_uniform ()">clutter_shader_effect_set_uniform</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">void</span>
</td>
<td class="function_name">
<a class="link" href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform-value" title="clutter_shader_effect_set_uniform_value ()">clutter_shader_effect_set_uniform_value</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">gboolean</span>
</td>
<td class="function_name">
<a class="link" href="ClutterShaderEffect.html#clutter-shader-effect-set-shader-source" title="clutter_shader_effect_set_shader_source ()">clutter_shader_effect_set_shader_source</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">CoglHandle</span>
</td>
<td class="function_name">
<a class="link" href="ClutterShaderEffect.html#clutter-shader-effect-get-program" title="clutter_shader_effect_get_program ()">clutter_shader_effect_get_program</a> <span class="c_punctuation">()</span>
</td>
</tr>
<tr>
<td class="function_type">
<span class="returnvalue">CoglHandle</span>
</td>
<td class="function_name">
<a class="link" href="ClutterShaderEffect.html#clutter-shader-effect-get-shader" title="clutter_shader_effect_get_shader ()">clutter_shader_effect_get_shader</a> <span class="c_punctuation">()</span>
</td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="ClutterShaderEffect.properties"></a><h2>Properties</h2>
<div class="informaltable"><table class="informaltable" border="0">
<colgroup>
<col width="150px" class="properties_type">
<col width="300px" class="properties_name">
<col width="200px" class="properties_flags">
</colgroup>
<tbody><tr>
<td class="property_type"><a class="link" href="ClutterShaderEffect.html#ClutterShaderType" title="enum ClutterShaderType"><span class="type">ClutterShaderType</span></a></td>
<td class="property_name"><a class="link" href="ClutterShaderEffect.html#ClutterShaderEffect--shader-type" title="The “shader-type” property">shader-type</a></td>
<td class="property_flags">Write / Construct Only</td>
</tr></tbody>
</table></div>
</div>
<div class="refsect1">
<a name="ClutterShaderEffect.other"></a><h2>Types and Values</h2>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="name">
<col class="description">
</colgroup>
<tbody>
<tr>
<td class="datatype_keyword">enum</td>
<td class="function_name"><a class="link" href="ClutterShaderEffect.html#ClutterShaderType" title="enum ClutterShaderType">ClutterShaderType</a></td>
</tr>
<tr>
<td class="datatype_keyword">struct</td>
<td class="function_name"><a class="link" href="ClutterShaderEffect.html#ClutterShaderEffect-struct" title="struct ClutterShaderEffect">ClutterShaderEffect</a></td>
</tr>
<tr>
<td class="datatype_keyword">struct</td>
<td class="function_name"><a class="link" href="ClutterShaderEffect.html#ClutterShaderEffectClass" title="struct ClutterShaderEffectClass">ClutterShaderEffectClass</a></td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect1">
<a name="ClutterShaderEffect.object-hierarchy"></a><h2>Object Hierarchy</h2>
<pre class="screen">    GObject
    <span class="lineart">╰──</span> GInitiallyUnowned
        <span class="lineart">╰──</span> <a class="link" href="ClutterActorMeta.html" title="ClutterActorMeta">ClutterActorMeta</a>
            <span class="lineart">╰──</span> <a class="link" href="ClutterEffect.html" title="ClutterEffect">ClutterEffect</a>
                <span class="lineart">╰──</span> <a class="link" href="ClutterOffscreenEffect.html" title="ClutterOffscreenEffect">ClutterOffscreenEffect</a>
                    <span class="lineart">╰──</span> ClutterShaderEffect
</pre>
</div>
<div class="refsect1">
<a name="ClutterShaderEffect.description"></a><h2>Description</h2>
<p><a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> is a class that implements all the plumbing for
creating <a class="link" href="ClutterEffect.html" title="ClutterEffect"><span class="type">ClutterEffect</span></a>s using GLSL shaders.</p>
<p><a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> 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.</p>
<p><a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> is available since Clutter 1.4</p>
<div class="refsect3">
<a name="id-1.5.7.3.7.5"></a><h4>Implementing a ClutterShaderEffect</h4>
<p>Creating a sub-class of <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> requires the
overriding of the <a class="link" href="ClutterOffscreenEffect.html#ClutterOffscreenEffectClass.paint-target"><code class="function">ClutterOffscreenEffectClass.paint_target()</code></a> virtual
function from the <a class="link" href="ClutterOffscreenEffect.html" title="ClutterOffscreenEffect"><span class="type">ClutterOffscreenEffect</span></a> class. It is also convenient
to implement the <a class="link" href="ClutterShaderEffect.html#ClutterShaderEffectClass.get-static-shader-source"><code class="function">ClutterShaderEffectClass.get_static_shader_source()</code></a>
virtual function in case you are planning to create more than one
instance of the effect.</p>
<p>The <a class="link" href="ClutterShaderEffect.html#ClutterShaderEffectClass.get-static-shader-source"><code class="function">ClutterShaderEffectClass.get_static_shader_source()</code></a>
function should return a copy of the shader source to use. This
function is only called once per subclass of <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a>
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
<code class="function">g_strdup()</code>.</p>
<p>The <a class="link" href="ClutterOffscreenEffect.html#ClutterOffscreenEffectClass.paint-target"><code class="function">ClutterOffscreenEffectClass.paint_target()</code></a> should set the
shader's uniforms if any. This is done by calling
<a class="link" href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform-value" title="clutter_shader_effect_set_uniform_value ()"><code class="function">clutter_shader_effect_set_uniform_value()</code></a> or
<a class="link" href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform" title="clutter_shader_effect_set_uniform ()"><code class="function">clutter_shader_effect_set_uniform()</code></a>. The sub-class should then
chain up to the <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> implementation.</p>
</div>
<div class="refsect3">
<a name="id-1.5.7.3.7.6"></a><h4>Setting uniforms on a ClutterShaderEffect</h4>
<p>The example below shows a typical implementation of the
<a class="link" href="ClutterShaderEffect.html#ClutterShaderEffectClass.get-static-shader-source"><code class="function">ClutterShaderEffectClass.get_static_shader_source()</code></a> and
<a class="link" href="ClutterOffscreenEffect.html#ClutterOffscreenEffectClass.paint-target"><code class="function">ClutterOffscreenEffectClass.paint_target()</code></a> virtual functions
for a <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> subclass.</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="keyword">static</span><span class="normal"> gchar </span><span class="symbol">*</span>
<span class="function">my_effect_get_static_shader_source</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">ClutterShaderEffect</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">effect</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">  </span><span class="comment">// shader_source is set elsewhere</span>
<span class="normal">  </span><span class="keyword">return</span><span class="normal"> </span><span class="function">g_strdup</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">shader_source</span><span class="symbol">);</span>
<span class="cbracket">}</span>

<span class="keyword">static</span><span class="normal"> gboolean</span>
<span class="function">my_effect_paint_target</span><span class="normal"> </span><span class="symbol">(</span><span class="usertype">ClutterOffscreenEffect</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">effect</span><span class="symbol">)</span>
<span class="cbracket">{</span>
<span class="normal">  </span><span class="usertype">MyEffect</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">self </span><span class="symbol">=</span><span class="normal"> </span><span class="function">MY_EFFECT</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">effect</span><span class="symbol">);</span>
<span class="normal">  </span><span class="usertype">ClutterShaderEffect</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">shader </span><span class="symbol">=</span><span class="normal"> </span><span class="function">CLUTTER_SHADER_EFFECT</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">effect</span><span class="symbol">);</span>
<span class="normal">  </span><span class="usertype">ClutterEffectClass</span><span class="normal"> </span><span class="symbol">*</span><span class="normal">parent_class</span><span class="symbol">;</span>
<span class="normal">  </span><span class="usertype">gfloat</span><span class="normal"> component_r</span><span class="symbol">,</span><span class="normal"> component_g</span><span class="symbol">,</span><span class="normal"> component_b</span><span class="symbol">;</span>

<span class="normal">  </span><span class="comment">// the "tex" uniform is declared in the shader as:</span>
<span class="normal">  </span><span class="comment">//</span>
<span class="normal">  </span><span class="comment">//   uniform int tex;</span>
<span class="normal">  </span><span class="comment">//</span>
<span class="normal">  </span><span class="comment">// and it is passed a constant value of 0</span>
<span class="normal">  </span><span class="function"><a href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform">clutter_shader_effect_set_uniform</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">shader</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"tex"</span><span class="symbol">,</span><span class="normal"> G_TYPE_INT</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span><span class="normal"> </span><span class="number">0</span><span class="symbol">);</span>

<span class="normal">  </span><span class="comment">// the "component" uniform is declared in the shader as:</span>
<span class="normal">  </span><span class="comment">//</span>
<span class="normal">  </span><span class="comment">//   uniform vec3 component;</span>
<span class="normal">  </span><span class="comment">//</span>
<span class="normal">  </span><span class="comment">// and it's defined to contain the normalized components</span>
<span class="normal">  </span><span class="comment">// of a #ClutterColor</span>
<span class="normal">  component_r </span><span class="symbol">=</span><span class="normal"> self</span><span class="symbol">-&gt;</span><span class="normal">color</span><span class="symbol">.</span><span class="normal">red   </span><span class="symbol">/</span><span class="normal"> </span><span class="number">255</span><span class="symbol">.</span><span class="normal">0f</span><span class="symbol">;</span>
<span class="normal">  component_g </span><span class="symbol">=</span><span class="normal"> self</span><span class="symbol">-&gt;</span><span class="normal">color</span><span class="symbol">.</span><span class="normal">green </span><span class="symbol">/</span><span class="normal"> </span><span class="number">255</span><span class="symbol">.</span><span class="normal">0f</span><span class="symbol">;</span>
<span class="normal">  component_b </span><span class="symbol">=</span><span class="normal"> self</span><span class="symbol">-&gt;</span><span class="normal">color</span><span class="symbol">.</span><span class="normal">blue  </span><span class="symbol">/</span><span class="normal"> </span><span class="number">255</span><span class="symbol">.</span><span class="normal">0f</span><span class="symbol">;</span>
<span class="normal">  </span><span class="function"><a href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform">clutter_shader_effect_set_uniform</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">shader</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"component"</span><span class="symbol">,</span>
<span class="normal">                                     G_TYPE_FLOAT</span><span class="symbol">,</span><span class="normal"> </span><span class="number">3</span><span class="symbol">,</span>
<span class="normal">                                     component_r</span><span class="symbol">,</span>
<span class="normal">                                     component_g</span><span class="symbol">,</span>
<span class="normal">                                     component_b</span><span class="symbol">);</span>

<span class="normal">  </span><span class="comment">// chain up to the parent's implementation</span>
<span class="normal">  parent_class </span><span class="symbol">=</span><span class="normal"> </span><span class="function">CLUTTER_OFFSCREEN_EFFECT_CLASS</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">my_effect_parent_class</span><span class="symbol">);</span>
<span class="normal">  </span><span class="keyword">return</span><span class="normal"> parent_class</span><span class="symbol">-&gt;</span><span class="function">paint_target</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">effect</span><span class="symbol">);</span>
<span class="cbracket">}</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
</div>
</div>
<div class="refsect1">
<a name="ClutterShaderEffect.functions_details"></a><h2>Functions</h2>
<div class="refsect2">
<a name="clutter-shader-effect-new"></a><h3>clutter_shader_effect_new ()</h3>
<pre class="programlisting"><a class="link" href="ClutterEffect.html" title="ClutterEffect"><span class="returnvalue">ClutterEffect</span></a> *
clutter_shader_effect_new (<em class="parameter"><code><a class="link" href="ClutterShaderEffect.html#ClutterShaderType" title="enum ClutterShaderType"><span class="type">ClutterShaderType</span></a> shader_type</code></em>);</pre>
<p>Creates a new <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a>, to be applied to an actor using
<a class="link" href="ClutterActor.html#clutter-actor-add-effect" title="clutter_actor_add_effect ()"><code class="function">clutter_actor_add_effect()</code></a>.</p>
<p>The effect will be empty until <a class="link" href="ClutterShaderEffect.html#clutter-shader-effect-set-shader-source" title="clutter_shader_effect_set_shader_source ()"><code class="function">clutter_shader_effect_set_shader_source()</code></a>
is called.</p>
<div class="refsect3">
<a name="clutter-shader-effect-new.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>shader_type</p></td>
<td class="parameter_description"><p>the type of the shader, either <a class="link" href="ClutterShaderEffect.html#CLUTTER-FRAGMENT-SHADER:CAPS"><code class="literal">CLUTTER_FRAGMENT_SHADER</code></a>,
or <a class="link" href="ClutterShaderEffect.html#CLUTTER-VERTEX-SHADER:CAPS"><code class="literal">CLUTTER_VERTEX_SHADER</code></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="clutter-shader-effect-new.returns"></a><h4>Returns</h4>
<p> the newly created <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a>.
Use <code class="function">g_object_unref()</code> when done.</p>
</div>
<p class="since">Since: <a class="link" href="ix11.html#api-index-1.8">1.8</a></p>
</div>
<hr>
<div class="refsect2">
<a name="clutter-shader-effect-set-uniform"></a><h3>clutter_shader_effect_set_uniform ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
clutter_shader_effect_set_uniform (<em class="parameter"><code><a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> *effect</code></em>,
                                   <em class="parameter"><code>const <span class="type">gchar</span> *name</code></em>,
                                   <em class="parameter"><code><span class="type">GType</span> gtype</code></em>,
                                   <em class="parameter"><code><span class="type">gsize</span> n_values</code></em>,
                                   <em class="parameter"><code>...</code></em>);</pre>
<p>Sets a list of values as the payload for the uniform <em class="parameter"><code>name</code></em>
 inside
the shader effect</p>
<p>The <em class="parameter"><code>gtype</code></em>
 must be one of: <code class="literal">G_TYPE_INT</code>, for 1 or more integer values;
<code class="literal">G_TYPE_FLOAT</code>, for 1 or more floating point values;
<code class="literal">CLUTTER_TYPE_SHADER_INT</code>, for a pointer to an array of integer values;
<code class="literal">CLUTTER_TYPE_SHADER_FLOAT</code>, for a pointer to an array of floating point
values; and <code class="literal">CLUTTER_TYPE_SHADER_MATRIX</code>, for a pointer to an array of
floating point values mapping a matrix</p>
<p>The number of values interepreted is defined by the <em class="parameter"><code>n_value</code></em>

argument, and by the <em class="parameter"><code>gtype</code></em>
 argument. For instance, a uniform named
"sampler0" and containing a single integer value is set using:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function"><a href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform">clutter_shader_effect_set_uniform</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">effect</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"sampler0"</span><span class="symbol">,</span>
<span class="normal">                                   G_TYPE_INT</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span>
<span class="normal">                                   </span><span class="number">0</span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p>While a uniform named "components" and containing a 3-elements vector
of floating point values (a "vec3") can be set using:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5
6
7</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="usertype">gfloat</span><span class="normal"> component_r</span><span class="symbol">,</span><span class="normal"> component_g</span><span class="symbol">,</span><span class="normal"> component_b</span><span class="symbol">;</span>

<span class="function"><a href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform">clutter_shader_effect_set_uniform</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">effect</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"components"</span><span class="symbol">,</span>
<span class="normal">                                   G_TYPE_FLOAT</span><span class="symbol">,</span><span class="normal"> </span><span class="number">3</span><span class="symbol">,</span>
<span class="normal">                                   component_r</span><span class="symbol">,</span>
<span class="normal">                                   component_g</span><span class="symbol">,</span>
<span class="normal">                                   component_b</span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p>or can be set using:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3
4
5</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="usertype">gfloat</span><span class="normal"> component_vec</span><span class="symbol">[</span><span class="number">3</span><span class="symbol">];</span>

<span class="function"><a href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform">clutter_shader_effect_set_uniform</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">effect</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"components"</span><span class="symbol">,</span>
<span class="normal">                                   CLUTTER_TYPE_SHADER_FLOAT</span><span class="symbol">,</span><span class="normal"> </span><span class="number">3</span><span class="symbol">,</span>
<span class="normal">                                   component_vec</span><span class="symbol">);</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<p>Finally, a uniform named "map" and containing a matrix can be set using:</p>
<div class="informalexample">
  <table class="listing_frame" border="0" cellpadding="0" cellspacing="0">
    <tbody>
      <tr>
        <td class="listing_lines" align="right"><pre>1
2
3</pre></td>
        <td class="listing_code"><pre class="programlisting"><span class="function"><a href="ClutterShaderEffect.html#clutter-shader-effect-set-uniform">clutter_shader_effect_set_uniform</a></span><span class="normal"> </span><span class="symbol">(</span><span class="normal">effect</span><span class="symbol">,</span><span class="normal"> </span><span class="string">"map"</span><span class="symbol">,</span>
<span class="normal">                                   CLUTTER_TYPE_SHADER_MATRIX</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span>
<span class="normal">                                   </span><span class="function">cogl_matrix_get_array</span><span class="normal"> </span><span class="symbol">(&amp;</span><span class="normal">matrix</span><span class="symbol">));</span></pre></td>
      </tr>
    </tbody>
  </table>
</div>

<p></p>
<div class="refsect3">
<a name="clutter-shader-effect-set-uniform.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>effect</p></td>
<td class="parameter_description"><p>a <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>name</p></td>
<td class="parameter_description"><p>the name of the uniform to set</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>gtype</p></td>
<td class="parameter_description"><p>the type of the uniform to set</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>n_values</p></td>
<td class="parameter_description"><p>the number of values</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>...</p></td>
<td class="parameter_description"><p>a list of values</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="ix09.html#api-index-1.4">1.4</a></p>
</div>
<hr>
<div class="refsect2">
<a name="clutter-shader-effect-set-uniform-value"></a><h3>clutter_shader_effect_set_uniform_value ()</h3>
<pre class="programlisting"><span class="returnvalue">void</span>
clutter_shader_effect_set_uniform_value
                               (<em class="parameter"><code><a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> *effect</code></em>,
                                <em class="parameter"><code>const <span class="type">gchar</span> *name</code></em>,
                                <em class="parameter"><code>const <span class="type">GValue</span> *value</code></em>);</pre>
<p>Sets <em class="parameter"><code>value</code></em>
 as the payload for the uniform <em class="parameter"><code>name</code></em>
 inside the shader
effect</p>
<p>The <span class="type">GType</span> of the <em class="parameter"><code>value</code></em>
 must be one of: <code class="literal">G_TYPE_INT</code>, for a single
integer value; <code class="literal">G_TYPE_FLOAT</code>, for a single floating point value;
<code class="literal">CLUTTER_TYPE_SHADER_INT</code>, for an array of integer values;
<code class="literal">CLUTTER_TYPE_SHADER_FLOAT</code>, for an array of floating point values;
and <code class="literal">CLUTTER_TYPE_SHADER_MATRIX</code>, for a matrix of floating point
values. It also accepts <code class="literal">G_TYPE_DOUBLE</code> for compatibility with other
languages than C.</p>
<div class="refsect3">
<a name="clutter-shader-effect-set-uniform-value.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>effect</p></td>
<td class="parameter_description"><p>a <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>name</p></td>
<td class="parameter_description"><p>the name of the uniform to set</p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>value</p></td>
<td class="parameter_description"><p>a <span class="type">GValue</span> with the value of the uniform to set</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="ix09.html#api-index-1.4">1.4</a></p>
</div>
<hr>
<div class="refsect2">
<a name="clutter-shader-effect-set-shader-source"></a><h3>clutter_shader_effect_set_shader_source ()</h3>
<pre class="programlisting"><span class="returnvalue">gboolean</span>
clutter_shader_effect_set_shader_source
                               (<em class="parameter"><code><a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> *effect</code></em>,
                                <em class="parameter"><code>const <span class="type">gchar</span> *source</code></em>);</pre>
<p>Sets the source of the GLSL shader used by <em class="parameter"><code>effect</code></em>
</p>
<p>This function should only be called by implementations of
the <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> class, and not by application code.</p>
<p>This function can only be called once; subsequent calls will
yield no result.</p>
<div class="refsect3">
<a name="clutter-shader-effect-set-shader-source.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody>
<tr>
<td class="parameter_name"><p>effect</p></td>
<td class="parameter_description"><p>a <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr>
<tr>
<td class="parameter_name"><p>source</p></td>
<td class="parameter_description"><p>the source of a GLSL shader</p></td>
<td class="parameter_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<div class="refsect3">
<a name="clutter-shader-effect-set-shader-source.returns"></a><h4>Returns</h4>
<p> <code class="literal">TRUE</code> if the source was set</p>
</div>
<p class="since">Since: <a class="link" href="ix09.html#api-index-1.4">1.4</a></p>
</div>
<hr>
<div class="refsect2">
<a name="clutter-shader-effect-get-program"></a><h3>clutter_shader_effect_get_program ()</h3>
<pre class="programlisting"><span class="returnvalue">CoglHandle</span>
clutter_shader_effect_get_program (<em class="parameter"><code><a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> *effect</code></em>);</pre>
<p>Retrieves a pointer to the program's handle</p>
<div class="refsect3">
<a name="clutter-shader-effect-get-program.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>effect</p></td>
<td class="parameter_description"><p>a <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="clutter-shader-effect-get-program.returns"></a><h4>Returns</h4>
<p> a pointer to the program's handle,
or <code class="literal">COGL_INVALID_HANDLE</code>. </p>
<p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="ix09.html#api-index-1.4">1.4</a></p>
</div>
<hr>
<div class="refsect2">
<a name="clutter-shader-effect-get-shader"></a><h3>clutter_shader_effect_get_shader ()</h3>
<pre class="programlisting"><span class="returnvalue">CoglHandle</span>
clutter_shader_effect_get_shader (<em class="parameter"><code><a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> *effect</code></em>);</pre>
<p>Retrieves a pointer to the shader's handle</p>
<div class="refsect3">
<a name="clutter-shader-effect-get-shader.parameters"></a><h4>Parameters</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="150px" class="parameters_name">
<col class="parameters_description">
<col width="200px" class="parameters_annotations">
</colgroup>
<tbody><tr>
<td class="parameter_name"><p>effect</p></td>
<td class="parameter_description"><p>a <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a></p></td>
<td class="parameter_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<div class="refsect3">
<a name="clutter-shader-effect-get-shader.returns"></a><h4>Returns</h4>
<p> a pointer to the shader's handle,
or <code class="literal">COGL_INVALID_HANDLE</code>. </p>
<p><span class="annotation">[<acronym title="Don't free data after the code is done."><span class="acronym">transfer none</span></acronym>]</span></p>
</div>
<p class="since">Since: <a class="link" href="ix09.html#api-index-1.4">1.4</a></p>
</div>
</div>
<div class="refsect1">
<a name="ClutterShaderEffect.other_details"></a><h2>Types and Values</h2>
<div class="refsect2">
<a name="ClutterShaderType"></a><h3>enum ClutterShaderType</h3>
<p>The type of GLSL shader program</p>
<div class="refsect3">
<a name="ClutterShaderType.members"></a><h4>Members</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="300px" class="enum_members_name">
<col class="enum_members_description">
<col width="200px" class="enum_members_annotations">
</colgroup>
<tbody>
<tr>
<td class="enum_member_name"><p><a name="CLUTTER-VERTEX-SHADER:CAPS"></a>CLUTTER_VERTEX_SHADER</p></td>
<td class="enum_member_description">
<p>a vertex shader</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
<tr>
<td class="enum_member_name"><p><a name="CLUTTER-FRAGMENT-SHADER:CAPS"></a>CLUTTER_FRAGMENT_SHADER</p></td>
<td class="enum_member_description">
<p>a fragment shader</p>
</td>
<td class="enum_member_annotations"> </td>
</tr>
</tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="ix09.html#api-index-1.4">1.4</a></p>
</div>
<hr>
<div class="refsect2">
<a name="ClutterShaderEffect-struct"></a><h3>struct ClutterShaderEffect</h3>
<pre class="programlisting">struct ClutterShaderEffect;</pre>
<p>The <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> structure contains
only private data and should be accessed using the provided API</p>
<p class="since">Since: <a class="link" href="ix09.html#api-index-1.4">1.4</a></p>
</div>
<hr>
<div class="refsect2">
<a name="ClutterShaderEffectClass"></a><h3>struct ClutterShaderEffectClass</h3>
<pre class="programlisting">struct ClutterShaderEffectClass {
  gchar * (* get_static_shader_source) (ClutterShaderEffect *effect);
};
</pre>
<p>The <a class="link" href="ClutterShaderEffect.html#ClutterShaderEffectClass" title="struct ClutterShaderEffectClass"><span class="type">ClutterShaderEffectClass</span></a> structure contains
only private data</p>
<div class="refsect3">
<a name="ClutterShaderEffectClass.members"></a><h4>Members</h4>
<div class="informaltable"><table class="informaltable" width="100%" border="0">
<colgroup>
<col width="300px" class="struct_members_name">
<col class="struct_members_description">
<col width="200px" class="struct_members_annotations">
</colgroup>
<tbody><tr>
<td class="struct_member_name"><p><em class="structfield"><code><a name="ClutterShaderEffectClass.get-static-shader-source"></a>get_static_shader_source</code></em> ()</p></td>
<td class="struct_member_description"><p>Returns the GLSL source code to use for
instances of this shader effect. Note that this function is only
called once per subclass of <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a> regardless of how
many instances are used. It is expected that subclasses will return
a copy of a static string from this function.</p></td>
<td class="struct_member_annotations"> </td>
</tr></tbody>
</table></div>
</div>
<p class="since">Since: <a class="link" href="ix09.html#api-index-1.4">1.4</a></p>
</div>
</div>
<div class="refsect1">
<a name="ClutterShaderEffect.property-details"></a><h2>Property Details</h2>
<div class="refsect2">
<a name="ClutterShaderEffect--shader-type"></a><h3>The <code class="literal">“shader-type”</code> property</h3>
<pre class="programlisting">  “shader-type”              <a class="link" href="ClutterShaderEffect.html#ClutterShaderType" title="enum ClutterShaderType"><span class="type">ClutterShaderType</span></a></pre>
<p>The type of shader that is used by the effect. This property
should be set by the constructor of <a class="link" href="ClutterShaderEffect.html" title="ClutterShaderEffect"><span class="type">ClutterShaderEffect</span></a>
sub-classes.</p>
<p>Flags: Write / Construct Only</p>
<p>Default value: CLUTTER_FRAGMENT_SHADER</p>
<p class="since">Since: <a class="link" href="ix09.html#api-index-1.4">1.4</a></p>
</div>
</div>
<div class="refsect1">
<a name="ClutterShaderEffect.see-also"></a><h2>See Also</h2>
<p><a class="link" href="ClutterEffect.html" title="ClutterEffect"><span class="type">ClutterEffect</span></a>, <a class="link" href="ClutterOffscreenEffect.html" title="ClutterOffscreenEffect"><span class="type">ClutterOffscreenEffect</span></a></p>
</div>
</div>
<div class="footer">
<hr>Generated by GTK-Doc V1.25.1</div>
</body>
</html>