[cogl] examples: use framebuffer matrix stack apis



commit 0365f6cda3df89335d243548053d85aaf66f1630
Author: Robert Bragg <robert linux intel com>
Date:   Sat Jan 7 23:48:08 2012 +0000

    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>

 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 3c61c96..d157a18 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 1461214..d89ecfe 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 9e2acec..e0ca7aa 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



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]