mirror of
https://github.com/brl/mutter.git
synced 2024-11-10 16:16:20 -05:00
99acb8e9c1
* clutter/cogl/cogl.h: Add cogl_fog_set() abstracting the glFog() functions and enabling the GL_FOG flag. * clutter/cogl/gl/cogl.c: Add GL implementation of cogl_fog_set(). * clutter/cogl/gles/cogl.c: Add GL/ES implementation of cogl_fog_set(). * clutter.symbols: Add new symbols. * clutter/clutter-stage.h: Add API to enable depth cueing on the stage using a linear GL fog, and to set the parameters for it (#637). * clutter/clutter-stage.c (clutter_stage_paint): Enable the GL fog if the ClutterStage:use-fog property is true. * tests/test-depth.c: Test the new stage API.
101 lines
2.7 KiB
C
101 lines
2.7 KiB
C
#include <stdlib.h>
|
|
#include <clutter/clutter.h>
|
|
|
|
static gboolean zoom_in = TRUE;
|
|
static ClutterBehaviour *d_behave = NULL;
|
|
|
|
static void
|
|
timeline_completed (ClutterTimeline *timeline,
|
|
gpointer user_data)
|
|
{
|
|
gint depth_start, depth_end;
|
|
|
|
if (zoom_in)
|
|
{
|
|
depth_start = 0;
|
|
depth_end = -500;
|
|
zoom_in = FALSE;
|
|
}
|
|
else
|
|
{
|
|
depth_start = -500;
|
|
depth_end = 0;
|
|
zoom_in = TRUE;
|
|
}
|
|
|
|
g_object_set (G_OBJECT (d_behave),
|
|
"depth-start", depth_start,
|
|
"depth-end", depth_end,
|
|
NULL);
|
|
|
|
clutter_timeline_rewind (timeline);
|
|
clutter_timeline_start (timeline);
|
|
}
|
|
|
|
int
|
|
main (int argc, char *argv[])
|
|
{
|
|
ClutterTimeline *timeline;
|
|
ClutterActor *stage;
|
|
ClutterActor *hand, *label, *rect;
|
|
ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
|
|
ClutterColor rect_color = { 0, 0, 0, 0x88 };
|
|
GdkPixbuf *pixbuf;
|
|
GError *error;
|
|
|
|
clutter_init (&argc, &argv);
|
|
|
|
error = NULL;
|
|
pixbuf = gdk_pixbuf_new_from_file ("redhand.png", &error);
|
|
if (error)
|
|
g_error ("Unable to load redhand.png: %s", error->message);
|
|
|
|
stage = clutter_stage_get_default ();
|
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
|
|
clutter_stage_set_use_fog (CLUTTER_STAGE (stage), TRUE);
|
|
|
|
g_signal_connect (stage,
|
|
"button-press-event", G_CALLBACK (clutter_main_quit),
|
|
NULL);
|
|
|
|
label = clutter_label_new_with_text ("Mono 26", "Clutter");
|
|
clutter_actor_set_position (label, 40, 140);
|
|
clutter_actor_show (label);
|
|
|
|
hand = clutter_texture_new_from_pixbuf (pixbuf);
|
|
clutter_actor_set_position (hand, 240, 140);
|
|
clutter_actor_show (hand);
|
|
|
|
rect = clutter_rectangle_new_with_color (&rect_color);
|
|
clutter_actor_set_position (rect, 440, 140);
|
|
clutter_actor_set_size (rect, 200, 200);
|
|
clutter_actor_show (rect);
|
|
|
|
clutter_container_add (CLUTTER_CONTAINER (stage), hand, label, rect, NULL);
|
|
|
|
/* 3 seconds, at 60 fps */
|
|
timeline = clutter_timeline_new (180, 60);
|
|
g_signal_connect (timeline,
|
|
"completed", G_CALLBACK (timeline_completed),
|
|
NULL);
|
|
|
|
d_behave = clutter_behaviour_depth_new (clutter_alpha_new_full (timeline,
|
|
CLUTTER_ALPHA_RAMP_INC,
|
|
NULL, NULL),
|
|
-500, 0);
|
|
clutter_behaviour_apply (d_behave, hand);
|
|
clutter_behaviour_apply (d_behave, label);
|
|
clutter_behaviour_apply (d_behave, rect);
|
|
|
|
clutter_actor_show (stage);
|
|
|
|
clutter_timeline_start (timeline);
|
|
|
|
clutter_main ();
|
|
|
|
g_object_unref (d_behave);
|
|
g_object_unref (timeline);
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|