From 439f8c62b0e2651b9afeb08cb5166ed9e7f49521 Mon Sep 17 00:00:00 2001 From: Robert Bragg Date: Thu, 26 Nov 2009 19:06:35 +0000 Subject: [PATCH] cogl: deprecate cogl_draw_buffer API and replace with a cogl_framebuffer API cogl_push_draw_buffer, cogl_set_draw_buffer and cogl_pop_draw_buffer are now deprecated and new code should use the new cogl_framebuffer_* API instead. Code that previously did: cogl_push_draw_buffer (); cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, buffer); /* draw */ cogl_pop_draw_buffer (); should now be re-written as: cogl_push_framebuffer (buffer); /* draw */ cogl_pop_framebuffer (); As can be seen from the example above the rename has been used as an opportunity to remove the redundant target argument from cogl_set_draw_buffer; it now only takes one call to redirect to an offscreen buffer, and finally the term framebuffer may be a bit more familiar to anyone coming from an OpenGL background. --- README | 13 + clutter/clutter-texture.c | 15 +- clutter/cogl/cogl/Makefile.am | 4 +- clutter/cogl/cogl/cogl-clip-stack.c | 74 ++-- clutter/cogl/cogl/cogl-context.c | 13 +- clutter/cogl/cogl/cogl-context.h | 4 +- ...r-private.h => cogl-framebuffer-private.h} | 75 ++-- ...{cogl-draw-buffer.c => cogl-framebuffer.c} | 375 +++++++++--------- clutter/cogl/cogl/cogl-journal.c | 12 +- clutter/cogl/cogl/cogl-matrix-stack.c | 6 +- clutter/cogl/cogl/cogl-primitives.c | 30 +- clutter/cogl/cogl/cogl-texture.c | 12 +- clutter/cogl/cogl/cogl-vertex-buffer.c | 6 +- clutter/cogl/cogl/cogl.c | 80 ++-- clutter/cogl/cogl/cogl.h | 73 +++- doc/reference/cogl/cogl-sections.txt | 3 + tests/conform/test-backface-culling.c | 7 +- tests/conform/test-cogl-offscreen.c | 33 +- tests/conform/test-cogl-readpixels.c | 45 +-- tests/conform/test-cogl-viewport.c | 90 ++--- tests/interactive/test-cogl-offscreen.c | 4 +- 21 files changed, 521 insertions(+), 453 deletions(-) rename clutter/cogl/cogl/{cogl-draw-buffer-private.h => cogl-framebuffer-private.h} (56%) rename clutter/cogl/cogl/{cogl-draw-buffer.c => cogl-framebuffer.c} (55%) diff --git a/README b/README index b1d1ca5de..bab7a3941 100644 --- a/README +++ b/README @@ -236,6 +236,19 @@ Cogl API changes for Clutter 1.2 way derived from another. This will allow Cogl to track material ancestries/similarities and reduce the cost of GPU state changes. +* cogl_push_draw_buffer, cogl_set_draw_buffer and cogl_pop_draw_buffer are now + deprecated and new code should use the cogl_framebuffer_* API instead. + Code that previously did: + cogl_push_draw_buffer (); + cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, buffer); + /* draw */ + cogl_pop_draw_buffer (); + can now be re-written as: + cogl_push_framebuffer (buffer); + /* draw */ + cogl_pop_framebuffer (); + + Release Notes for Clutter 1.0 ------------------------------- diff --git a/clutter/clutter-texture.c b/clutter/clutter-texture.c index abe0f8485..a6edc9827 100644 --- a/clutter/clutter-texture.c +++ b/clutter/clutter-texture.c @@ -484,7 +484,7 @@ set_viewport_with_buffer_under_fbo_source (ClutterActor *fbo_source, #undef ROUND /* translate the viewport so that the source actor lands on the - * sub-region backed by the offscreen draw buffer... */ + * sub-region backed by the offscreen framebuffer... */ cogl_set_viewport (x_offset, y_offset, viewport_width, viewport_height); } @@ -511,8 +511,7 @@ update_fbo (ClutterActor *self) clutter_shader_set_is_enabled (shader, FALSE); /* Redirect drawing to the fbo */ - cogl_push_draw_buffer (); - cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->fbo_handle); + cogl_push_framebuffer (priv->fbo_handle); if ((stage = clutter_actor_get_stage (self))) { @@ -520,8 +519,8 @@ update_fbo (ClutterActor *self) ClutterActor *source_parent; /* We copy the projection and modelview matrices from the stage to - * the offscreen draw buffer and create a viewport larger than the - * offscreen draw buffer - the same size as the stage. + * the offscreen framebuffer and create a viewport larger than the + * offscreen framebuffer - the same size as the stage. * * The fbo source actor gets rendered into this stage size viewport at the * same position it normally would after applying all it's usual parent @@ -542,7 +541,7 @@ update_fbo (ClutterActor *self) perspective.z_near, perspective.z_far); - /* Negatively offset the viewport so that the offscreen draw buffer is + /* Negatively offset the viewport so that the offscreen framebuffer is * position underneath the fbo_source actor... */ set_viewport_with_buffer_under_fbo_source (priv->fbo_source, stage_width, @@ -565,8 +564,8 @@ update_fbo (ClutterActor *self) /* Render the actor to the fbo */ clutter_actor_paint (priv->fbo_source); - /* Restore drawing to the previous draw buffer */ - cogl_pop_draw_buffer (); + /* Restore drawing to the previous framebuffer */ + cogl_pop_framebuffer (); /* If there is a shader on top of the shader stack, turn it back on. */ if (shader) diff --git a/clutter/cogl/cogl/Makefile.am b/clutter/cogl/cogl/Makefile.am index 67b353356..c3b19c424 100644 --- a/clutter/cogl/cogl/Makefile.am +++ b/clutter/cogl/cogl/Makefile.am @@ -131,8 +131,8 @@ libclutter_cogl_la_SOURCES = \ $(srcdir)/cogl-spans.c \ $(srcdir)/cogl-journal-private.h \ $(srcdir)/cogl-journal.c \ - $(srcdir)/cogl-draw-buffer-private.h \ - $(srcdir)/cogl-draw-buffer.c \ + $(srcdir)/cogl-framebuffer-private.h \ + $(srcdir)/cogl-framebuffer.c \ $(srcdir)/cogl-matrix-mesa.h \ $(srcdir)/cogl-matrix-mesa.c \ $(NULL) diff --git a/clutter/cogl/cogl/cogl-clip-stack.c b/clutter/cogl/cogl/cogl-clip-stack.c index 75ed1d9c8..f58792e29 100644 --- a/clutter/cogl/cogl/cogl-clip-stack.c +++ b/clutter/cogl/cogl/cogl-clip-stack.c @@ -35,7 +35,7 @@ #include "cogl-primitives.h" #include "cogl-context.h" #include "cogl-internal.h" -#include "cogl-draw-buffer-private.h" +#include "cogl-framebuffer-private.h" void _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, floatVec2 nodes_max, @@ -132,11 +132,11 @@ set_clip_plane (GLint plane_num, GLdouble plane[4]; #endif GLfloat angle; - CoglHandle draw_buffer = _cogl_get_draw_buffer (); + CoglHandle framebuffer = _cogl_get_framebuffer (); CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (draw_buffer); + _cogl_framebuffer_get_modelview_stack (framebuffer); CoglMatrixStack *projection_stack = - _cogl_draw_buffer_get_projection_stack (draw_buffer); + _cogl_framebuffer_get_projection_stack (framebuffer); CoglMatrix inverse_projection; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -184,12 +184,12 @@ set_clip_planes (float x_1, float x_2, float y_2) { - CoglHandle draw_buffer = _cogl_get_draw_buffer (); + CoglHandle framebuffer = _cogl_get_framebuffer (); CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (draw_buffer); + _cogl_framebuffer_get_modelview_stack (framebuffer); CoglMatrix modelview_matrix; CoglMatrixStack *projection_stack = - _cogl_draw_buffer_get_projection_stack (draw_buffer); + _cogl_framebuffer_get_projection_stack (framebuffer); CoglMatrix projection_matrix; float vertex_tl[4] = { x_1, y_1, 0, 1.0 }; @@ -236,7 +236,7 @@ add_stencil_clip_rectangle (float x_1, gboolean first) { CoglHandle current_source; - CoglHandle draw_buffer = _cogl_get_draw_buffer (); + CoglHandle framebuffer = _cogl_get_framebuffer (); _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -244,7 +244,7 @@ add_stencil_clip_rectangle (float x_1, * batched geometry before we start... */ _cogl_journal_flush (); - _cogl_draw_buffer_flush_state (draw_buffer, 0); + _cogl_framebuffer_flush_state (framebuffer, 0); /* temporarily swap in our special stenciling material */ current_source = cogl_handle_ref (ctx->source_material); @@ -267,9 +267,9 @@ add_stencil_clip_rectangle (float x_1, else { CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (draw_buffer); + _cogl_framebuffer_get_modelview_stack (framebuffer); CoglMatrixStack *projection_stack = - _cogl_draw_buffer_get_projection_stack (draw_buffer); + _cogl_framebuffer_get_projection_stack (framebuffer); /* Add one to every pixel of the stencil buffer in the rectangle */ @@ -341,10 +341,10 @@ cogl_clip_push_window_rectangle (int x_offset, int width, int height) { - CoglHandle draw_buffer; + CoglHandle framebuffer; CoglClipStackState *clip_state; CoglClipStack *stack; - int draw_buffer_height; + int framebuffer_height; CoglClipStackEntryWindowRect *entry; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -353,12 +353,12 @@ cogl_clip_push_window_rectangle (int x_offset, * it before making modifications */ _cogl_journal_flush (); - draw_buffer = _cogl_get_draw_buffer (); - clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); + framebuffer = _cogl_get_framebuffer (); + clip_state = _cogl_framebuffer_get_clip_state (framebuffer); stack = clip_state->stacks->data; - draw_buffer_height = _cogl_draw_buffer_get_height (draw_buffer); + framebuffer_height = _cogl_framebuffer_get_height (framebuffer); entry = g_slice_new (CoglClipStackEntryWindowRect); @@ -372,15 +372,15 @@ cogl_clip_push_window_rectangle (int x_offset, entry->type = COGL_CLIP_STACK_WINDOW_RECT; entry->x0 = x_offset; entry->x1 = x_offset + width; - if (cogl_is_offscreen (draw_buffer)) + if (cogl_is_offscreen (framebuffer)) { entry->y0 = y_offset; entry->y1 = y_offset + height; } else { - entry->y0 = draw_buffer_height - y_offset - height; - entry->y1 = draw_buffer_height - y_offset; + entry->y0 = framebuffer_height - y_offset - height; + entry->y1 = framebuffer_height - y_offset; } /* Store it in the stack */ @@ -400,7 +400,7 @@ cogl_clip_push_window_rect (float x_offset, } /* Scale from OpenGL normalized device coordinates (ranging from -1 to 1) - * to Cogl window/draw-buffer coordinates (ranging from 0 to buffer-size) with + * to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with * (0,0) being top left. */ #define VIEWPORT_TRANSFORM_X(x, vp_origin_x, vp_width) \ ( ( ((x) + 1.0) * ((vp_width) / 2.0) ) + (vp_origin_x) ) @@ -492,7 +492,7 @@ cogl_clip_push_rectangle (float x_1, float x_2, float y_2) { - CoglHandle draw_buffer; + CoglHandle framebuffer; CoglClipStackState *clip_state; CoglClipStack *stack; CoglClipStackEntryRect *entry; @@ -508,8 +508,8 @@ cogl_clip_push_rectangle (float x_1, if (try_pushing_rect_as_window_rect (x_1, y_1, x_2, y_2)) return; - draw_buffer = _cogl_get_draw_buffer (); - clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); + framebuffer = _cogl_get_framebuffer (); + clip_state = _cogl_framebuffer_get_clip_state (framebuffer); stack = clip_state->stacks->data; @@ -546,7 +546,7 @@ cogl_clip_push (float x_offset, void cogl_clip_push_from_path_preserve (void) { - CoglHandle draw_buffer; + CoglHandle framebuffer; CoglClipStackState *clip_state; CoglClipStack *stack; CoglClipStackEntryPath *entry; @@ -557,8 +557,8 @@ cogl_clip_push_from_path_preserve (void) * it before making modifications */ _cogl_journal_flush (); - draw_buffer = _cogl_get_draw_buffer (); - clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); + framebuffer = _cogl_get_framebuffer (); + clip_state = _cogl_framebuffer_get_clip_state (framebuffer); stack = clip_state->stacks->data; @@ -623,13 +623,13 @@ _cogl_clip_pop_real (CoglClipStackState *clip_state) void cogl_clip_pop (void) { - CoglHandle draw_buffer; + CoglHandle framebuffer; CoglClipStackState *clip_state; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - draw_buffer = _cogl_get_draw_buffer (); - clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); + framebuffer = _cogl_get_framebuffer (); + clip_state = _cogl_framebuffer_get_clip_state (framebuffer); _cogl_clip_pop_real (clip_state); } @@ -647,7 +647,7 @@ _cogl_flush_clip_state (CoglClipStackState *clip_state) gint scissor_x1 = G_MAXINT; gint scissor_y1 = G_MAXINT; CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); if (!clip_state->stack_dirty) return; @@ -776,7 +776,7 @@ cogl_clip_ensure (void) { CoglClipStackState *clip_state; - clip_state = _cogl_draw_buffer_get_clip_state (_cogl_get_draw_buffer ()); + clip_state = _cogl_framebuffer_get_clip_state (_cogl_get_framebuffer ()); _cogl_flush_clip_state (clip_state); } @@ -799,13 +799,13 @@ _cogl_clip_stack_save_real (CoglClipStackState *clip_state) void cogl_clip_stack_save (void) { - CoglHandle draw_buffer; + CoglHandle framebuffer; CoglClipStackState *clip_state; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - draw_buffer = _cogl_get_draw_buffer (); - clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); + framebuffer = _cogl_get_framebuffer (); + clip_state = _cogl_framebuffer_get_clip_state (framebuffer); _cogl_clip_stack_save_real (clip_state); } @@ -838,13 +838,13 @@ _cogl_clip_stack_restore_real (CoglClipStackState *clip_state) void cogl_clip_stack_restore (void) { - CoglHandle draw_buffer; + CoglHandle framebuffer; CoglClipStackState *clip_state; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - draw_buffer = _cogl_get_draw_buffer (); - clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); + framebuffer = _cogl_get_framebuffer (); + clip_state = _cogl_framebuffer_get_clip_state (framebuffer); _cogl_clip_stack_restore_real (clip_state); } diff --git a/clutter/cogl/cogl/cogl-context.c b/clutter/cogl/cogl/cogl-context.c index a05745bb4..c78b2821c 100644 --- a/clutter/cogl/cogl/cogl-context.c +++ b/clutter/cogl/cogl/cogl-context.c @@ -32,7 +32,7 @@ #include "cogl-journal-private.h" #include "cogl-texture-private.h" #include "cogl-material-private.h" -#include "cogl-draw-buffer-private.h" +#include "cogl-framebuffer-private.h" #include @@ -98,12 +98,13 @@ cogl_create_context (void) sizeof (CoglLayerInfo)); _context->n_texcoord_arrays_enabled = 0; - _context->draw_buffer_stack = _cogl_create_draw_buffer_stack (); + _context->framebuffer_stack = _cogl_create_framebuffer_stack (); window_buffer = _cogl_onscreen_new (); - /* XXX: When setting up the window buffer, cogl_set_draw_buffer - * assumes that the handle can be found in ctx->window_buffer */ + cogl_set_framebuffer (window_buffer); + /* XXX: the deprecated _cogl_set_draw_buffer API expects to + * find the window buffer here... */ _context->window_buffer = window_buffer; - cogl_set_draw_buffer (COGL_WINDOW_BUFFER, 0/* ignored */); + _context->dirty_bound_framebuffer = TRUE; _context->dirty_gl_viewport = TRUE; @@ -158,7 +159,7 @@ _cogl_destroy_context () _cogl_destroy_texture_units (); - _cogl_free_draw_buffer_stack (_context->draw_buffer_stack); + _cogl_free_framebuffer_stack (_context->framebuffer_stack); if (_context->path_nodes) g_array_free (_context->path_nodes, TRUE); diff --git a/clutter/cogl/cogl/cogl-context.h b/clutter/cogl/cogl/cogl-context.h index da7bb207b..717f3534e 100644 --- a/clutter/cogl/cogl/cogl-context.h +++ b/clutter/cogl/cogl/cogl-context.h @@ -86,8 +86,8 @@ typedef struct GArray *current_layers; guint n_texcoord_arrays_enabled; - /* Draw Buffers */ - GSList *draw_buffer_stack; + /* Framebuffers */ + GSList *framebuffer_stack; CoglHandle window_buffer; gboolean dirty_bound_framebuffer; gboolean dirty_gl_viewport; diff --git a/clutter/cogl/cogl/cogl-draw-buffer-private.h b/clutter/cogl/cogl/cogl-framebuffer-private.h similarity index 56% rename from clutter/cogl/cogl/cogl-draw-buffer-private.h rename to clutter/cogl/cogl/cogl-framebuffer-private.h index 3490cd26c..eb94c6f7f 100644 --- a/clutter/cogl/cogl/cogl-draw-buffer-private.h +++ b/clutter/cogl/cogl/cogl-framebuffer-private.h @@ -21,22 +21,22 @@ * Boston, MA 02111-1307, USA. */ -#ifndef __COGL_DRAW_BUFFER_PRIVATE_H -#define __COGL_DRAW_BUFFER_PRIVATE_H +#ifndef __COGL_FRAMEBUFFER_PRIVATE_H +#define __COGL_FRAMEBUFFER_PRIVATE_H #include "cogl-handle.h" #include "cogl-matrix-stack.h" #include "cogl-clip-stack.h" -typedef enum _CoglDrawBufferType { - COGL_DRAW_BUFFER_TYPE_ONSCREEN, - COGL_DRAW_BUFFER_TYPE_OFFSCREEN -} CoglDrawBufferType; +typedef enum _CoglFramebufferType { + COGL_FRAMEBUFFER_TYPE_ONSCREEN, + COGL_FRAMEBUFFER_TYPE_OFFSCREEN +} CoglFramebufferType; typedef struct { CoglHandleObject _parent; - CoglDrawBufferType type; + CoglFramebufferType type; int width; int height; @@ -48,19 +48,13 @@ typedef struct int viewport_height; CoglClipStackState clip_state; -} CoglDrawBuffer; +} CoglFramebuffer; -#define COGL_DRAW_BUFFER(X) ((CoglDrawBuffer *)(X)) - -typedef struct _CoglDrawBufferStackEntry -{ - CoglBufferTarget target; - CoglHandle draw_buffer; -} CoglDrawBufferStackEntry; +#define COGL_FRAMEBUFFER(X) ((CoglFramebuffer *)(X)) typedef struct _CoglOffscreen { - CoglDrawBuffer _parent; + CoglFramebuffer _parent; GLuint fbo_handle; GLuint gl_stencil_handle; } CoglOffscreen; @@ -69,65 +63,62 @@ typedef struct _CoglOffscreen typedef struct _CoglOnscreen { - CoglDrawBuffer _parent; + CoglFramebuffer _parent; } CoglOnscreen; #define COGL_ONSCREEN(X) ((CoglOnscreen *)(X)) void -_cogl_draw_buffer_state_init (void); +_cogl_framebuffer_state_init (void); int -_cogl_draw_buffer_get_width (CoglHandle handle); +_cogl_framebuffer_get_width (CoglHandle handle); int -_cogl_draw_buffer_get_height (CoglHandle handle); +_cogl_framebuffer_get_height (CoglHandle handle); CoglClipStackState * -_cogl_draw_buffer_get_clip_state (CoglHandle handle); +_cogl_framebuffer_get_clip_state (CoglHandle handle); void -_cogl_draw_buffer_set_viewport (CoglHandle handle, +_cogl_framebuffer_set_viewport (CoglHandle handle, int x, int y, int width, int height); int -_cogl_draw_buffer_get_viewport_x (CoglHandle handle); +_cogl_framebuffer_get_viewport_x (CoglHandle handle); int -_cogl_draw_buffer_get_viewport_y (CoglHandle handle); +_cogl_framebuffer_get_viewport_y (CoglHandle handle); int -_cogl_draw_buffer_get_viewport_width (CoglHandle handle); +_cogl_framebuffer_get_viewport_width (CoglHandle handle); int -_cogl_draw_buffer_get_viewport_height (CoglHandle handle); +_cogl_framebuffer_get_viewport_height (CoglHandle handle); void -_cogl_draw_buffer_get_viewport4fv (CoglHandle handle, int *viewport); +_cogl_framebuffer_get_viewport4fv (CoglHandle handle, int *viewport); CoglMatrixStack * -_cogl_draw_buffer_get_modelview_stack (CoglHandle handle); +_cogl_framebuffer_get_modelview_stack (CoglHandle handle); CoglMatrixStack * -_cogl_draw_buffer_get_projection_stack (CoglHandle handle); +_cogl_framebuffer_get_projection_stack (CoglHandle handle); -typedef enum _CoglDrawBufferFlushFlags +typedef enum _CoglFramebufferFlushFlags { /* XXX: When using this, that imples you are going to manually load the * modelview matrix (via glLoadMatrix). _cogl_matrix_stack_flush_to_gl wont - * be called for draw_buffer->modelview_stack, and the modelview_stack will + * be called for framebuffer->modelview_stack, and the modelview_stack will * also be marked as dirty. */ - COGL_DRAW_BUFFER_FLUSH_SKIP_MODELVIEW = 1L<<0, -} CoglDrawBufferFlushFlags; + COGL_FRAMEBUFFER_FLUSH_SKIP_MODELVIEW = 1L<<0, +} CoglFramebufferFlushFlags; void -_cogl_draw_buffer_flush_state (CoglHandle handle, - CoglDrawBufferFlushFlags flags); +_cogl_framebuffer_flush_state (CoglHandle handle, + CoglFramebufferFlushFlags flags); CoglHandle _cogl_onscreen_new (void); -gboolean -cogl_is_offscreen (CoglHandle handle); - CoglHandle -_cogl_get_draw_buffer (void); +_cogl_get_framebuffer (void); GSList * -_cogl_create_draw_buffer_stack (void); +_cogl_create_framebuffer_stack (void); void -_cogl_free_draw_buffer_stack (GSList *stack); +_cogl_free_framebuffer_stack (GSList *stack); -#endif /* __COGL_DRAW_BUFFER_PRIVATE_H */ +#endif /* __COGL_FRAMEBUFFER_PRIVATE_H */ diff --git a/clutter/cogl/cogl/cogl-draw-buffer.c b/clutter/cogl/cogl/cogl-framebuffer.c similarity index 55% rename from clutter/cogl/cogl/cogl-draw-buffer.c rename to clutter/cogl/cogl/cogl-framebuffer.c index d32d32500..5ba0616e3 100644 --- a/clutter/cogl/cogl/cogl-draw-buffer.c +++ b/clutter/cogl/cogl/cogl-framebuffer.c @@ -31,7 +31,7 @@ #include "cogl-handle.h" #include "cogl-util.h" #include "cogl-texture-private.h" -#include "cogl-draw-buffer-private.h" +#include "cogl-framebuffer-private.h" #include "cogl-clip-stack.h" #ifdef HAVE_COGL_GLES2 @@ -72,7 +72,7 @@ #define GL_STENCIL_INDEX8 0x8D48 #endif -static void _cogl_draw_buffer_free (CoglDrawBuffer *draw_buffer); +static void _cogl_framebuffer_free (CoglFramebuffer *framebuffer); static void _cogl_onscreen_free (CoglOnscreen *onscreen); static void _cogl_offscreen_free (CoglOffscreen *offscreen); @@ -81,12 +81,12 @@ COGL_HANDLE_DEFINE (Offscreen, offscreen); /* XXX: * The CoglHandle macros don't support any form of inheritance, so for - * now we implement the CoglHandle support for the CoglDrawBuffer + * now we implement the CoglHandle support for the CoglFramebuffer * abstract class manually. */ gboolean -cogl_is_draw_buffer (CoglHandle handle) +cogl_is_framebuffer (CoglHandle handle) { CoglHandleObject *obj = (CoglHandleObject *)handle; @@ -98,138 +98,138 @@ cogl_is_draw_buffer (CoglHandle handle) } static void -_cogl_draw_buffer_init (CoglDrawBuffer *draw_buffer, - CoglDrawBufferType type, +_cogl_framebuffer_init (CoglFramebuffer *framebuffer, + CoglFramebufferType type, int width, int height) { - draw_buffer->type = type; - draw_buffer->width = width; - draw_buffer->height = height; - draw_buffer->viewport_x = 0; - draw_buffer->viewport_y = 0; - draw_buffer->viewport_width = width; - draw_buffer->viewport_height = height; + framebuffer->type = type; + framebuffer->width = width; + framebuffer->height = height; + framebuffer->viewport_x = 0; + framebuffer->viewport_y = 0; + framebuffer->viewport_width = width; + framebuffer->viewport_height = height; - draw_buffer->modelview_stack = _cogl_matrix_stack_new (); - draw_buffer->projection_stack = _cogl_matrix_stack_new (); + framebuffer->modelview_stack = _cogl_matrix_stack_new (); + framebuffer->projection_stack = _cogl_matrix_stack_new (); /* Initialise the clip stack */ - _cogl_clip_stack_state_init (&draw_buffer->clip_state); + _cogl_clip_stack_state_init (&framebuffer->clip_state); } void -_cogl_draw_buffer_free (CoglDrawBuffer *draw_buffer) +_cogl_framebuffer_free (CoglFramebuffer *framebuffer) { - _cogl_clip_stack_state_destroy (&draw_buffer->clip_state); + _cogl_clip_stack_state_destroy (&framebuffer->clip_state); - _cogl_matrix_stack_destroy (draw_buffer->modelview_stack); - draw_buffer->modelview_stack = NULL; + _cogl_matrix_stack_destroy (framebuffer->modelview_stack); + framebuffer->modelview_stack = NULL; - _cogl_matrix_stack_destroy (draw_buffer->projection_stack); - draw_buffer->projection_stack = NULL; + _cogl_matrix_stack_destroy (framebuffer->projection_stack); + framebuffer->projection_stack = NULL; } int -_cogl_draw_buffer_get_width (CoglHandle handle) +_cogl_framebuffer_get_width (CoglHandle handle) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); - return draw_buffer->width; + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); + return framebuffer->width; } int -_cogl_draw_buffer_get_height (CoglHandle handle) +_cogl_framebuffer_get_height (CoglHandle handle) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); - return draw_buffer->height; + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); + return framebuffer->height; } CoglClipStackState * -_cogl_draw_buffer_get_clip_state (CoglHandle handle) +_cogl_framebuffer_get_clip_state (CoglHandle handle) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); - return &draw_buffer->clip_state; + return &framebuffer->clip_state; } void -_cogl_draw_buffer_set_viewport (CoglHandle handle, +_cogl_framebuffer_set_viewport (CoglHandle handle, int x, int y, int width, int height) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); _COGL_GET_CONTEXT (ctx, NO_RETVAL); - if (draw_buffer->viewport_x == x && - draw_buffer->viewport_y == y && - draw_buffer->viewport_width == width && - draw_buffer->viewport_height == height) + if (framebuffer->viewport_x == x && + framebuffer->viewport_y == y && + framebuffer->viewport_width == width && + framebuffer->viewport_height == height) return; _cogl_journal_flush (); - draw_buffer->viewport_x = x; - draw_buffer->viewport_y = y; - draw_buffer->viewport_width = width; - draw_buffer->viewport_height = height; + framebuffer->viewport_x = x; + framebuffer->viewport_y = y; + framebuffer->viewport_width = width; + framebuffer->viewport_height = height; - if (_cogl_get_draw_buffer () == draw_buffer) + if (_cogl_get_framebuffer () == framebuffer) ctx->dirty_gl_viewport = TRUE; } int -_cogl_draw_buffer_get_viewport_x (CoglHandle handle) +_cogl_framebuffer_get_viewport_x (CoglHandle handle) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); - return draw_buffer->viewport_x; + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); + return framebuffer->viewport_x; } int -_cogl_draw_buffer_get_viewport_y (CoglHandle handle) +_cogl_framebuffer_get_viewport_y (CoglHandle handle) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); - return draw_buffer->viewport_y; + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); + return framebuffer->viewport_y; } int -_cogl_draw_buffer_get_viewport_width (CoglHandle handle) +_cogl_framebuffer_get_viewport_width (CoglHandle handle) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); - return draw_buffer->viewport_width; + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); + return framebuffer->viewport_width; } int -_cogl_draw_buffer_get_viewport_height (CoglHandle handle) +_cogl_framebuffer_get_viewport_height (CoglHandle handle) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); - return draw_buffer->viewport_height; + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); + return framebuffer->viewport_height; } void -_cogl_draw_buffer_get_viewport4fv (CoglHandle handle, int *viewport) +_cogl_framebuffer_get_viewport4fv (CoglHandle handle, int *viewport) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); - viewport[0] = draw_buffer->viewport_x; - viewport[1] = draw_buffer->viewport_y; - viewport[2] = draw_buffer->viewport_width; - viewport[3] = draw_buffer->viewport_height; + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); + viewport[0] = framebuffer->viewport_x; + viewport[1] = framebuffer->viewport_y; + viewport[2] = framebuffer->viewport_width; + viewport[3] = framebuffer->viewport_height; } CoglMatrixStack * -_cogl_draw_buffer_get_modelview_stack (CoglHandle handle) +_cogl_framebuffer_get_modelview_stack (CoglHandle handle) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); - return draw_buffer->modelview_stack; + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); + return framebuffer->modelview_stack; } CoglMatrixStack * -_cogl_draw_buffer_get_projection_stack (CoglHandle handle) +_cogl_framebuffer_get_projection_stack (CoglHandle handle) { - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (handle); - return draw_buffer->projection_stack; + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (handle); + return framebuffer->projection_stack; } CoglHandle @@ -278,7 +278,7 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) GE (glBindRenderbuffer (GL_RENDERBUFFER, 0)); /* We are about to generate and bind a new fbo, so when next flushing the - * journal, we will need to rebind the current draw buffer... */ + * journal, we will need to rebind the current framebuffer... */ ctx->dirty_bound_framebuffer = 1; /* Generate framebuffer */ @@ -329,8 +329,8 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) offscreen = g_new0 (CoglOffscreen, 1); - _cogl_draw_buffer_init (COGL_DRAW_BUFFER (offscreen), - COGL_DRAW_BUFFER_TYPE_OFFSCREEN, + _cogl_framebuffer_init (COGL_FRAMEBUFFER (offscreen), + COGL_FRAMEBUFFER_TYPE_OFFSCREEN, width, height); @@ -341,9 +341,9 @@ cogl_offscreen_new_to_texture (CoglHandle texhandle) * users of the API are hopefully setting up the modelview from scratch * anyway */ #if 0 - cogl_matrix_translate (&draw_buffer->modelview, -1.0f, -1.0f, 0.0f); - cogl_matrix_scale (&draw_buffer->modelview, - 2.0f / draw_buffer->width, 2.0f / draw_buffer->height, 1.0f); + cogl_matrix_translate (&framebuffer->modelview, -1.0f, -1.0f, 0.0f); + cogl_matrix_scale (&framebuffer->modelview, + 2.0f / framebuffer->width, 2.0f / framebuffer->height, 1.0f); #endif return _cogl_offscreen_handle_new (offscreen); @@ -355,7 +355,7 @@ _cogl_offscreen_free (CoglOffscreen *offscreen) _COGL_GET_CONTEXT (ctx, NO_RETVAL); /* Chain up to parent */ - _cogl_draw_buffer_free (COGL_DRAW_BUFFER (offscreen)); + _cogl_framebuffer_free (COGL_FRAMEBUFFER (offscreen)); if (offscreen->gl_stencil_handle) GE (glDeleteRenderbuffers (1, &offscreen->gl_stencil_handle)); @@ -369,12 +369,12 @@ _cogl_onscreen_new (void) CoglOnscreen *onscreen; /* XXX: Until we have full winsys support in Cogl then we can't fully - * implement CoglOnscreen draw buffers, since we can't, e.g. keep track of + * implement CoglOnscreen framebuffers, since we can't, e.g. keep track of * the window size. */ onscreen = g_new0 (CoglOnscreen, 1); - _cogl_draw_buffer_init (COGL_DRAW_BUFFER (onscreen), - COGL_DRAW_BUFFER_TYPE_ONSCREEN, + _cogl_framebuffer_init (COGL_FRAMEBUFFER (onscreen), + COGL_FRAMEBUFFER_TYPE_ONSCREEN, 0xdeadbeef, /* width */ 0xdeadbeef); /* height */ @@ -387,7 +387,7 @@ _cogl_onscreen_free (CoglOnscreen *onscreen) _COGL_GET_CONTEXT (ctx, NO_RETVAL); /* Chain up to parent */ - _cogl_draw_buffer_free (COGL_DRAW_BUFFER (onscreen)); + _cogl_framebuffer_free (COGL_FRAMEBUFFER (onscreen)); g_free (onscreen); } @@ -395,17 +395,17 @@ _cogl_onscreen_free (CoglOnscreen *onscreen) void _cogl_onscreen_clutter_backend_set_size (int width, int height) { - CoglDrawBuffer *draw_buffer; + CoglFramebuffer *framebuffer; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - draw_buffer = COGL_DRAW_BUFFER (ctx->window_buffer); + framebuffer = COGL_FRAMEBUFFER (ctx->window_buffer); - if (draw_buffer->width == width && draw_buffer->height == height) + if (framebuffer->width == width && framebuffer->height == height) return; - draw_buffer->width = width; - draw_buffer->height = height; + framebuffer->width = width; + framebuffer->height = height; /* We'll need to recalculate the GL viewport state derived * from the Cogl viewport */ @@ -413,153 +413,168 @@ _cogl_onscreen_clutter_backend_set_size (int width, int height) } GSList * -_cogl_create_draw_buffer_stack (void) +_cogl_create_framebuffer_stack (void) { GSList *stack = NULL; - CoglDrawBufferStackEntry *entry; - entry = g_slice_new0 (CoglDrawBufferStackEntry); - entry->target = COGL_WINDOW_BUFFER; - entry->draw_buffer = COGL_INVALID_HANDLE; - - return g_slist_prepend (stack, entry); + return g_slist_prepend (stack, COGL_INVALID_HANDLE); } void -_cogl_free_draw_buffer_stack (GSList *stack) +_cogl_free_framebuffer_stack (GSList *stack) { GSList *l; for (l = stack; l != NULL; l = l->next) { - CoglDrawBufferStackEntry *entry = l->data; - CoglDrawBuffer *draw_buffer = COGL_DRAW_BUFFER (entry->draw_buffer); - if (draw_buffer->type == COGL_DRAW_BUFFER_TYPE_OFFSCREEN) - _cogl_offscreen_free (COGL_OFFSCREEN (draw_buffer)); + CoglFramebuffer *framebuffer = COGL_FRAMEBUFFER (l->data); + if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN) + _cogl_offscreen_free (COGL_OFFSCREEN (framebuffer)); else - _cogl_onscreen_free (COGL_ONSCREEN (draw_buffer)); + _cogl_onscreen_free (COGL_ONSCREEN (framebuffer)); } g_slist_free (stack); } -/* XXX: The target argument is redundant; when we break API, we should - * remove it! */ +/* Set the current framebuffer without checking if it's already the + * current framebuffer. This is used by cogl_pop_framebuffer while + * the top of the stack is currently not up to date. */ +static void +_cogl_set_framebuffer_real (CoglFramebuffer *framebuffer) +{ + CoglHandle *entry; + + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + cogl_flush (); + + entry = &ctx->framebuffer_stack->data; + + ctx->dirty_bound_framebuffer = 1; + ctx->dirty_gl_viewport = 1; + + if (framebuffer != COGL_INVALID_HANDLE) + cogl_handle_ref (framebuffer); + if (*entry != COGL_INVALID_HANDLE) + cogl_handle_unref (*entry); + + *entry = framebuffer; + + /* We've effectively just switched the current modelview and + * projection matrix stacks and clip state so we need to dirty + * them to ensure they get flushed for the next batch of geometry + * we flush */ + _cogl_matrix_stack_dirty (framebuffer->modelview_stack); + _cogl_matrix_stack_dirty (framebuffer->projection_stack); + _cogl_clip_stack_state_dirty (&framebuffer->clip_state); +} + +void +cogl_set_framebuffer (CoglHandle handle) +{ + g_return_if_fail (cogl_is_framebuffer (handle)); + + if (_cogl_get_framebuffer () != handle) + _cogl_set_framebuffer_real (COGL_FRAMEBUFFER (handle)); +} + +/* XXX: deprecated API */ void cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle handle) { - CoglDrawBuffer *draw_buffer = NULL; - CoglDrawBufferStackEntry *entry; - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - _cogl_journal_flush (); - - g_assert (ctx->draw_buffer_stack != NULL); - entry = ctx->draw_buffer_stack->data; - if (target == COGL_WINDOW_BUFFER) handle = ctx->window_buffer; - else if (!cogl_is_draw_buffer (handle)) - return; - draw_buffer = COGL_DRAW_BUFFER (handle); - - if (entry->draw_buffer != draw_buffer) - { - entry->target = target; - - ctx->dirty_bound_framebuffer = 1; - ctx->dirty_gl_viewport = 1; - - if (draw_buffer != COGL_INVALID_HANDLE) - cogl_handle_ref (draw_buffer); - if (entry->draw_buffer != COGL_INVALID_HANDLE) - cogl_handle_unref (entry->draw_buffer); - entry->draw_buffer = draw_buffer; - - /* We've effectively just switched the current modelview and - * projection matrix stacks and clip state so we need to dirty - * them to ensure they get flushed for the next batch of geometry - * we flush */ - _cogl_matrix_stack_dirty (draw_buffer->modelview_stack); - _cogl_matrix_stack_dirty (draw_buffer->projection_stack); - _cogl_clip_stack_state_dirty (&draw_buffer->clip_state); - } + cogl_set_framebuffer (handle); } CoglHandle -_cogl_get_draw_buffer (void) +_cogl_get_framebuffer (void) { - CoglDrawBufferStackEntry *entry; - _COGL_GET_CONTEXT (ctx, NULL); - g_assert (ctx->draw_buffer_stack); - entry = ctx->draw_buffer_stack->data; + g_assert (ctx->framebuffer_stack); - return entry->draw_buffer; + return (CoglHandle)ctx->framebuffer_stack->data; } +void +cogl_push_framebuffer (CoglHandle buffer) +{ + _COGL_GET_CONTEXT (ctx, NO_RETVAL); + + g_return_if_fail (cogl_is_framebuffer (buffer)); + g_assert (ctx->framebuffer_stack); + + cogl_flush (); + + ctx->framebuffer_stack = + g_slist_prepend (ctx->framebuffer_stack, COGL_INVALID_HANDLE); + + cogl_set_framebuffer (buffer); +} + +/* XXX: deprecated API */ void cogl_push_draw_buffer (void) { - CoglDrawBufferStackEntry *old; - CoglDrawBufferStackEntry *entry; + cogl_push_framebuffer (_cogl_get_framebuffer ()); +} + +void +cogl_pop_framebuffer (void) +{ + CoglHandle to_pop; + CoglHandle to_restore; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - entry = g_slice_new0 (CoglDrawBufferStackEntry); + g_assert (ctx->framebuffer_stack != NULL); + g_assert (ctx->framebuffer_stack->next != NULL); - g_assert (ctx->draw_buffer_stack); + to_pop = ctx->framebuffer_stack->data; + to_restore = ctx->framebuffer_stack->next->data; - old = ctx->draw_buffer_stack->data; - *entry = *old; + cogl_flush (); - cogl_handle_ref (entry->draw_buffer); + cogl_handle_unref (to_pop); + ctx->framebuffer_stack = + g_slist_remove_link (ctx->framebuffer_stack, + ctx->framebuffer_stack); - ctx->draw_buffer_stack = - g_slist_prepend (ctx->draw_buffer_stack, entry); + /* If the framebuffer has changed as a result of popping the top + * then re-assert the current buffer so as to dirty state as + * necessary. */ + if (to_pop != to_restore) + _cogl_set_framebuffer_real (to_restore); } +/* XXX: deprecated API */ void cogl_pop_draw_buffer (void) { - CoglDrawBufferStackEntry *to_pop; - CoglDrawBufferStackEntry *to_restore; - - _COGL_GET_CONTEXT (ctx, NO_RETVAL); - - g_assert (ctx->draw_buffer_stack != NULL); - - to_pop = ctx->draw_buffer_stack->data; - to_restore = ctx->draw_buffer_stack->next->data; - - cogl_set_draw_buffer (to_restore->target, to_restore->draw_buffer); - - cogl_handle_unref (to_pop->draw_buffer); - ctx->draw_buffer_stack = - g_slist_remove_link (ctx->draw_buffer_stack, - ctx->draw_buffer_stack); - g_slice_free (CoglDrawBufferStackEntry, to_pop); + cogl_pop_framebuffer (); } void -_cogl_draw_buffer_flush_state (CoglHandle handle, - CoglDrawBufferFlushFlags flags) +_cogl_framebuffer_flush_state (CoglHandle handle, + CoglFramebufferFlushFlags flags) { - CoglDrawBuffer *draw_buffer; + CoglFramebuffer *framebuffer; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - draw_buffer = COGL_DRAW_BUFFER (handle); + framebuffer = COGL_FRAMEBUFFER (handle); if (cogl_features_available (COGL_FEATURE_OFFSCREEN) && ctx->dirty_bound_framebuffer) { - if (draw_buffer->type == COGL_DRAW_BUFFER_TYPE_OFFSCREEN) + if (framebuffer->type == COGL_FRAMEBUFFER_TYPE_OFFSCREEN) { GE (glBindFramebuffer (GL_FRAMEBUFFER, - COGL_OFFSCREEN (draw_buffer)->fbo_handle)); + COGL_OFFSCREEN (framebuffer)->fbo_handle)); } else GE (glBindFramebuffer (GL_FRAMEBUFFER, 0)); @@ -573,31 +588,31 @@ _cogl_draw_buffer_flush_state (CoglHandle handle, /* Convert the Cogl viewport y offset to an OpenGL viewport y offset * NB: OpenGL defines its window and viewport origins to be bottom * left, while Cogl defines them to be top left. - * NB: We render upside down to offscreen draw buffers so we don't + * NB: We render upside down to offscreen framebuffers so we don't * need to convert the y offset in this case. */ - if (cogl_is_offscreen (draw_buffer)) - gl_viewport_y = draw_buffer->viewport_y; + if (cogl_is_offscreen (framebuffer)) + gl_viewport_y = framebuffer->viewport_y; else - gl_viewport_y = draw_buffer->height - - (draw_buffer->viewport_y + draw_buffer->viewport_height); + gl_viewport_y = framebuffer->height - + (framebuffer->viewport_y + framebuffer->viewport_height); - GE (glViewport (draw_buffer->viewport_x, + GE (glViewport (framebuffer->viewport_x, gl_viewport_y, - draw_buffer->viewport_width, - draw_buffer->viewport_height)); + framebuffer->viewport_width, + framebuffer->viewport_height)); ctx->dirty_gl_viewport = FALSE; } /* XXX: Flushing clip state may trash the modelview and projection * matrices so we must do it before flushing the matrices... */ - _cogl_flush_clip_state (&draw_buffer->clip_state); + _cogl_flush_clip_state (&framebuffer->clip_state); - if (!(flags & COGL_DRAW_BUFFER_FLUSH_SKIP_MODELVIEW)) - _cogl_matrix_stack_flush_to_gl (draw_buffer->modelview_stack, + if (!(flags & COGL_FRAMEBUFFER_FLUSH_SKIP_MODELVIEW)) + _cogl_matrix_stack_flush_to_gl (framebuffer->modelview_stack, COGL_MATRIX_MODELVIEW); - _cogl_matrix_stack_flush_to_gl (draw_buffer->projection_stack, + _cogl_matrix_stack_flush_to_gl (framebuffer->projection_stack, COGL_MATRIX_PROJECTION); } diff --git a/clutter/cogl/cogl/cogl-journal.c b/clutter/cogl/cogl/cogl-journal.c index 97110a9f1..db406ea9c 100644 --- a/clutter/cogl/cogl/cogl-journal.c +++ b/clutter/cogl/cogl/cogl-journal.c @@ -32,7 +32,7 @@ #include "cogl-texture-private.h" #include "cogl-material-private.h" #include "cogl-vertex-buffer-private.h" -#include "cogl-draw-buffer-private.h" +#include "cogl-framebuffer-private.h" #include #include @@ -533,7 +533,7 @@ _cogl_journal_flush (void) GLuint journal_vbo; gboolean vbo_fallback = (cogl_get_features () & COGL_FEATURE_VBOS) ? FALSE : TRUE; - CoglHandle draw_buffer; + CoglHandle framebuffer; CoglMatrixStack *modelview_stack; _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -551,8 +551,8 @@ _cogl_journal_flush (void) else state.vbo_offset = (char *)ctx->logged_vertices->data; - draw_buffer = _cogl_get_draw_buffer (); - modelview_stack = _cogl_draw_buffer_get_modelview_stack (draw_buffer); + framebuffer = _cogl_get_framebuffer (); + modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer); state.modelview_stack = modelview_stack; _cogl_matrix_stack_push (modelview_stack); @@ -618,8 +618,8 @@ _cogl_journal_init (void) * that themselves depend on the journal, such as clip state. */ /* NB: the journal deals with flushing the modelview stack manually */ - _cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), - COGL_DRAW_BUFFER_FLUSH_SKIP_MODELVIEW); + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), + COGL_FRAMEBUFFER_FLUSH_SKIP_MODELVIEW); } void diff --git a/clutter/cogl/cogl/cogl-matrix-stack.c b/clutter/cogl/cogl/cogl-matrix-stack.c index c6236efd3..fd59433bf 100644 --- a/clutter/cogl/cogl/cogl-matrix-stack.c +++ b/clutter/cogl/cogl/cogl-matrix-stack.c @@ -33,7 +33,7 @@ #include "cogl-context.h" #include "cogl-internal.h" #include "cogl-matrix-stack.h" -#include "cogl-draw-buffer-private.h" +#include "cogl-framebuffer-private.h" typedef struct { CoglMatrix matrix; @@ -426,11 +426,11 @@ _cogl_matrix_stack_flush_to_gl (CoglMatrixStack *stack, } /* Because Cogl defines texture coordinates to have a top left origin and - * because offscreen draw buffers may be used for rendering to textures we + * because offscreen framebuffers may be used for rendering to textures we * always render upside down to offscreen buffers. */ if (mode == COGL_MATRIX_PROJECTION && - cogl_is_offscreen (_cogl_get_draw_buffer ())) + cogl_is_offscreen (_cogl_get_framebuffer ())) { CoglMatrix flipped_projection; CoglMatrix *projection = diff --git a/clutter/cogl/cogl/cogl-primitives.c b/clutter/cogl/cogl/cogl-primitives.c index 8ccbcce14..b68c7e4d8 100644 --- a/clutter/cogl/cogl/cogl-primitives.c +++ b/clutter/cogl/cogl/cogl-primitives.c @@ -32,7 +32,7 @@ #include "cogl-texture-private.h" #include "cogl-material-private.h" #include "cogl-vertex-buffer-private.h" -#include "cogl-draw-buffer-private.h" +#include "cogl-framebuffer-private.h" #include #include @@ -862,10 +862,10 @@ cogl_polygon (CoglTextureVertex *vertices, _cogl_journal_flush (); - /* NB: _cogl_draw_buffer_flush_state may disrupt various state (such + /* NB: _cogl_framebuffer_flush_state may disrupt various state (such * as the material state) when flushing the clip stack, so should * always be done first when preparing to draw. */ - _cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); material = ctx->source_material; layers = cogl_material_get_layers (ctx->source_material); @@ -1062,10 +1062,10 @@ _cogl_path_stroke_nodes (void) _cogl_journal_flush (); - /* NB: _cogl_draw_buffer_flush_state may disrupt various state (such + /* NB: _cogl_framebuffer_flush_state may disrupt various state (such * as the material state) when flushing the clip stack, so should * always be done first when preparing to draw. */ - _cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); enable_flags |= _cogl_material_get_cogl_enable_flags (ctx->source_material); cogl_enable (enable_flags); @@ -1121,11 +1121,11 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, unsigned long enable_flags = COGL_ENABLE_VERTEX_ARRAY; CoglHandle prev_source; int i; - CoglHandle draw_buffer = _cogl_get_draw_buffer (); + CoglHandle framebuffer = _cogl_get_framebuffer (); CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (draw_buffer); + _cogl_framebuffer_get_modelview_stack (framebuffer); CoglMatrixStack *projection_stack = - _cogl_draw_buffer_get_projection_stack (draw_buffer); + _cogl_framebuffer_get_projection_stack (framebuffer); _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -1134,10 +1134,10 @@ _cogl_add_path_to_stencil_buffer (floatVec2 nodes_min, * so we need to flush any batched geometry first */ _cogl_journal_flush (); - /* NB: _cogl_draw_buffer_flush_state may disrupt various state (such + /* NB: _cogl_framebuffer_flush_state may disrupt various state (such * as the material state) when flushing the clip stack, so should * always be done first when preparing to draw. */ - _cogl_draw_buffer_flush_state (draw_buffer, 0); + _cogl_framebuffer_flush_state (framebuffer, 0); /* Just setup a simple material that doesn't use texturing... */ prev_source = cogl_handle_ref (ctx->source_material); @@ -1311,10 +1311,10 @@ _cogl_path_fill_nodes_scanlines (CoglPathNode *path, */ _cogl_journal_flush (); - /* NB: _cogl_draw_buffer_flush_state may disrupt various state (such + /* NB: _cogl_framebuffer_flush_state may disrupt various state (such * as the material state) when flushing the clip stack, so should * always be done first when preparing to draw. */ - _cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); _cogl_material_flush_gl_state (ctx->source_material, NULL); @@ -1477,13 +1477,13 @@ _cogl_path_fill_nodes (void) if (G_LIKELY (!(cogl_debug_flags & COGL_DEBUG_FORCE_SCANLINE_PATHS)) && cogl_features_available (COGL_FEATURE_STENCIL_BUFFER)) { - CoglHandle draw_buffer; + CoglHandle framebuffer; CoglClipStackState *clip_state; _cogl_journal_flush (); - draw_buffer = _cogl_get_draw_buffer (); - clip_state = _cogl_draw_buffer_get_clip_state (draw_buffer); + framebuffer = _cogl_get_framebuffer (); + clip_state = _cogl_framebuffer_get_clip_state (framebuffer); _cogl_add_path_to_stencil_buffer (ctx->path_nodes_min, ctx->path_nodes_max, diff --git a/clutter/cogl/cogl/cogl-texture.c b/clutter/cogl/cogl/cogl-texture.c index 18dcb69fe..5b3950bc3 100644 --- a/clutter/cogl/cogl/cogl-texture.c +++ b/clutter/cogl/cogl/cogl-texture.c @@ -42,7 +42,7 @@ #include "cogl-context.h" #include "cogl-handle.h" #include "cogl-primitives.h" -#include "cogl-draw-buffer-private.h" +#include "cogl-framebuffer-private.h" #include #include @@ -601,7 +601,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex, GLuint target_gl_type) { gint bpp; - CoglHandle draw_buffer; + CoglHandle framebuffer; int viewport[4]; CoglBitmap alpha_bmp; CoglHandle prev_source; @@ -612,9 +612,9 @@ _cogl_texture_draw_and_read (CoglTexture *tex, bpp = _cogl_get_format_bpp (COGL_PIXEL_FORMAT_RGBA_8888); - draw_buffer = _cogl_get_draw_buffer (); + framebuffer = _cogl_get_framebuffer (); /* Viewport needs to have some size and be inside the window for this */ - _cogl_draw_buffer_get_viewport4fv (draw_buffer, viewport); + _cogl_framebuffer_get_viewport4fv (framebuffer, viewport); if (viewport[0] < 0 || viewport[1] < 0 || viewport[2] <= 0 || viewport[3] <= 0) return FALSE; @@ -624,7 +624,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex, * works) */ - projection_stack = _cogl_draw_buffer_get_projection_stack (draw_buffer); + projection_stack = _cogl_framebuffer_get_projection_stack (framebuffer); _cogl_matrix_stack_push (projection_stack); _cogl_matrix_stack_load_identity (projection_stack); _cogl_matrix_stack_ortho (projection_stack, @@ -633,7 +633,7 @@ _cogl_texture_draw_and_read (CoglTexture *tex, (float)(0), (float)(100)); - modelview_stack = _cogl_draw_buffer_get_modelview_stack (draw_buffer); + modelview_stack = _cogl_framebuffer_get_modelview_stack (framebuffer); _cogl_matrix_stack_push (modelview_stack); _cogl_matrix_stack_load_identity (modelview_stack); diff --git a/clutter/cogl/cogl/cogl-vertex-buffer.c b/clutter/cogl/cogl/cogl-vertex-buffer.c index fc44009d8..26d09ce01 100644 --- a/clutter/cogl/cogl/cogl-vertex-buffer.c +++ b/clutter/cogl/cogl/cogl-vertex-buffer.c @@ -138,7 +138,7 @@ #include "cogl-texture-private.h" #include "cogl-material-private.h" #include "cogl-primitives.h" -#include "cogl-draw-buffer-private.h" +#include "cogl-framebuffer-private.h" #define PAD_FOR_ALIGNMENT(VAR, TYPE_SIZE) \ (VAR = TYPE_SIZE + ((VAR - 1) & ~(TYPE_SIZE - 1))) @@ -1666,10 +1666,10 @@ enable_state_for_drawing_buffer (CoglVertexBuffer *buffer) } ctx->n_texcoord_arrays_enabled = max_texcoord_attrib_unit + 1; - /* NB: _cogl_draw_buffer_flush_state may disrupt various state (such + /* NB: _cogl_framebuffer_flush_state may disrupt various state (such * as the material state) when flushing the clip stack, so should * always be done first when preparing to draw. */ - _cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); options.flags = COGL_MATERIAL_FLUSH_FALLBACK_MASK | diff --git a/clutter/cogl/cogl/cogl.c b/clutter/cogl/cogl/cogl.c index 04917e872..aa61fd590 100644 --- a/clutter/cogl/cogl/cogl.c +++ b/clutter/cogl/cogl/cogl.c @@ -38,7 +38,7 @@ #include "cogl-context.h" #include "cogl-material-private.h" #include "cogl-winsys.h" -#include "cogl-draw-buffer-private.h" +#include "cogl-framebuffer-private.h" #include "cogl-matrix-private.h" #if defined (HAVE_COGL_GLES2) || defined (HAVE_COGL_GLES) @@ -120,10 +120,10 @@ cogl_clear (const CoglColor *color, gulong buffers) _cogl_journal_flush (); - /* NB: _cogl_draw_buffer_flush_state may disrupt various state (such + /* NB: _cogl_framebuffer_flush_state may disrupt various state (such * as the material state) when flushing the clip stack, so should * always be done first when preparing to draw. */ - _cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); if (buffers & COGL_BUFFER_BIT_COLOR) { @@ -304,7 +304,7 @@ _cogl_flush_face_winding (void) * all offscreen rendering is done upside down resulting in reversed winding * for all triangles. */ - if (cogl_is_offscreen (_cogl_get_draw_buffer ())) + if (cogl_is_offscreen (_cogl_get_framebuffer ())) winding = COGL_FRONT_WINDING_CLOCKWISE; else winding = COGL_FRONT_WINDING_COUNTER_CLOCKWISE; @@ -343,13 +343,13 @@ cogl_set_viewport (int x, int width, int height) { - CoglHandle draw_buffer; + CoglHandle framebuffer; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - draw_buffer = _cogl_get_draw_buffer (); + framebuffer = _cogl_get_framebuffer (); - _cogl_draw_buffer_set_viewport (draw_buffer, + _cogl_framebuffer_set_viewport (framebuffer, x, y, width, @@ -430,7 +430,7 @@ _cogl_setup_viewport (guint width, z_camera = 0.5 * projection_matrix.xx; modelview_stack = - _cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_load_identity (modelview_stack); _cogl_matrix_stack_translate (modelview_stack, -0.5f, -0.5f, -z_camera); _cogl_matrix_stack_scale (modelview_stack, @@ -463,19 +463,19 @@ cogl_features_available (CoglFeatureFlags features) /* XXX: This function should either be replaced with one returning * integers, or removed/deprecated and make the - * _cogl_draw_buffer_get_viewport* functions public. + * _cogl_framebuffer_get_viewport* functions public. */ void cogl_get_viewport (float v[4]) { - CoglHandle draw_buffer; + CoglHandle framebuffer; int viewport[4]; int i; _COGL_GET_CONTEXT (ctx, NO_RETVAL); - draw_buffer = _cogl_get_draw_buffer (); - _cogl_draw_buffer_get_viewport4fv (draw_buffer, viewport); + framebuffer = _cogl_get_framebuffer (); + _cogl_framebuffer_get_viewport4fv (framebuffer, viewport); for (i = 0; i < 4; i++) v[i] = viewport[i]; @@ -585,8 +585,8 @@ cogl_read_pixels (int x, CoglPixelFormat format, guint8 *pixels) { - CoglHandle draw_buffer; - int draw_buffer_height; + CoglHandle framebuffer; + int framebuffer_height; int rowstride = width * 4; guint8 *temprow; @@ -595,13 +595,17 @@ cogl_read_pixels (int x, g_return_if_fail (format == COGL_PIXEL_FORMAT_RGBA_8888); g_return_if_fail (source == COGL_READ_PIXELS_COLOR_BUFFER); + /* make sure any batched primitives get emitted to the GL driver before + * issuing our read pixels... */ + cogl_flush (); + temprow = g_alloca (rowstride * sizeof (guint8)); - draw_buffer = _cogl_get_draw_buffer (); + framebuffer = _cogl_get_framebuffer (); - _cogl_draw_buffer_flush_state (draw_buffer, 0); + _cogl_framebuffer_flush_state (framebuffer, 0); - draw_buffer_height = _cogl_draw_buffer_get_height (draw_buffer); + framebuffer_height = _cogl_framebuffer_get_height (framebuffer); /* The y co-ordinate should be given in OpenGL's coordinate system * so 0 is the bottom row @@ -609,12 +613,8 @@ cogl_read_pixels (int x, * NB: all offscreen rendering is done upside down so no conversion * is necissary in this case. */ - if (!cogl_is_offscreen (draw_buffer)) - y = draw_buffer_height - y - height; - - /* make sure any batched primitives get emitted to the GL driver before - * issuing our read pixels... */ - cogl_flush (); + if (!cogl_is_offscreen (framebuffer)) + y = framebuffer_height - y - height; /* Setup the pixel store parameters that may have been changed by Cogl */ @@ -629,7 +629,7 @@ cogl_read_pixels (int x, /* NB: All offscreen rendering is done upside down so there is no need * to flip in this case... */ - if (cogl_is_offscreen (draw_buffer)) + if (cogl_is_offscreen (framebuffer)) return; /* TODO: consider using the GL_MESA_pack_invert extension in the future @@ -676,10 +676,10 @@ cogl_begin_gl (void) /* Flush framebuffer state, including clip state, modelview and * projection matrix state * - * NB: _cogl_draw_buffer_flush_state may disrupt various state (such + * NB: _cogl_framebuffer_flush_state may disrupt various state (such * as the material state) when flushing the clip stack, so should * always be done first when preparing to draw. */ - _cogl_draw_buffer_flush_state (_cogl_get_draw_buffer (), 0); + _cogl_framebuffer_flush_state (_cogl_get_framebuffer (), 0); /* Setup the state for the current material */ @@ -791,7 +791,7 @@ void cogl_push_matrix (void) { CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_push (modelview_stack); } @@ -799,7 +799,7 @@ void cogl_pop_matrix (void) { CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_pop (modelview_stack); } @@ -807,7 +807,7 @@ void cogl_scale (float x, float y, float z) { CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_scale (modelview_stack, x, y, z); } @@ -815,7 +815,7 @@ void cogl_translate (float x, float y, float z) { CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_translate (modelview_stack, x, y, z); } @@ -823,7 +823,7 @@ void cogl_rotate (float angle, float x, float y, float z) { CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_rotate (modelview_stack, angle, x, y, z); } @@ -852,7 +852,7 @@ cogl_frustum (float left, float z_far) { CoglMatrixStack *projection_stack = - _cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_projection_stack (_cogl_get_framebuffer ()); _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -877,7 +877,7 @@ cogl_ortho (float left, { CoglMatrix ortho; CoglMatrixStack *projection_stack = - _cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_projection_stack (_cogl_get_framebuffer ()); _COGL_GET_CONTEXT (ctx, NO_RETVAL); @@ -890,7 +890,7 @@ void cogl_get_modelview_matrix (CoglMatrix *matrix) { CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_get (modelview_stack, matrix); _COGL_MATRIX_DEBUG_PRINT (matrix); } @@ -899,7 +899,7 @@ void cogl_set_modelview_matrix (CoglMatrix *matrix) { CoglMatrixStack *modelview_stack = - _cogl_draw_buffer_get_modelview_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_modelview_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_set (modelview_stack, matrix); _COGL_MATRIX_DEBUG_PRINT (matrix); } @@ -908,7 +908,7 @@ void cogl_get_projection_matrix (CoglMatrix *matrix) { CoglMatrixStack *projection_stack = - _cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_projection_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_get (projection_stack, matrix); _COGL_MATRIX_DEBUG_PRINT (matrix); } @@ -917,7 +917,7 @@ void cogl_set_projection_matrix (CoglMatrix *matrix) { CoglMatrixStack *projection_stack = - _cogl_draw_buffer_get_projection_stack (_cogl_get_draw_buffer ()); + _cogl_framebuffer_get_projection_stack (_cogl_get_framebuffer ()); _cogl_matrix_stack_set (projection_stack, matrix); /* FIXME: Update the inverse projection matrix!! Presumably use @@ -928,10 +928,10 @@ cogl_set_projection_matrix (CoglMatrix *matrix) CoglClipStackState * _cogl_get_clip_state (void) { - CoglHandle draw_buffer; + CoglHandle framebuffer; - draw_buffer = _cogl_get_draw_buffer (); - return _cogl_draw_buffer_get_clip_state (draw_buffer); + framebuffer = _cogl_get_framebuffer (); + return _cogl_framebuffer_get_clip_state (framebuffer); } GQuark diff --git a/clutter/cogl/cogl/cogl.h b/clutter/cogl/cogl/cogl.h index 9f3442851..5782989c8 100644 --- a/clutter/cogl/cogl/cogl.h +++ b/clutter/cogl/cogl/cogl.h @@ -736,8 +736,8 @@ void cogl_clip_ensure (void) G_GNUC_DEPRECATED; * cogl_clip_stack_restore(). * * Deprecated: 1.2: This was originally added to allow us to save the - * clip stack when switching to an offscreen draw buffer, but it's - * not necessary anymore given that draw buffers now own separate + * clip stack when switching to an offscreen framebuffer, but it's + * not necessary anymore given that framebuffers now own separate * clip stacks which will be automatically switched between when a * new buffer is set. Calling this function has no effect * @@ -752,8 +752,8 @@ void cogl_clip_stack_save (void) G_GNUC_DEPRECATED; * by cogl_clip_stack_save(). * * Deprecated: 1.2: This was originally added to allow us to restore - * the clip stack when switching back from an offscreen draw buffer, - * but it's not necessary anymore given that draw buffers now own + * the clip stack when switching back from an offscreen framebuffer, + * but it's not necessary anymore given that framebuffers now own * separate clip stacks which will be automatically switched between * when a new buffer is set. Calling this function has no effect * @@ -763,34 +763,85 @@ void cogl_clip_stack_restore (void) G_GNUC_DEPRECATED; #endif /* COGL_DISABLE_DEPRECATED */ +/** + * cogl_set_framebuffer: + * @buffer: The #CoglHandle of a Cogl framebuffer; either onscreen or + * offscreen. + * + * This redirects all subsequent drawing to the specified framebuffer. This + * can either be an offscreen buffer created with + * cogl_offscreen_new_to_texture () or you can revert to your original + * onscreen window buffer. + * + * Since: 1.2 + */ +void cogl_set_framebuffer (CoglHandle buffer); + +/** + * cogl_push_framebuffer: + * @buffer: The #CoglHandle of a Cogl framebuffer; either onscreen or + * offscreen. + * + * Redirects all subsequent drawing to the specified framebuffer. This + * can either be an offscreen buffer created with + * cogl_offscreen_new_to_texture () or you can revert to your original + * onscreen window buffer. + * + * The previous framebuffer can be restored by calling cogl_pop_framebuffer() + * + * Since: 1.2 + */ +void cogl_push_framebuffer (CoglHandle buffer); + +/** + * cogl_pop_framebuffer: + * + * Restores the framebuffer that was previously at the top of the stack. + * All subsequent drawing will be redirected to this framebuffer. + * + * Since: 1.2 + */ +void cogl_pop_framebuffer (void); + +#ifndef COGL_DISABLE_DEPRECATED + /** * cogl_set_draw_buffer: - * @target: A #CoglBufferTarget that specifies what kind of draw buffer you + * @target: A #CoglBufferTarget that specifies what kind of framebuffer you * are setting as the render target. - * @offscreen: If you are setting a draw buffer of type COGL_OFFSCREEN_BUFFER + * @offscreen: If you are setting a framebuffer of type COGL_OFFSCREEN_BUFFER * then this is a CoglHandle for the offscreen buffer. * - * This redirects all subsequent drawing to the specified draw buffer. This + * Redirects all subsequent drawing to the specified framebuffer. This * can either be an offscreen buffer created with * cogl_offscreen_new_to_texture () or you can revert to your original * on screen window buffer. + * + * Deprecated: 1.2: The target argument was redundant since we could look at + * the type of CoglHandle given instead. */ void cogl_set_draw_buffer (CoglBufferTarget target, - CoglHandle offscreen); + CoglHandle offscreen) G_GNUC_DEPRECATED; /** * cogl_push_draw_buffer: * * Save cogl_set_draw_buffer() state. + * + * Deprecated: 1.2: The draw buffer API was replaced with a framebuffer API */ -void cogl_push_draw_buffer (void); +void cogl_push_draw_buffer (void) G_GNUC_DEPRECATED; /** * cogl_pop_draw_buffer: * * Restore cogl_set_draw_buffer() state. + * + * Deprecated: 1.2: The draw buffer API was replaced with a framebuffer API */ -void cogl_pop_draw_buffer (void); +void cogl_pop_draw_buffer (void) G_GNUC_DEPRECATED; + +#endif /* COGL_DISABLE_DEPRECATED */ /** * CoglReadPixelsFlags: @@ -816,7 +867,7 @@ typedef enum { /*< prefix=COGL_READ_PIXELS >*/ * (only COGL_PIXEL_FORMAT_RGBA_8888 supported currently) * @pixels: The location to write the pixel data. * - * This reads a rectangle of pixels from the current draw buffer where + * This reads a rectangle of pixels from the current framebuffer where * position (0, 0) is the top left. The pixel at (x, y) is the first * read, and the data is returned with a rowstride of (width * 4) */ diff --git a/doc/reference/cogl/cogl-sections.txt b/doc/reference/cogl/cogl-sections.txt index c771d2f97..336f9ad03 100644 --- a/doc/reference/cogl/cogl-sections.txt +++ b/doc/reference/cogl/cogl-sections.txt @@ -245,6 +245,9 @@ cogl_offscreen_new_to_texture cogl_offscreen_ref cogl_offscreen_unref cogl_is_offscreen +cogl_set_framebuffer +cogl_push_frameffer +cogl_pop_framebuffer cogl_set_draw_buffer cogl_pop_draw_buffer cogl_push_draw_buffer diff --git a/tests/conform/test-backface-culling.c b/tests/conform/test-backface-culling.c index ddae9822c..f25818753 100644 --- a/tests/conform/test-backface-culling.c +++ b/tests/conform/test-backface-culling.c @@ -215,15 +215,14 @@ on_paint (ClutterActor *actor, TestState *state) cogl_clear (&clr, COGL_BUFFER_BIT_COLOR|COGL_BUFFER_BIT_STENCIL); /* - * Now repeat the test but rendered to an offscreen draw buffer... + * Now repeat the test but rendered to an offscreen framebuffer... */ cogl_get_viewport (stage_viewport); cogl_get_projection_matrix (&stage_projection); cogl_get_modelview_matrix (&stage_modelview); - cogl_push_draw_buffer (); - cogl_set_draw_buffer (0 /* unused */, state->offscreen); + cogl_push_framebuffer (state->offscreen); cogl_clear (&clr, COGL_BUFFER_BIT_COLOR|COGL_BUFFER_BIT_STENCIL); @@ -236,7 +235,7 @@ on_paint (ClutterActor *actor, TestState *state) do_test_backface_culling (state); - cogl_pop_draw_buffer (); + cogl_pop_framebuffer (); /* Incase we want feedback of what was drawn offscreen we draw it * to the stage... */ diff --git a/tests/conform/test-cogl-offscreen.c b/tests/conform/test-cogl-offscreen.c index f6f4a972a..d9ba05986 100644 --- a/tests/conform/test-cogl-offscreen.c +++ b/tests/conform/test-cogl-offscreen.c @@ -8,8 +8,8 @@ #define GREEN 1 #define BLUE 2 -#define DRAW_BUFFER_WIDTH 640 -#define DRAW_BUFFER_HEIGHT 480 +#define FRAMEBUFFER_WIDTH 640 +#define FRAMEBUFFER_HEIGHT 480 static const ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; @@ -38,18 +38,18 @@ on_paint (ClutterActor *actor, void *state) cogl_set_projection_matrix (&projection); cogl_set_modelview_matrix (&modelview); - data = g_malloc (DRAW_BUFFER_WIDTH * 4 * DRAW_BUFFER_HEIGHT); - tex = cogl_texture_new_from_data (DRAW_BUFFER_WIDTH, DRAW_BUFFER_HEIGHT, + data = g_malloc (FRAMEBUFFER_WIDTH * 4 * FRAMEBUFFER_HEIGHT); + tex = cogl_texture_new_from_data (FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_RGBA_8888, /* data fmt */ COGL_PIXEL_FORMAT_ANY, /* internal fmt */ - DRAW_BUFFER_WIDTH * 4, /* rowstride */ + FRAMEBUFFER_WIDTH * 4, /* rowstride */ data); g_free (data); offscreen = cogl_offscreen_new_to_texture (tex); - /* Set a scale and translate transform on the window draw buffer before - * switching to the offscreen draw buffer so we can verify it gets restored + /* Set a scale and translate transform on the window framebuffer before + * switching to the offscreen framebuffer so we can verify it gets restored * when we switch back * * The test is going to draw a grid of 4 colors to a texture which we @@ -60,15 +60,14 @@ on_paint (ClutterActor *actor, void *state) cogl_translate (0.5, 0.5, 0); cogl_scale (-0.5, 0.5, 1); - cogl_push_draw_buffer (); - cogl_set_draw_buffer (0 /* unused */, offscreen); + cogl_push_framebuffer (offscreen); - /* Cogl should release the last reference when we call cogl_pop_draw_buffer() + /* Cogl should release the last reference when we call cogl_pop_framebuffer() */ cogl_handle_unref (offscreen); /* Setup something other than the identity matrix for the modelview so we can - * verify it gets restored when we call cogl_pop_draw_buffer () */ + * verify it gets restored when we call cogl_pop_framebuffer () */ cogl_scale (2, 2, 1); /* red, top left */ @@ -84,7 +83,7 @@ on_paint (ClutterActor *actor, void *state) cogl_set_source_color4ub (0xff, 0xff, 0xff, 0xff); cogl_rectangle (0, 0, 0.5, -0.5); - cogl_pop_draw_buffer (); + cogl_pop_framebuffer (); cogl_set_source_texture (tex); cogl_rectangle (-1, 1, 1, -1); @@ -95,28 +94,28 @@ on_paint (ClutterActor *actor, void *state) * top right corner of the window. */ /* red, top right */ - cogl_read_pixels (DRAW_BUFFER_WIDTH - 1, 0, 1, 1, + cogl_read_pixels (FRAMEBUFFER_WIDTH - 1, 0, 1, 1, COGL_READ_PIXELS_COLOR_BUFFER, COGL_PIXEL_FORMAT_RGBA_8888, pixel); g_assert (pixel[RED] == 0xff && pixel[GREEN] == 0x00 && pixel[BLUE] == 0x00); /* green, top left */ - cogl_read_pixels ((DRAW_BUFFER_WIDTH/2), 0, 1, 1, + cogl_read_pixels ((FRAMEBUFFER_WIDTH/2), 0, 1, 1, COGL_READ_PIXELS_COLOR_BUFFER, COGL_PIXEL_FORMAT_RGBA_8888, pixel); g_assert (pixel[RED] == 0x00 && pixel[GREEN] == 0xff && pixel[BLUE] == 0x00); /* blue, bottom right */ - cogl_read_pixels (DRAW_BUFFER_WIDTH - 1, (DRAW_BUFFER_HEIGHT/2) - 1, 1, 1, + cogl_read_pixels (FRAMEBUFFER_WIDTH - 1, (FRAMEBUFFER_HEIGHT/2) - 1, 1, 1, COGL_READ_PIXELS_COLOR_BUFFER, COGL_PIXEL_FORMAT_RGBA_8888, pixel); g_assert (pixel[RED] == 0x00 && pixel[GREEN] == 0x00 && pixel[BLUE] == 0xff); /* white, bottom left */ - cogl_read_pixels ((DRAW_BUFFER_WIDTH/2), (DRAW_BUFFER_HEIGHT/2) - 1, 1, 1, + cogl_read_pixels ((FRAMEBUFFER_WIDTH/2), (FRAMEBUFFER_HEIGHT/2) - 1, 1, 1, COGL_READ_PIXELS_COLOR_BUFFER, COGL_PIXEL_FORMAT_RGBA_8888, pixel); @@ -145,7 +144,7 @@ test_cogl_offscreen (TestConformSimpleFixture *fixture, stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); - clutter_actor_set_size (stage, DRAW_BUFFER_WIDTH, DRAW_BUFFER_HEIGHT); + clutter_actor_set_size (stage, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT); /* We force continuous redrawing of the stage, since we need to skip * the first few frames, and we wont be doing anything else that diff --git a/tests/conform/test-cogl-readpixels.c b/tests/conform/test-cogl-readpixels.c index 563efdf60..eb29da0f9 100644 --- a/tests/conform/test-cogl-readpixels.c +++ b/tests/conform/test-cogl-readpixels.c @@ -8,8 +8,8 @@ #define GREEN 1 #define BLUE 2 -#define DRAW_BUFFER_WIDTH 640 -#define DRAW_BUFFER_HEIGHT 480 +#define FRAMEBUFFER_WIDTH 640 +#define FRAMEBUFFER_HEIGHT 480 static const ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; @@ -39,21 +39,20 @@ on_paint (ClutterActor *actor, void *state) cogl_set_modelview_matrix (&modelview); /* All offscreen rendering is done upside down so the first thing we - * verify is reading back grid of colors from a CoglOffscreen draw buffer + * verify is reading back grid of colors from a CoglOffscreen framebuffer */ - data = g_malloc (DRAW_BUFFER_WIDTH * 4 * DRAW_BUFFER_HEIGHT); - tex = cogl_texture_new_from_data (DRAW_BUFFER_WIDTH, DRAW_BUFFER_HEIGHT, + data = g_malloc (FRAMEBUFFER_WIDTH * 4 * FRAMEBUFFER_HEIGHT); + tex = cogl_texture_new_from_data (FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_RGBA_8888, /* data fmt */ COGL_PIXEL_FORMAT_ANY, /* internal fmt */ - DRAW_BUFFER_WIDTH * 4, /* rowstride */ + FRAMEBUFFER_WIDTH * 4, /* rowstride */ data); g_free (data); offscreen = cogl_offscreen_new_to_texture (tex); - cogl_push_draw_buffer (); - cogl_set_draw_buffer (0 /* unused */, offscreen); + cogl_push_framebuffer (offscreen); /* red, top left */ cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff); @@ -68,39 +67,39 @@ on_paint (ClutterActor *actor, void *state) cogl_set_source_color4ub (0xff, 0xff, 0xff, 0xff); cogl_rectangle (0, 0, 1, -1); - pixels = g_malloc0 (DRAW_BUFFER_WIDTH * 4 * DRAW_BUFFER_HEIGHT); - cogl_read_pixels (0, 0, DRAW_BUFFER_WIDTH, DRAW_BUFFER_HEIGHT, + pixels = g_malloc0 (FRAMEBUFFER_WIDTH * 4 * FRAMEBUFFER_HEIGHT); + cogl_read_pixels (0, 0, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT, COGL_READ_PIXELS_COLOR_BUFFER, COGL_PIXEL_FORMAT_RGBA_8888, (guchar *)pixels); g_assert (pixels[0] == 0xff0000ff); - g_assert (pixels[DRAW_BUFFER_WIDTH - 1] == 0xff00ff00); - g_assert (pixels[(DRAW_BUFFER_HEIGHT - 1) * DRAW_BUFFER_WIDTH] == 0xffff0000); - g_assert (pixels[(DRAW_BUFFER_HEIGHT - 1) * DRAW_BUFFER_WIDTH + - DRAW_BUFFER_WIDTH - 1] == 0xffffffff); + g_assert (pixels[FRAMEBUFFER_WIDTH - 1] == 0xff00ff00); + g_assert (pixels[(FRAMEBUFFER_HEIGHT - 1) * FRAMEBUFFER_WIDTH] == 0xffff0000); + g_assert (pixels[(FRAMEBUFFER_HEIGHT - 1) * FRAMEBUFFER_WIDTH + + FRAMEBUFFER_WIDTH - 1] == 0xffffffff); g_free (pixels); - cogl_pop_draw_buffer (); + cogl_pop_framebuffer (); cogl_handle_unref (offscreen); - /* Now verify reading back from an onscreen draw buffer... + /* Now verify reading back from an onscreen framebuffer... */ cogl_set_source_texture (tex); cogl_rectangle (-1, 1, 1, -1); - pixels = g_malloc0 (DRAW_BUFFER_WIDTH * 4 * DRAW_BUFFER_HEIGHT); - cogl_read_pixels (0, 0, DRAW_BUFFER_WIDTH, DRAW_BUFFER_HEIGHT, + pixels = g_malloc0 (FRAMEBUFFER_WIDTH * 4 * FRAMEBUFFER_HEIGHT); + cogl_read_pixels (0, 0, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT, COGL_READ_PIXELS_COLOR_BUFFER, COGL_PIXEL_FORMAT_RGBA_8888, (guchar *)pixels); g_assert (pixels[0] == 0xff0000ff); - g_assert (pixels[DRAW_BUFFER_WIDTH - 1] == 0xff00ff00); - g_assert (pixels[(DRAW_BUFFER_HEIGHT - 1) * DRAW_BUFFER_WIDTH] == 0xffff0000); - g_assert (pixels[(DRAW_BUFFER_HEIGHT - 1) * DRAW_BUFFER_WIDTH + - DRAW_BUFFER_WIDTH - 1] == 0xffffffff); + g_assert (pixels[FRAMEBUFFER_WIDTH - 1] == 0xff00ff00); + g_assert (pixels[(FRAMEBUFFER_HEIGHT - 1) * FRAMEBUFFER_WIDTH] == 0xffff0000); + g_assert (pixels[(FRAMEBUFFER_HEIGHT - 1) * FRAMEBUFFER_WIDTH + + FRAMEBUFFER_WIDTH - 1] == 0xffffffff); g_free (pixels); cogl_handle_unref (tex); @@ -129,7 +128,7 @@ test_cogl_readpixels (TestConformSimpleFixture *fixture, stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); - clutter_actor_set_size (stage, DRAW_BUFFER_WIDTH, DRAW_BUFFER_HEIGHT); + clutter_actor_set_size (stage, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT); /* We force continuous redrawing of the stage, since we need to skip * the first few frames, and we wont be doing anything else that diff --git a/tests/conform/test-cogl-viewport.c b/tests/conform/test-cogl-viewport.c index 693b18278..704474219 100644 --- a/tests/conform/test-cogl-viewport.c +++ b/tests/conform/test-cogl-viewport.c @@ -9,8 +9,8 @@ #define BLUE 2 #define ALPHA 3 -#define DRAW_BUFFER_WIDTH 640 -#define DRAW_BUFFER_HEIGHT 480 +#define FRAMEBUFFER_WIDTH 640 +#define FRAMEBUFFER_HEIGHT 480 static const ClutterColor stage_color = { 0x0, 0x0, 0x0, 0xff }; @@ -81,7 +81,7 @@ on_paint (ClutterActor *actor, void *state) float width; float height; - /* for clearing the offscreen draw buffer to black... */ + /* for clearing the offscreen framebuffer to black... */ cogl_color_set_from_4ub (&black, 0x00, 0x00, 0x00, 0xff); cogl_get_viewport (saved_viewport); @@ -94,10 +94,10 @@ on_paint (ClutterActor *actor, void *state) cogl_set_projection_matrix (&projection); cogl_set_modelview_matrix (&modelview); - /* - Create a 100x200 viewport (i.e. smaller than the onscreen draw buffer) - * and position it a (20, 10) inside the draw buffer. + /* - Create a 100x200 viewport (i.e. smaller than the onscreen framebuffer) + * and position it a (20, 10) inside the framebuffer. * - Fill the whole viewport with a purple rectangle - * - Verify that the draw buffer is black with a 100x200 purple rectangle at + * - Verify that the framebuffer is black with a 100x200 purple rectangle at * (20, 10) */ cogl_set_viewport (20, /* x */ @@ -113,28 +113,28 @@ on_paint (ClutterActor *actor, void *state) 0xff, 0x00, 0xff); - /* - Create a viewport twice the size of the onscreen draw buffer with + /* - Create a viewport twice the size of the onscreen framebuffer with * a negative offset positioning it at (-20, -10) relative to the * buffer itself. * - Draw a 100x200 green rectangle at (40, 20) within the viewport (which - * is (20, 10) within the draw buffer) - * - Verify that the draw buffer is black with a 100x200 green rectangle at + * is (20, 10) within the framebuffer) + * - Verify that the framebuffer is black with a 100x200 green rectangle at * (20, 10) */ cogl_set_viewport (-20, /* x */ -10, /* y */ - DRAW_BUFFER_WIDTH * 2, /* width */ - DRAW_BUFFER_HEIGHT * 2); /* height */ + FRAMEBUFFER_WIDTH * 2, /* width */ + FRAMEBUFFER_HEIGHT * 2); /* height */ /* clear everything... */ cogl_clear (&black, COGL_BUFFER_BIT_COLOR); /* draw a 100x200 green rectangle offset into the viewport such that its * top left corner should be found at (20, 10) in the offscreen buffer */ /* (offset 40 pixels right from the left of the viewport) */ - x0 = -1.0f + (1.0f / DRAW_BUFFER_WIDTH) * 40.f; + x0 = -1.0f + (1.0f / FRAMEBUFFER_WIDTH) * 40.f; /* (offset 20 pixels down from the top of the viewport) */ - y0 = 1.0f - (1.0f / DRAW_BUFFER_HEIGHT) * 20.0f; - width = (1.0f / DRAW_BUFFER_WIDTH) * 100; - height = (1.0f / DRAW_BUFFER_HEIGHT) * 200; + y0 = 1.0f - (1.0f / FRAMEBUFFER_HEIGHT) * 20.0f; + width = (1.0f / FRAMEBUFFER_WIDTH) * 100; + height = (1.0f / FRAMEBUFFER_HEIGHT) * 200; cogl_set_source_color4ub (0x00, 0xff, 0x00, 0xff); cogl_rectangle (x0, y0, x0 + width, y0 - height); assert_rectangle_color_and_black_border (20, 10, 100, 200, @@ -145,7 +145,7 @@ on_paint (ClutterActor *actor, void *state) * buffer. * - Push a 100x200 window space clip rectangle at (20, 10) * - Fill the whole viewport with a blue rectangle - * - Verify that the draw buffer is black with a 100x200 blue rectangle at + * - Verify that the framebuffer is black with a 100x200 blue rectangle at * (20, 10) */ cogl_set_viewport (20, /* x */ @@ -166,9 +166,9 @@ on_paint (ClutterActor *actor, void *state) /* - Create a 200x400 viewport and position it a (20, 10) inside the draw * buffer. * - Push a 100x200 model space clip rectangle at (20, 10) in the viewport - * (i.e. (40, 20) inside the draw buffer) + * (i.e. (40, 20) inside the framebuffer) * - Fill the whole viewport with a green rectangle - * - Verify that the draw buffer is black with a 100x200 green rectangle at + * - Verify that the framebuffer is black with a 100x200 green rectangle at * (40, 20) */ cogl_set_viewport (20, /* x */ @@ -203,31 +203,29 @@ on_paint (ClutterActor *actor, void *state) /* Set the viewport to something specific so we can verify that it gets - * restored after we are done testing with an offscreen draw buffer... */ + * restored after we are done testing with an offscreen framebuffer... */ cogl_set_viewport (20, 10, 100, 200); /* * Next test offscreen drawing... */ - cogl_push_draw_buffer (); - - data = g_malloc (DRAW_BUFFER_WIDTH * 4 * DRAW_BUFFER_HEIGHT); - tex = cogl_texture_new_from_data (DRAW_BUFFER_WIDTH, DRAW_BUFFER_HEIGHT, + data = g_malloc (FRAMEBUFFER_WIDTH * 4 * FRAMEBUFFER_HEIGHT); + tex = cogl_texture_new_from_data (FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT, COGL_TEXTURE_NO_SLICING, COGL_PIXEL_FORMAT_RGBA_8888, /* data fmt */ COGL_PIXEL_FORMAT_ANY, /* internal fmt */ - DRAW_BUFFER_WIDTH * 4, /* rowstride */ + FRAMEBUFFER_WIDTH * 4, /* rowstride */ data); g_free (data); offscreen = cogl_offscreen_new_to_texture (tex); - cogl_set_draw_buffer (0 /* unused */, offscreen); + cogl_push_framebuffer (offscreen); - /* - Create a 100x200 viewport (i.e. smaller than the offscreen draw buffer) - * and position it a (20, 10) inside the draw buffer. + /* - Create a 100x200 viewport (i.e. smaller than the offscreen framebuffer) + * and position it a (20, 10) inside the framebuffer. * - Fill the whole viewport with a blue rectangle - * - Verify that the draw buffer is black with a 100x200 blue rectangle at + * - Verify that the framebuffer is black with a 100x200 blue rectangle at * (20, 10) */ cogl_set_viewport (20, /* x */ @@ -243,28 +241,28 @@ on_paint (ClutterActor *actor, void *state) 0x00, 0x00, 0xff); - /* - Create a viewport twice the size of the offscreen draw buffer with + /* - Create a viewport twice the size of the offscreen framebuffer with * a negative offset positioning it at (-20, -10) relative to the * buffer itself. * - Draw a 100x200 red rectangle at (40, 20) within the viewport (which - * is (20, 10) within the draw buffer) - * - Verify that the draw buffer is black with a 100x200 red rectangle at + * is (20, 10) within the framebuffer) + * - Verify that the framebuffer is black with a 100x200 red rectangle at * (20, 10) */ cogl_set_viewport (-20, /* x */ -10, /* y */ - DRAW_BUFFER_WIDTH * 2, /* width */ - DRAW_BUFFER_HEIGHT * 2); /* height */ + FRAMEBUFFER_WIDTH * 2, /* width */ + FRAMEBUFFER_HEIGHT * 2); /* height */ /* clear everything... */ cogl_clear (&black, COGL_BUFFER_BIT_COLOR); /* draw a 100x200 red rectangle offset into the viewport such that its * top left corner should be found at (20, 10) in the offscreen buffer */ /* (offset 40 pixels right from the left of the viewport) */ - x0 = -1.0f + (1.0f / DRAW_BUFFER_WIDTH) * 40.f; + x0 = -1.0f + (1.0f / FRAMEBUFFER_WIDTH) * 40.f; /* (offset 20 pixels down from the top of the viewport) */ - y0 = 1.0f - (1.0f / DRAW_BUFFER_HEIGHT) * 20.0f; - width = (1.0f / DRAW_BUFFER_WIDTH) * 100; - height = (1.0f / DRAW_BUFFER_HEIGHT) * 200; + y0 = 1.0f - (1.0f / FRAMEBUFFER_HEIGHT) * 20.0f; + width = (1.0f / FRAMEBUFFER_WIDTH) * 100; + height = (1.0f / FRAMEBUFFER_HEIGHT) * 200; cogl_set_source_color4ub (0xff, 0x00, 0x00, 0xff); cogl_rectangle (x0, y0, x0 + width, y0 - height); assert_rectangle_color_and_black_border (20, 10, 100, 200, @@ -275,7 +273,7 @@ on_paint (ClutterActor *actor, void *state) * buffer. * - Push a 100x200 window space clip rectangle at (20, 10) * - Fill the whole viewport with a blue rectangle - * - Verify that the draw buffer is black with a 100x200 blue rectangle at + * - Verify that the framebuffer is black with a 100x200 blue rectangle at * (20, 10) */ cogl_set_viewport (20, /* x */ @@ -296,9 +294,9 @@ on_paint (ClutterActor *actor, void *state) /* - Create a 200x400 viewport and position it a (20, 10) inside the draw * buffer. * - Push a 100x200 model space clip rectangle at (20, 10) in the viewport - * (i.e. (40, 20) inside the draw buffer) + * (i.e. (40, 20) inside the framebuffer) * - Fill the whole viewport with a green rectangle - * - Verify that the draw buffer is black with a 100x200 green rectangle at + * - Verify that the framebuffer is black with a 100x200 green rectangle at * (40, 20) */ cogl_set_viewport (20, /* x */ @@ -333,14 +331,14 @@ on_paint (ClutterActor *actor, void *state) /* Set the viewport to something obscure to verify that it gets - * replace when we switch back to the onscreen draw buffer... */ + * replace when we switch back to the onscreen framebuffer... */ cogl_set_viewport (0, 0, 10, 10); - cogl_pop_draw_buffer (); + cogl_pop_framebuffer (); cogl_handle_unref (offscreen); /* - * Verify that the previous onscreen draw buffer's viewport was restored + * Verify that the previous onscreen framebuffer's viewport was restored * by drawing a white rectangle across the whole viewport. This should * draw a 100x200 rectangle at (20,10) relative to the onscreen draw * buffer... @@ -352,11 +350,11 @@ on_paint (ClutterActor *actor, void *state) 0xff, 0xff, 0xff); - /* Uncomment to display the last contents of the offscreen draw buffer */ + /* Uncomment to display the last contents of the offscreen framebuffer */ #if 1 cogl_matrix_init_identity (&projection); cogl_matrix_init_identity (&modelview); - cogl_set_viewport (0, 0, DRAW_BUFFER_WIDTH, DRAW_BUFFER_HEIGHT); + cogl_set_viewport (0, 0, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT); cogl_set_projection_matrix (&projection); cogl_set_modelview_matrix (&modelview); cogl_set_source_texture (tex); @@ -395,7 +393,7 @@ test_cogl_viewport (TestConformSimpleFixture *fixture, stage = clutter_stage_get_default (); clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color); - clutter_actor_set_size (stage, DRAW_BUFFER_WIDTH, DRAW_BUFFER_HEIGHT); + clutter_actor_set_size (stage, FRAMEBUFFER_WIDTH, FRAMEBUFFER_HEIGHT); /* We force continuous redrawing of the stage, since we need to skip * the first few frames, and we wont be doing anything else that diff --git a/tests/interactive/test-cogl-offscreen.c b/tests/interactive/test-cogl-offscreen.c index 1bae10d32..f7baf4359 100644 --- a/tests/interactive/test-cogl-offscreen.c +++ b/tests/interactive/test-cogl-offscreen.c @@ -95,7 +95,7 @@ test_coglbox_paint(ClutterActor *self) 0, 0, 6, 6); - cogl_set_draw_buffer (COGL_OFFSCREEN_BUFFER, priv->offscreen_id); + cogl_push_framebuffer (priv->offscreen_id); cogl_set_source_color4ub (0xff, 0, 0, 0xff); cogl_rectangle (20, 20, 20 + 100, 20 + 100); @@ -103,7 +103,7 @@ test_coglbox_paint(ClutterActor *self) cogl_set_source_color4ub (0, 0xff, 0, 0xff); cogl_rectangle (80, 80, 80 + 100, 80 + 100); - cogl_set_draw_buffer (COGL_WINDOW_BUFFER, 0); + cogl_pop_framebuffer (); material = cogl_material_new (); cogl_material_set_color4ub (material, 0x88, 0x88, 0x88, 0x88);