[cogl] examples: use cogl_framebuffer_clear4f not cogl_clear



commit 7287dd1fafd893bfed42242fc01eb4c20885e50b
Author: Robert Bragg <robert linux intel com>
Date:   Sat Jan 7 23:28:36 2012 +0000

    examples: use cogl_framebuffer_clear4f not cogl_clear
    
    cogl_clear depends on the default CoglContext which we are trying to
    steer the API away from requiring. cogl_framebuffer_clear4f is
    explicitly passed a framebuffer pointer which is implicitly related to a
    specific context.
    
    This updates all the examples to use cogl_framebuffer_clear4f instead of
    cogl_clear and removes any redundant CoglColor that was previously
    passed to cogl_clear.
    
    Reviewed-by: Neil Roberts <neil linux intel com>

 examples/cogl-crate.c       |    9 +++++----
 examples/cogl-hello.c       |    2 +-
 examples/cogl-msaa.c        |    4 +---
 examples/cogl-sdl-hello.c   |    5 ++---
 examples/cogl-x11-foreign.c |    4 +---
 examples/cogl-x11-tfp.c     |    4 +---
 examples/cogland.c          |    8 +-------
 7 files changed, 12 insertions(+), 24 deletions(-)
---
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c
index edd9f31..3c61c96 100644
--- a/examples/cogl-crate.c
+++ b/examples/cogl-crate.c
@@ -4,6 +4,7 @@
 /* The state for this example... */
 typedef struct _Data
 {
+  CoglFramebuffer *fb;
   int framebuffer_width;
   int framebuffer_height;
 
@@ -31,7 +32,6 @@ typedef struct _Data
 /* A static identity matrix initialized for convenience. */
 static CoglMatrix identity;
 /* static colors initialized for convenience. */
-static CoglColor black;
 static CoglColor white;
 
 /* A cube modelled using 4 vertices for each face.
@@ -83,7 +83,9 @@ paint (Data *data)
 {
   float rotation;
 
-  cogl_clear (&black, COGL_BUFFER_BIT_COLOR|COGL_BUFFER_BIT_DEPTH);
+  cogl_framebuffer_clear4f (data->fb,
+                            COGL_BUFFER_BIT_COLOR|COGL_BUFFER_BIT_DEPTH,
+                            0, 0, 0, 1);
 
   cogl_push_matrix ();
 
@@ -167,7 +169,7 @@ main (int argc, char **argv)
 
   onscreen = cogl_onscreen_new (ctx, 640, 480);
   fb = COGL_FRAMEBUFFER (onscreen);
-
+  data.fb = fb;
   data.framebuffer_width = cogl_framebuffer_get_width (fb);
   data.framebuffer_height = cogl_framebuffer_get_height (fb);
 
@@ -206,7 +208,6 @@ main (int argc, char **argv)
 
   /* Initialize some convenient constants */
   cogl_matrix_init_identity (&identity);
-  cogl_color_set_from_4ub (&black, 0x00, 0x00, 0x00, 0xff);
   cogl_color_set_from_4ub (&white, 0xff, 0xff, 0xff, 0xff);
 
   /* rectangle indices allow the GPU to interpret a list of quads (the
diff --git a/examples/cogl-hello.c b/examples/cogl-hello.c
index ad38509..49055e7 100644
--- a/examples/cogl-hello.c
+++ b/examples/cogl-hello.c
@@ -37,7 +37,7 @@ main (int argc, char **argv)
         int n_poll_fds;
         gint64 timeout;
 
-        cogl_clear (&black, COGL_BUFFER_BIT_COLOR);
+        cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
         cogl_primitive_draw (triangle);
         cogl_framebuffer_swap_buffers (fb);
 
diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c
index 3c1594c..1461214 100644
--- a/examples/cogl-msaa.c
+++ b/examples/cogl-msaa.c
@@ -2,8 +2,6 @@
 #include <glib.h>
 #include <stdio.h>
 
-CoglColor black;
-
 int
 main (int argc, char **argv)
 {
@@ -90,7 +88,7 @@ main (int argc, char **argv)
         int n_poll_fds;
         gint64 timeout;
 
-        cogl_clear (&black, COGL_BUFFER_BIT_COLOR);
+        cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
 
         cogl_push_matrix ();
         cogl_scale (0.5, 1, 1);
diff --git a/examples/cogl-sdl-hello.c b/examples/cogl-sdl-hello.c
index c8f6702..9e2acec 100644
--- a/examples/cogl-sdl-hello.c
+++ b/examples/cogl-sdl-hello.c
@@ -8,7 +8,6 @@
 
 typedef struct Data
 {
-  CoglColor black;
   CoglPrimitive *triangle;
   float center_x, center_y;
   CoglFramebuffer *fb;
@@ -18,7 +17,7 @@ typedef struct Data
 static void
 redraw (Data *data)
 {
-  cogl_clear (&data->black, COGL_BUFFER_BIT_COLOR);
+  cogl_framebuffer_clear4f (data->fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
 
   cogl_push_matrix ();
   cogl_translate (data->center_x, -data->center_y, 0.0f);
@@ -138,8 +137,8 @@ main (int argc, char **argv)
   SDL_InitSubSystem (SDL_INIT_TIMER);
 
   onscreen = cogl_onscreen_new (ctx, 800, 600);
+  data.fb = COGL_FRAMEBUFFER (onscreen);
 
-  cogl_color_set_from_4ub (&data.black, 0, 0, 0, 255);
   data.center_x = 0.0f;
   data.center_y = 0.0f;
   data.quit = FALSE;
diff --git a/examples/cogl-x11-foreign.c b/examples/cogl-x11-foreign.c
index cba837f..00dbb1f 100644
--- a/examples/cogl-x11-foreign.c
+++ b/examples/cogl-x11-foreign.c
@@ -13,8 +13,6 @@
    ButtonReleaseMask | \
    PointerMotionMask)
 
-CoglColor black;
-
 static void
 update_cogl_x11_event_mask (CoglOnscreen *onscreen,
                             guint32 event_mask,
@@ -171,7 +169,7 @@ main (int argc, char **argv)
             }
           cogl_xlib_renderer_handle_event (renderer, &event);
         }
-      cogl_clear (&black, COGL_BUFFER_BIT_COLOR);
+      cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
       cogl_primitive_draw (triangle);
       cogl_framebuffer_swap_buffers (fb);
 
diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c
index 551ce81..74ef45d 100644
--- a/examples/cogl-x11-tfp.c
+++ b/examples/cogl-x11-tfp.c
@@ -19,8 +19,6 @@
 #define TFP_XWIN_WIDTH 200
 #define TFP_XWIN_HEIGHT 200
 
-CoglColor black;
-
 static void
 update_cogl_x11_event_mask (CoglOnscreen *onscreen,
                             guint32 event_mask,
@@ -216,7 +214,7 @@ main (int argc, char **argv)
       XFillRectangle (xdpy, tfp_xwin, gc, 0, 0, TFP_XWIN_WIDTH, TFP_XWIN_HEIGHT);
       XFlush (xdpy);
 
-      cogl_clear (&black, COGL_BUFFER_BIT_COLOR);
+      cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
       cogl_set_source_texture (tfp);
       cogl_rectangle (-0.8, 0.8, 0.8, -0.8);
       cogl_framebuffer_swap_buffers (fb);
diff --git a/examples/cogland.c b/examples/cogland.c
index 3b2fad0..a91e3f0 100644
--- a/examples/cogland.c
+++ b/examples/cogland.c
@@ -6,8 +6,6 @@
 
 #include <wayland-server.h>
 
-CoglColor black;
-
 typedef struct _CoglandCompositor CoglandCompositor;
 
 typedef struct
@@ -512,11 +510,7 @@ paint_cb (void *user_data)
 
       cogl_push_framebuffer (fb);
 
-#if 0
-      cogl_framebuffer_clear (fb, COGL_BUFFER_BIT_COLOR);
-#else
-      cogl_clear (&black, COGL_BUFFER_BIT_COLOR);
-#endif
+      cogl_framebuffer_clear4f (fb, COGL_BUFFER_BIT_COLOR, 0, 0, 0, 1);
 
       cogl_primitive_draw (compositor->triangle);
 



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