summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Bragg <robert@linux.intel.com>2012-01-07 23:48:08 +0000
committerRobert Bragg <robert@linux.intel.com>2012-02-09 13:09:15 +0000
commit0365f6cda3df89335d243548053d85aaf66f1630 (patch)
treeb4734143819cb46b684fc6430eb47225d0a021f7
parent7287dd1fafd893bfed42242fc01eb4c20885e50b (diff)
downloadcogl-0365f6cda3df89335d243548053d85aaf66f1630.tar.gz
examples: use framebuffer matrix stack apis
Instead of using apis like cogl_push/pop_matrix, cogl_rotate, cogl_translate and cogl_scale all the examples now use the cogl_framebuffer_* equivalents. Our aim is to remove the need for the default CoglContext and so we are switching towards apis that are explicitly tied to a specific context. Reviewed-by: Neil Roberts <neil@linux.intel.com>
-rw-r--r--examples/cogl-crate.c20
-rw-r--r--examples/cogl-msaa.c8
-rw-r--r--examples/cogl-sdl-hello.c12
3 files changed, 23 insertions, 17 deletions
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c
index 3c61c96e..d157a18b 100644
--- a/examples/cogl-crate.c
+++ b/examples/cogl-crate.c
@@ -81,17 +81,21 @@ static CoglVertexP3T2 vertices[] =
static void
paint (Data *data)
{
+ CoglFramebuffer *fb = data->fb;
float rotation;
- cogl_framebuffer_clear4f (data->fb,
+ cogl_framebuffer_clear4f (fb,
COGL_BUFFER_BIT_COLOR|COGL_BUFFER_BIT_DEPTH,
0, 0, 0, 1);
- cogl_push_matrix ();
+ cogl_framebuffer_push_matrix (fb);
- cogl_translate (data->framebuffer_width / 2, data->framebuffer_height / 2, 0);
+ cogl_framebuffer_translate (fb,
+ data->framebuffer_width / 2,
+ data->framebuffer_height / 2,
+ 0);
- cogl_scale (75, 75, 75);
+ cogl_framebuffer_scale (fb, 75, 75, 75);
/* Update the rotation based on the time the application has been
running so that we get a linear animation regardless of the frame
@@ -107,9 +111,9 @@ paint (Data *data)
* we want it to be a rotation around the origin, before it is
* scaled and translated.
*/
- cogl_rotate (rotation, 0, 0, 1);
- cogl_rotate (rotation, 0, 1, 0);
- cogl_rotate (rotation, 1, 0, 0);
+ cogl_framebuffer_rotate (fb, rotation, 0, 0, 1);
+ cogl_framebuffer_rotate (fb, rotation, 0, 1, 0);
+ cogl_framebuffer_rotate (fb, rotation, 1, 0, 0);
/* Whenever you draw something with Cogl using geometry defined by
* one of cogl_rectangle, cogl_polygon, cogl_path or
@@ -125,7 +129,7 @@ paint (Data *data)
cogl_set_depth_test_enabled (FALSE);
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (fb);
/* And finally render our Pango layouts... */
diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c
index 14612142..d89ecfe7 100644
--- a/examples/cogl-msaa.c
+++ b/examples/cogl-msaa.c
@@ -90,12 +90,12 @@ main (int argc, char **argv)
cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
- cogl_push_matrix ();
- cogl_scale (0.5, 1, 1);
- cogl_translate (-1, 0, 0);
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_scale (fb, 0.5, 1, 1);
+ cogl_framebuffer_translate (fb, -1, 0, 0);
cogl_set_source (pipeline);
cogl_primitive_draw (triangle);
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (fb);
cogl_push_framebuffer (offscreen_fb);
cogl_primitive_draw (triangle);
diff --git a/examples/cogl-sdl-hello.c b/examples/cogl-sdl-hello.c
index 9e2acecc..e0ca7aa5 100644
--- a/examples/cogl-sdl-hello.c
+++ b/examples/cogl-sdl-hello.c
@@ -17,15 +17,17 @@ typedef struct Data
static void
redraw (Data *data)
{
- cogl_framebuffer_clear4f (data->fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
+ CoglFramebuffer *fb = data->fb;
- cogl_push_matrix ();
- cogl_translate (data->center_x, -data->center_y, 0.0f);
+ cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
+
+ cogl_framebuffer_push_matrix (fb);
+ cogl_framebuffer_translate (fb, data->center_x, -data->center_y, 0.0f);
cogl_primitive_draw (data->triangle);
- cogl_pop_matrix ();
+ cogl_framebuffer_pop_matrix (fb);
- cogl_framebuffer_swap_buffers (data->fb);
+ cogl_framebuffer_swap_buffers (fb);
}
static void