From 0365f6cda3df89335d243548053d85aaf66f1630 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Sat, 7 Jan 2012 23:48:08 +0000 Subject: 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 --- examples/cogl-crate.c | 20 ++++++++++++-------- examples/cogl-msaa.c | 8 ++++---- examples/cogl-sdl-hello.c | 12 +++++++----- 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 -- cgit v1.2.1