2007-12-03 11:29:18 -05:00
|
|
|
#include <clutter/clutter.h>
|
|
|
|
|
|
|
|
#include <errno.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <glib.h>
|
2008-11-07 14:32:28 -05:00
|
|
|
#include <gmodule.h>
|
2007-12-03 11:29:18 -05:00
|
|
|
|
2008-02-07 11:52:12 -05:00
|
|
|
/* Dynamic branching appeared in "Shader Model 3.0" that low-end IGPs
|
|
|
|
* don't support.
|
|
|
|
*/
|
|
|
|
#define GPU_SUPPORTS_DYNAMIC_BRANCHING 0
|
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
typedef struct
|
|
|
|
{
|
|
|
|
gchar *name;
|
|
|
|
gchar *source;
|
|
|
|
} ShaderSource;
|
|
|
|
|
2008-03-10 19:07:22 -04:00
|
|
|
/* a couple of boilerplate defines that are common amongst all the
|
|
|
|
* sample shaders
|
|
|
|
*/
|
|
|
|
|
2008-03-10 19:09:28 -04:00
|
|
|
/* FRAGMENT_SHADER_BEGIN: generate boilerplate with a local vec4 color already
|
2008-06-06 11:00:12 -04:00
|
|
|
* initialized, from a sampler2D in a variable tex.
|
2008-03-10 19:07:22 -04:00
|
|
|
*/
|
2008-06-06 11:41:52 -04:00
|
|
|
#define FRAGMENT_SHADER_VARS \
|
2008-06-06 11:00:12 -04:00
|
|
|
"uniform sampler2D tex;" \
|
|
|
|
"uniform float x_step, y_step;" \
|
2008-06-06 11:41:52 -04:00
|
|
|
|
|
|
|
#define FRAGMENT_SHADER_BEGIN \
|
2008-06-06 11:00:12 -04:00
|
|
|
"void main (){" \
|
2010-07-23 12:46:41 -04:00
|
|
|
" vec4 color = texture2D (tex, vec2(cogl_tex_coord_in[0]));"
|
2008-03-10 19:07:22 -04:00
|
|
|
|
2008-03-10 19:09:28 -04:00
|
|
|
/* FRAGMENT_SHADER_END: apply the changed color to the output buffer correctly
|
|
|
|
* blended with the gl specified color (makes the opacity of actors work
|
|
|
|
* correctly).
|
2008-03-10 19:07:22 -04:00
|
|
|
*/
|
|
|
|
#define FRAGMENT_SHADER_END \
|
|
|
|
" gl_FragColor = color;" \
|
2010-07-23 12:46:41 -04:00
|
|
|
" gl_FragColor = gl_FragColor * cogl_color_in;" \
|
2008-03-10 19:07:22 -04:00
|
|
|
"}"
|
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
static ShaderSource shaders[]=
|
|
|
|
{
|
|
|
|
{"brightness-contrast",
|
2008-06-06 11:41:52 -04:00
|
|
|
FRAGMENT_SHADER_VARS
|
2008-03-10 19:07:22 -04:00
|
|
|
"uniform float brightness, contrast;"
|
|
|
|
FRAGMENT_SHADER_BEGIN
|
2009-06-24 07:04:55 -04:00
|
|
|
" color.rgb /= color.a;"
|
2008-03-10 19:09:28 -04:00
|
|
|
" color.rgb = (color.rgb - vec3(0.5, 0.5, 0.5)) * contrast + "
|
|
|
|
"vec3 (brightness + 0.5, brightness + 0.5, brightness + 0.5);"
|
2009-06-24 07:04:55 -04:00
|
|
|
" color.rgb *= color.a;"
|
2008-03-10 19:07:22 -04:00
|
|
|
FRAGMENT_SHADER_END
|
2007-12-03 11:29:18 -05:00
|
|
|
},
|
2008-03-10 19:07:22 -04:00
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
{"box-blur",
|
2008-06-06 11:41:52 -04:00
|
|
|
FRAGMENT_SHADER_VARS
|
|
|
|
|
2008-02-07 11:52:12 -05:00
|
|
|
#if GPU_SUPPORTS_DYNAMIC_BRANCHING
|
2008-03-10 19:07:22 -04:00
|
|
|
"uniform float radius;"
|
|
|
|
FRAGMENT_SHADER_BEGIN
|
|
|
|
"float u, v;"
|
|
|
|
"int count = 1;"
|
|
|
|
"for (u=-radius;u<radius;u++)"
|
|
|
|
" for (v=-radius;v<radius;v++)"
|
|
|
|
" {"
|
2008-06-06 11:00:12 -04:00
|
|
|
" color += texture2D(tex, "
|
2010-07-23 12:46:41 -04:00
|
|
|
" vec2(cogl_tex_coord_in[0].s + u * 2.0 * x_step, "
|
|
|
|
" cogl_tex_coord_in[0].t + v * 2.0 * y_step));"
|
2008-03-10 19:07:22 -04:00
|
|
|
" count ++;"
|
|
|
|
" }"
|
|
|
|
"color = color / float(count);"
|
|
|
|
FRAGMENT_SHADER_END
|
2008-02-07 11:52:12 -05:00
|
|
|
#else
|
2008-06-06 11:00:12 -04:00
|
|
|
"vec4 get_rgba_rel(sampler2D tex, float dx, float dy)"
|
2008-03-10 19:07:22 -04:00
|
|
|
"{"
|
2010-07-23 12:46:41 -04:00
|
|
|
" return texture2D (tex, cogl_tex_coord_in[0].st "
|
2008-06-06 11:00:12 -04:00
|
|
|
" + vec2(dx, dy) * 2.0);"
|
2008-03-10 19:07:22 -04:00
|
|
|
"}"
|
|
|
|
|
|
|
|
FRAGMENT_SHADER_BEGIN
|
|
|
|
" float count = 1.0;"
|
2008-06-06 11:00:12 -04:00
|
|
|
" color += get_rgba_rel (tex, -x_step, -y_step); count++;"
|
|
|
|
" color += get_rgba_rel (tex, -x_step, 0.0); count++;"
|
|
|
|
" color += get_rgba_rel (tex, -x_step, y_step); count++;"
|
|
|
|
" color += get_rgba_rel (tex, 0.0, -y_step); count++;"
|
|
|
|
" color += get_rgba_rel (tex, 0.0, 0.0); count++;"
|
|
|
|
" color += get_rgba_rel (tex, 0.0, y_step); count++;"
|
|
|
|
" color += get_rgba_rel (tex, x_step, -y_step); count++;"
|
|
|
|
" color += get_rgba_rel (tex, x_step, 0.0); count++;"
|
|
|
|
" color += get_rgba_rel (tex, x_step, y_step); count++;"
|
2008-03-10 19:07:22 -04:00
|
|
|
" color = color / count;"
|
|
|
|
FRAGMENT_SHADER_END
|
2008-02-07 11:52:12 -05:00
|
|
|
#endif
|
2007-12-03 11:29:18 -05:00
|
|
|
},
|
|
|
|
|
2008-03-10 19:07:22 -04:00
|
|
|
{"invert",
|
2008-06-06 11:41:52 -04:00
|
|
|
FRAGMENT_SHADER_VARS
|
2008-03-10 19:07:22 -04:00
|
|
|
FRAGMENT_SHADER_BEGIN
|
2009-06-24 07:04:55 -04:00
|
|
|
" color.rgb /= color.a;"
|
2008-03-10 19:07:22 -04:00
|
|
|
" color.rgb = vec3(1.0, 1.0, 1.0) - color.rgb;\n"
|
2009-06-24 07:04:55 -04:00
|
|
|
" color.rgb *= color.a;"
|
2008-03-10 19:07:22 -04:00
|
|
|
FRAGMENT_SHADER_END
|
2007-12-03 11:29:18 -05:00
|
|
|
},
|
|
|
|
|
2008-03-10 19:07:22 -04:00
|
|
|
{"brightness-contrast",
|
2008-06-06 11:41:52 -04:00
|
|
|
FRAGMENT_SHADER_VARS
|
2008-03-10 19:07:22 -04:00
|
|
|
"uniform float brightness;"
|
|
|
|
"uniform float contrast;"
|
|
|
|
FRAGMENT_SHADER_BEGIN
|
2009-06-24 07:04:55 -04:00
|
|
|
" color.rgb /= color.a;"
|
2008-03-10 19:07:22 -04:00
|
|
|
" color.r = (color.r - 0.5) * contrast + brightness + 0.5;"
|
|
|
|
" color.g = (color.g - 0.5) * contrast + brightness + 0.5;"
|
|
|
|
" color.b = (color.b - 0.5) * contrast + brightness + 0.5;"
|
2009-06-24 07:04:55 -04:00
|
|
|
" color.rgb *= color.a;"
|
2008-03-10 19:07:22 -04:00
|
|
|
FRAGMENT_SHADER_END
|
2007-12-03 11:29:18 -05:00
|
|
|
},
|
2008-03-10 19:07:22 -04:00
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
{"gray",
|
2008-06-06 11:41:52 -04:00
|
|
|
FRAGMENT_SHADER_VARS
|
2008-03-10 19:07:22 -04:00
|
|
|
FRAGMENT_SHADER_BEGIN
|
|
|
|
" float avg = (color.r + color.g + color.b) / 3.0;"
|
|
|
|
" color.r = avg;"
|
|
|
|
" color.g = avg;"
|
|
|
|
" color.b = avg;"
|
|
|
|
FRAGMENT_SHADER_END
|
2007-12-03 11:29:18 -05:00
|
|
|
},
|
2008-03-10 19:07:22 -04:00
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
{"combined-mirror",
|
2008-06-06 11:41:52 -04:00
|
|
|
FRAGMENT_SHADER_VARS
|
2008-03-10 19:07:22 -04:00
|
|
|
FRAGMENT_SHADER_BEGIN
|
2010-07-23 12:46:41 -04:00
|
|
|
" vec4 colorB = texture2D (tex, vec2(cogl_tex_coord_in[0].ts));"
|
2008-03-10 19:07:22 -04:00
|
|
|
" float avg = (color.r + color.g + color.b) / 3.0;"
|
|
|
|
" color.r = avg;"
|
|
|
|
" color.g = avg;"
|
|
|
|
" color.b = avg;"
|
|
|
|
" color = (color + colorB)/2.0;"
|
|
|
|
FRAGMENT_SHADER_END
|
2007-12-03 11:29:18 -05:00
|
|
|
},
|
2008-06-30 10:19:04 -04:00
|
|
|
|
|
|
|
{"edge-detect",
|
|
|
|
FRAGMENT_SHADER_VARS
|
|
|
|
"float get_avg_rel(sampler2D texB, float dx, float dy)"
|
|
|
|
"{"
|
2011-01-11 09:15:46 -05:00
|
|
|
" vec4 colorB = texture2D (texB, cogl_tex_coord_in[0].st + vec2(dx, dy));"
|
2008-06-30 10:19:04 -04:00
|
|
|
" return (colorB.r + colorB.g + colorB.b) / 3.0;"
|
|
|
|
"}"
|
|
|
|
FRAGMENT_SHADER_BEGIN
|
|
|
|
" mat3 sobel_h = mat3( 1.0, 2.0, 1.0,"
|
|
|
|
" 0.0, 0.0, 0.0,"
|
|
|
|
" -1.0, -2.0, -1.0);"
|
|
|
|
" mat3 sobel_v = mat3( 1.0, 0.0, -1.0,"
|
|
|
|
" 2.0, 0.0, -2.0,"
|
|
|
|
" 1.0, 0.0, -1.0);"
|
|
|
|
" mat3 map = mat3( get_avg_rel(tex, -x_step, -y_step),"
|
|
|
|
" get_avg_rel(tex, -x_step, 0.0),"
|
|
|
|
" get_avg_rel(tex, -x_step, y_step),"
|
|
|
|
" get_avg_rel(tex, 0.0, -y_step),"
|
|
|
|
" get_avg_rel(tex, 0.0, 0.0),"
|
|
|
|
" get_avg_rel(tex, 0.0, y_step),"
|
|
|
|
" get_avg_rel(tex, x_step, -y_step),"
|
|
|
|
" get_avg_rel(tex, x_step, 0.0),"
|
|
|
|
" get_avg_rel(tex, x_step, y_step) );"
|
|
|
|
" mat3 gh = sobel_h * map;"
|
|
|
|
" mat3 gv = map * sobel_v;"
|
|
|
|
" float avgh = (gh[0][0] + gh[0][1] + gh[0][2] +"
|
|
|
|
" gh[1][0] + gh[1][1] + gh[1][2] +"
|
|
|
|
" gh[2][0] + gh[2][1] + gh[2][2]) / 18.0 + 0.5;"
|
|
|
|
" float avgv = (gv[0][0] + gv[0][1] + gv[0][2] +"
|
|
|
|
" gv[1][0] + gv[1][1] + gv[1][2] +"
|
|
|
|
" gv[2][0] + gv[2][1] + gv[2][2]) / 18.0 + 0.5;"
|
|
|
|
" float avg = (avgh + avgv) / 2.0;"
|
|
|
|
" color.r = avg * color.r;"
|
|
|
|
" color.g = avg * color.g;"
|
|
|
|
" color.b = avg * color.b;"
|
|
|
|
FRAGMENT_SHADER_END
|
|
|
|
},
|
2008-03-10 19:07:22 -04:00
|
|
|
/* Terminating NULL sentinel */
|
2007-12-03 11:29:18 -05:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2007-12-11 09:49:41 -05:00
|
|
|
static gint shader_no = 0;
|
2007-12-03 11:29:18 -05:00
|
|
|
|
2010-02-05 11:22:09 -05:00
|
|
|
static int
|
|
|
|
next_p2 (gint a)
|
|
|
|
{
|
|
|
|
int rval = 1;
|
|
|
|
|
|
|
|
while (rval < a)
|
|
|
|
rval <<= 1;
|
|
|
|
|
|
|
|
return rval;
|
|
|
|
}
|
|
|
|
|
2008-06-06 11:41:52 -04:00
|
|
|
static void
|
|
|
|
set_shader_num (ClutterActor *actor, gint new_no)
|
2007-12-03 11:29:18 -05:00
|
|
|
{
|
2008-06-06 11:00:12 -04:00
|
|
|
int tex_width;
|
|
|
|
int tex_height;
|
2007-12-11 09:49:41 -05:00
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
if (new_no >= 0 && shaders[new_no].name)
|
|
|
|
{
|
|
|
|
ClutterShader *shader;
|
2007-12-11 09:49:41 -05:00
|
|
|
GError *error;
|
2007-12-03 11:29:18 -05:00
|
|
|
shader_no = new_no;
|
|
|
|
|
2007-12-11 09:49:41 -05:00
|
|
|
g_print ("setting shaders[%i] named '%s'\n",
|
|
|
|
shader_no,
|
|
|
|
shaders[shader_no].name);
|
|
|
|
|
|
|
|
shader = clutter_shader_new ();
|
2007-12-03 11:29:18 -05:00
|
|
|
|
2007-12-11 09:49:41 -05:00
|
|
|
error = NULL;
|
2008-03-10 19:09:28 -04:00
|
|
|
g_object_set (G_OBJECT (shader),
|
2009-05-31 10:15:46 -04:00
|
|
|
"fragment-source", shaders[shader_no].source,
|
|
|
|
NULL);
|
2007-12-11 09:49:41 -05:00
|
|
|
|
|
|
|
/* try to bind the shader, provoking an error we catch if there is issues
|
2008-03-10 19:09:28 -04:00
|
|
|
* with the shader sources we've provided. At a later stage it should be
|
|
|
|
* possible to iterate through a set of alternate shader sources (glsl ->
|
|
|
|
* asm -> cg?) and the one that succesfully compiles is used.
|
2007-12-11 09:49:41 -05:00
|
|
|
*/
|
2008-04-11 08:00:50 -04:00
|
|
|
clutter_shader_compile (shader, &error);
|
2007-12-11 09:49:41 -05:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_print ("unable to set shaders[%i] named '%s': %s",
|
|
|
|
shader_no, shaders[shader_no].name,
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
2008-02-04 06:45:12 -05:00
|
|
|
clutter_actor_set_shader (actor, NULL);
|
2007-12-11 09:49:41 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-02-04 06:45:12 -05:00
|
|
|
clutter_actor_set_shader (actor, NULL);
|
|
|
|
clutter_actor_set_shader (actor, shader);
|
2008-11-18 10:08:40 -05:00
|
|
|
clutter_actor_set_shader_param_int (actor, "tex", 0);
|
|
|
|
clutter_actor_set_shader_param_float (actor, "radius", 3.0);
|
|
|
|
clutter_actor_set_shader_param_float (actor, "brightness", 0.4);
|
|
|
|
clutter_actor_set_shader_param_float (actor, "contrast", -1.9);
|
2008-06-06 11:00:12 -04:00
|
|
|
|
|
|
|
if (CLUTTER_IS_TEXTURE (actor))
|
|
|
|
{
|
2010-02-05 11:22:09 -05:00
|
|
|
/* XXX - this assumes *a lot* about how things are done
|
|
|
|
* internally on *some* hardware and driver
|
|
|
|
*/
|
2008-06-06 11:00:12 -04:00
|
|
|
tex_width = clutter_actor_get_width (actor);
|
2010-02-05 11:22:09 -05:00
|
|
|
tex_width = next_p2 (tex_width);
|
|
|
|
|
2008-06-06 11:00:12 -04:00
|
|
|
tex_height = clutter_actor_get_height (actor);
|
2010-02-05 11:22:09 -05:00
|
|
|
tex_height = next_p2 (tex_height);
|
2008-06-06 11:00:12 -04:00
|
|
|
|
2008-11-18 10:08:40 -05:00
|
|
|
clutter_actor_set_shader_param_float (actor, "x_step",
|
|
|
|
1.0f / tex_width);
|
|
|
|
clutter_actor_set_shader_param_float (actor, "y_step",
|
|
|
|
1.0f / tex_height);
|
2008-06-06 11:00:12 -04:00
|
|
|
}
|
2007-12-11 09:49:41 -05:00
|
|
|
}
|
2010-07-22 12:27:04 -04:00
|
|
|
|
|
|
|
g_object_unref (shader);
|
2007-12-03 11:29:18 -05:00
|
|
|
}
|
2008-06-06 11:41:52 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
static gboolean
|
|
|
|
button_release_cb (ClutterActor *actor,
|
|
|
|
ClutterEvent *event,
|
|
|
|
gpointer data)
|
|
|
|
{
|
|
|
|
gint new_no;
|
|
|
|
|
|
|
|
if (event->button.button == 1)
|
|
|
|
{
|
|
|
|
new_no = shader_no - 1;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
new_no = shader_no + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
set_shader_num (actor, new_no);
|
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2010-06-08 17:54:26 -04:00
|
|
|
#ifdef COGL_HAS_GLES2
|
2008-06-06 11:41:52 -04:00
|
|
|
static gboolean
|
|
|
|
timeout_cb (gpointer data)
|
|
|
|
{
|
|
|
|
int new_no = shader_no + 1;
|
|
|
|
|
|
|
|
if (shaders[new_no].name == NULL)
|
|
|
|
new_no = 0;
|
|
|
|
|
|
|
|
set_shader_num (CLUTTER_ACTOR (data), new_no);
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
2010-06-08 17:54:26 -04:00
|
|
|
#endif /* COGL_HAS_GLES2 */
|
2007-12-03 11:29:18 -05:00
|
|
|
|
2008-11-07 14:32:28 -05:00
|
|
|
G_MODULE_EXPORT gint
|
|
|
|
test_shader_main (gint argc, gchar *argv[])
|
2007-12-03 11:29:18 -05:00
|
|
|
{
|
2009-11-05 12:30:33 -05:00
|
|
|
ClutterActor *actor;
|
|
|
|
ClutterActor *stage;
|
|
|
|
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
|
|
|
|
ClutterShader *shader;
|
|
|
|
GError *error;
|
|
|
|
gchar *file;
|
2007-12-06 05:58:42 -05:00
|
|
|
|
2011-02-21 19:19:35 -05:00
|
|
|
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
|
|
|
|
return 1;
|
2007-12-03 11:29:18 -05:00
|
|
|
|
2011-02-18 06:43:27 -05:00
|
|
|
stage = clutter_stage_new ();
|
|
|
|
clutter_stage_set_title (CLUTTER_STAGE (stage), "Shaders");
|
2007-12-03 11:29:18 -05:00
|
|
|
clutter_actor_set_size (stage, 512, 384);
|
2011-02-18 06:43:27 -05:00
|
|
|
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
|
2007-12-03 11:29:18 -05:00
|
|
|
|
2007-12-11 09:49:41 -05:00
|
|
|
g_print ("applying shaders[%i] named '%s'\n",
|
|
|
|
shader_no,
|
|
|
|
shaders[shader_no].name);
|
|
|
|
|
|
|
|
shader = clutter_shader_new ();
|
|
|
|
|
|
|
|
error = NULL;
|
2007-12-14 12:25:55 -05:00
|
|
|
clutter_shader_set_fragment_source (shader, shaders[shader_no].source, -1);
|
2008-04-11 08:00:50 -04:00
|
|
|
clutter_shader_compile (shader, &error);
|
2007-12-11 09:49:41 -05:00
|
|
|
if (error)
|
|
|
|
{
|
|
|
|
g_print ("unable to load shaders[%d] named '%s': %s\n",
|
|
|
|
shader_no,
|
|
|
|
shaders[shader_no].name,
|
|
|
|
error->message);
|
|
|
|
g_error_free (error);
|
|
|
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2007-12-03 11:29:18 -05:00
|
|
|
|
|
|
|
clutter_stage_set_title (CLUTTER_STAGE (stage), "Shader Test");
|
|
|
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
|
|
|
|
2009-11-05 12:30:33 -05:00
|
|
|
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
|
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
#ifndef TEST_GROUP
|
2009-11-05 12:30:33 -05:00
|
|
|
actor = clutter_texture_new_from_file (file, &error);
|
2008-04-25 09:37:36 -04:00
|
|
|
if (!actor)
|
|
|
|
g_error("pixbuf load failed: %s", error ? error->message : "Unknown");
|
2007-12-03 11:29:18 -05:00
|
|
|
#else
|
|
|
|
actor = clutter_group_new ();
|
2009-11-05 12:30:33 -05:00
|
|
|
|
|
|
|
{
|
|
|
|
ClutterActor *child1, *child2, *child3, *child4;
|
|
|
|
ClutterColor color = { 0xff, 0x22, 0x66, 0x99 };
|
|
|
|
|
|
|
|
child1 = clutter_texture_new_from_file (file, &error);
|
|
|
|
if (!child1)
|
|
|
|
g_error("pixbuf load failed: %s", error ? error->message : "Unknown");
|
|
|
|
|
|
|
|
child2 = clutter_texture_new_from_file (file, &error);
|
|
|
|
if (!child2)
|
|
|
|
g_error("pixbuf load failed: %s", error ? error->message : "Unknown");
|
|
|
|
|
|
|
|
child3 = clutter_rectangle_new ();
|
|
|
|
child4 = clutter_text_new_with_text ("Sans 20px", "Shady stuff");
|
|
|
|
|
|
|
|
clutter_rectangle_set_color (CLUTTER_RECTANGLE (child3), &color);
|
|
|
|
clutter_actor_set_size (child3, 50, 50);
|
|
|
|
|
|
|
|
clutter_actor_set_position (child1, 0, 0);
|
|
|
|
clutter_actor_set_position (child2, 50, 100);
|
|
|
|
clutter_actor_set_position (child3, 30, -30);
|
|
|
|
clutter_actor_set_position (child4, -50, 20);
|
|
|
|
|
|
|
|
clutter_container_add (CLUTTER_CONTAINER (actor),
|
|
|
|
child1,
|
|
|
|
child2,
|
|
|
|
child3,
|
|
|
|
child4,
|
|
|
|
NULL);
|
|
|
|
|
|
|
|
clutter_actor_show_all (actor);
|
|
|
|
}
|
|
|
|
#endif /* !TEST_GROUP */
|
|
|
|
|
|
|
|
g_free (file);
|
2007-12-11 09:49:41 -05:00
|
|
|
|
2008-02-04 06:45:12 -05:00
|
|
|
clutter_actor_set_shader (actor, shader);
|
2007-12-03 11:29:18 -05:00
|
|
|
clutter_actor_set_position (actor, 100, 100);
|
|
|
|
|
2010-07-22 12:27:04 -04:00
|
|
|
g_object_unref (shader);
|
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), actor);
|
|
|
|
|
2008-11-18 10:08:40 -05:00
|
|
|
clutter_actor_set_shader_param_int (actor, "tex", 0);
|
|
|
|
clutter_actor_set_shader_param_float (actor, "brightness", 0.4);
|
|
|
|
clutter_actor_set_shader_param_float (actor, "contrast", -1.9);
|
2007-12-03 11:29:18 -05:00
|
|
|
|
|
|
|
clutter_actor_set_reactive (actor, TRUE);
|
|
|
|
g_signal_connect (actor, "button-release-event",
|
|
|
|
G_CALLBACK (button_release_cb), NULL);
|
|
|
|
|
2010-06-08 17:54:26 -04:00
|
|
|
#ifdef COGL_HAS_GLES2
|
2008-06-06 11:41:52 -04:00
|
|
|
/* On an embedded platform it is difficult to right click so we will
|
|
|
|
cycle through the shaders automatically */
|
|
|
|
g_timeout_add_seconds (3, timeout_cb, actor);
|
|
|
|
#endif
|
|
|
|
|
2007-12-03 11:29:18 -05:00
|
|
|
/* Show everying ( and map window ) */
|
|
|
|
clutter_actor_show_all (stage);
|
|
|
|
|
|
|
|
clutter_main ();
|
|
|
|
|
2007-12-11 09:49:41 -05:00
|
|
|
return EXIT_SUCCESS;
|
2007-12-03 11:29:18 -05:00
|
|
|
}
|