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>
This commit is contained in:
Robert Bragg 2012-01-07 23:28:36 +00:00
parent cdbc1dc9b1
commit 7287dd1faf
7 changed files with 12 additions and 24 deletions

View File

@ -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

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);