diff options
author | Robert Bragg <robert@linux.intel.com> | 2012-01-07 23:28:36 +0000 |
---|---|---|
committer | Robert Bragg <robert@linux.intel.com> | 2012-02-09 13:09:15 +0000 |
commit | 7287dd1fafd893bfed42242fc01eb4c20885e50b (patch) | |
tree | bbfb26655bf96f6fee19c65093487197a777a335 | |
parent | cdbc1dc9b138c2fcb467a1faf11b3c3ff2152335 (diff) | |
download | cogl-7287dd1fafd893bfed42242fc01eb4c20885e50b.tar.gz |
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>
-rw-r--r-- | examples/cogl-crate.c | 9 | ||||
-rw-r--r-- | examples/cogl-hello.c | 2 | ||||
-rw-r--r-- | examples/cogl-msaa.c | 4 | ||||
-rw-r--r-- | examples/cogl-sdl-hello.c | 5 | ||||
-rw-r--r-- | examples/cogl-x11-foreign.c | 4 | ||||
-rw-r--r-- | examples/cogl-x11-tfp.c | 4 | ||||
-rw-r--r-- | examples/cogland.c | 8 |
7 files changed, 12 insertions, 24 deletions
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c index edd9f31d..3c61c96e 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 ad385097..49055e72 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 3c1594ce..14612142 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 c8f6702b..9e2acecc 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 cba837f9..00dbb1f5 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 551ce818..74ef45d4 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 3b2fad04..a91e3f09 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); |