1
0
Fork 0

examples: Remove explicit framebuffer allocations

It used to be that cogl_framebuffer_allocate() had to be done explicitly
but we have since made Cogl lazily allocate framebuffers when they are
first used if they haven't already been explicitly allocated. Developers
only need to explicitly allocate framebuffers if they are planning to
gracefully handle any errors. In cases where the program will simply
abort due to an allocation error they can simply rely on implicit
allocation which will cause an abort on error.

This updates the examples to not explicitly allocate the framebuffers
since they all just abort on error anyway.

Reviewed-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
Robert Bragg 2012-01-07 23:10:25 +00:00
parent 88f8780367
commit cdbc1dc9b1
6 changed files with 4 additions and 47 deletions

View file

@ -165,16 +165,8 @@ main (int argc, char **argv)
return 1;
}
data.framebuffer_width = 640;
data.framebuffer_height = 480;
onscreen = cogl_onscreen_new (ctx, data.framebuffer_width, data.framebuffer_height);
/* Eventually there will be an implicit allocate on first use so this
* will become optional... */
onscreen = cogl_onscreen_new (ctx, 640, 480);
fb = COGL_FRAMEBUFFER (onscreen);
if (!cogl_framebuffer_allocate (fb, &error)) {
fprintf (stderr, "Failed to allocate framebuffer: %s\n", error->message);
return 1;
}
data.framebuffer_width = cogl_framebuffer_get_width (fb);
data.framebuffer_height = cogl_framebuffer_get_height (fb);

View file

@ -25,16 +25,9 @@ main (int argc, char **argv)
}
onscreen = cogl_onscreen_new (ctx, 640, 480);
/* Eventually there will be an implicit allocate on first use so this
* will become optional... */
fb = COGL_FRAMEBUFFER (onscreen);
if (!cogl_framebuffer_allocate (fb, &error)) {
fprintf (stderr, "Failed to allocate framebuffer: %s\n", error->message);
return 1;
}
cogl_onscreen_show (onscreen);
fb = COGL_FRAMEBUFFER (onscreen);
cogl_push_framebuffer (fb);
triangle = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES,

View file

@ -43,8 +43,6 @@ main (int argc, char **argv)
}
onscreen = cogl_onscreen_new (ctx, 640, 480);
/* Eventually there will be an implicit allocate on first use so this
* will become optional... */
fb = COGL_FRAMEBUFFER (onscreen);
cogl_framebuffer_set_samples_per_pixel (fb, 4);

View file

@ -138,15 +138,6 @@ main (int argc, char **argv)
SDL_InitSubSystem (SDL_INIT_TIMER);
onscreen = cogl_onscreen_new (ctx, 800, 600);
/* Eventually there will be an implicit allocate on first use so this
* will become optional... */
data.fb = COGL_FRAMEBUFFER (onscreen);
if (!cogl_framebuffer_allocate (data.fb, &error))
{
fprintf (stderr, "Failed to allocate framebuffer: %s\n",
error->message);
return 1;
}
cogl_color_set_from_4ub (&data.black, 0, 0, 0, 255);
data.center_x = 0.0f;

View file

@ -146,17 +146,9 @@ main (int argc, char **argv)
update_cogl_x11_event_mask,
xdpy);
fb = COGL_FRAMEBUFFER (onscreen);
/* Eventually there will be an implicit allocate on first use so this
* will become optional... */
if (!cogl_framebuffer_allocate (fb, &error))
{
fprintf (stderr, "Failed to allocate framebuffer: %s\n", error->message);
return 1;
}
XMapWindow (xdpy, xwin);
fb = COGL_FRAMEBUFFER (onscreen);
cogl_push_framebuffer (fb);
triangle = cogl_primitive_new_p2c4 (COGL_VERTICES_MODE_TRIANGLES,

View file

@ -167,15 +167,6 @@ main (int argc, char **argv)
update_cogl_x11_event_mask,
xdpy);
fb = COGL_FRAMEBUFFER (onscreen);
/* Eventually there will be an implicit allocate on first use so this
* will become optional... */
if (!cogl_framebuffer_allocate (fb, &error))
{
fprintf (stderr, "Failed to allocate framebuffer: %s\n", error->message);
return 1;
}
XMapWindow (xdpy, xwin);
XCompositeRedirectSubwindows (xdpy, xwin, CompositeRedirectManual);
@ -190,11 +181,11 @@ main (int argc, char **argv)
gc = XCreateGC (xdpy, tfp_xwin, 0, NULL);
pixmap = XCompositeNameWindowPixmap (xdpy, tfp_xwin);
tfp = cogl_texture_pixmap_x11_new (pixmap, TRUE);
fb = COGL_FRAMEBUFFER (onscreen);
cogl_push_framebuffer (fb);
for (;;)