[cogl] examples: Remove explicit framebuffer allocations



commit cdbc1dc9b138c2fcb467a1faf11b3c3ff2152335
Author: Robert Bragg <robert linux intel com>
Date:   Sat Jan 7 23:10:25 2012 +0000

    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>

 examples/cogl-crate.c       |   10 +---------
 examples/cogl-hello.c       |    9 +--------
 examples/cogl-msaa.c        |    2 --
 examples/cogl-sdl-hello.c   |    9 ---------
 examples/cogl-x11-foreign.c |   10 +---------
 examples/cogl-x11-tfp.c     |   11 +----------
 6 files changed, 4 insertions(+), 47 deletions(-)
---
diff --git a/examples/cogl-crate.c b/examples/cogl-crate.c
index 3c9ee43..edd9f31 100644
--- a/examples/cogl-crate.c
+++ b/examples/cogl-crate.c
@@ -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);
diff --git a/examples/cogl-hello.c b/examples/cogl-hello.c
index e8e4f5b..ad38509 100644
--- a/examples/cogl-hello.c
+++ b/examples/cogl-hello.c
@@ -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,
diff --git a/examples/cogl-msaa.c b/examples/cogl-msaa.c
index aecc903..3c1594c 100644
--- a/examples/cogl-msaa.c
+++ b/examples/cogl-msaa.c
@@ -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);
diff --git a/examples/cogl-sdl-hello.c b/examples/cogl-sdl-hello.c
index b74e8a2..c8f6702 100644
--- a/examples/cogl-sdl-hello.c
+++ b/examples/cogl-sdl-hello.c
@@ -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;
diff --git a/examples/cogl-x11-foreign.c b/examples/cogl-x11-foreign.c
index b1d6acf..cba837f 100644
--- a/examples/cogl-x11-foreign.c
+++ b/examples/cogl-x11-foreign.c
@@ -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,
diff --git a/examples/cogl-x11-tfp.c b/examples/cogl-x11-tfp.c
index b045118..551ce81 100644
--- a/examples/cogl-x11-tfp.c
+++ b/examples/cogl-x11-tfp.c
@@ -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 (;;)



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