framebuffer: expose viewport getters/setters

This exposes experimental cogl_framebuffer APIs for getting and setting
a viewport without having to refer to the implicit CoglContext. It adds
the following experimental API:

  cogl_framebuffer_set_viewport
  cogl_framebuffer_get_viewport4fv
  cogl_framebuffer_get_viewport_x
  cogl_framebuffer_get_viewport_y
  cogl_framebuffer_get_viewport_width
  cogl_framebuffer_get_viewport_height

Signed-off-by: Neil Roberts <neil@linux.intel.com>
This commit is contained in:
Robert Bragg 2011-06-15 00:06:29 +01:00
parent 716b88b0c8
commit c4eb869bd7
6 changed files with 48 additions and 42 deletions

View File

@ -194,28 +194,6 @@ void
_cogl_framebuffer_set_clip_stack (CoglFramebuffer *framebuffer, _cogl_framebuffer_set_clip_stack (CoglFramebuffer *framebuffer,
CoglClipStack *stack); CoglClipStack *stack);
void
_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
float x,
float y,
float width,
float height);
float
_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer);
float
_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer);
float
_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer);
float
_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer);
void
_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer,
float *viewport);
CoglMatrixStack * CoglMatrixStack *
_cogl_framebuffer_get_modelview_stack (CoglFramebuffer *framebuffer); _cogl_framebuffer_get_modelview_stack (CoglFramebuffer *framebuffer);

View File

@ -507,7 +507,7 @@ _cogl_framebuffer_set_clip_stack (CoglFramebuffer *framebuffer,
} }
void void
_cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer, cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
float x, float x,
float y, float y,
float width, float width,
@ -533,31 +533,31 @@ _cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
} }
float float
_cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer) cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer)
{ {
return framebuffer->viewport_x; return framebuffer->viewport_x;
} }
float float
_cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer) cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer)
{ {
return framebuffer->viewport_y; return framebuffer->viewport_y;
} }
float float
_cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer) cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer)
{ {
return framebuffer->viewport_width; return framebuffer->viewport_width;
} }
float float
_cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer) cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer)
{ {
return framebuffer->viewport_height; return framebuffer->viewport_height;
} }
void void
_cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer, cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer,
float *viewport) float *viewport)
{ {
viewport[0] = framebuffer->viewport_x; viewport[0] = framebuffer->viewport_x;

View File

@ -58,6 +58,35 @@ cogl_framebuffer_get_width (CoglFramebuffer *framebuffer);
int int
cogl_framebuffer_get_height (CoglFramebuffer *framebuffer); cogl_framebuffer_get_height (CoglFramebuffer *framebuffer);
#define cogl_framebuffer_set_viewport cogl_framebuffer_set_viewport_EXP
void
cogl_framebuffer_set_viewport (CoglFramebuffer *framebuffer,
float x,
float y,
float width,
float height);
#define cogl_framebuffer_get_viewport_x cogl_framebuffer_get_viewport_x_EXP
float
cogl_framebuffer_get_viewport_x (CoglFramebuffer *framebuffer);
#define cogl_framebuffer_get_viewport_y cogl_framebuffer_get_viewport_y_EXP
float
cogl_framebuffer_get_viewport_y (CoglFramebuffer *framebuffer);
#define cogl_framebuffer_get_viewport_width cogl_framebuffer_get_viewport_width_EXP
float
cogl_framebuffer_get_viewport_width (CoglFramebuffer *framebuffer);
#define cogl_framebuffer_get_viewport_height cogl_framebuffer_get_viewport_height_EXP
float
cogl_framebuffer_get_viewport_height (CoglFramebuffer *framebuffer);
#define cogl_framebuffer_get_viewport4fv cogl_framebuffer_get_viewport4fv_EXP
void
cogl_framebuffer_get_viewport4fv (CoglFramebuffer *framebuffer,
float *viewport);
#define cogl_framebuffer_swap_buffers cogl_framebuffer_swap_buffers_EXP #define cogl_framebuffer_swap_buffers cogl_framebuffer_swap_buffers_EXP
void void
cogl_framebuffer_swap_buffers (CoglFramebuffer *framebuffer); cogl_framebuffer_swap_buffers (CoglFramebuffer *framebuffer);

View File

@ -1647,8 +1647,7 @@ entry_to_screen_polygon (const CoglJournalEntry *entry,
poly, /* points_out */ poly, /* points_out */
4 /* n_points */); 4 /* n_points */);
_cogl_framebuffer_get_viewport4fv (cogl_get_draw_framebuffer (), cogl_framebuffer_get_viewport4fv (cogl_get_draw_framebuffer (), viewport);
viewport);
/* Scale from OpenGL normalized device coordinates (ranging from -1 to 1) /* Scale from OpenGL normalized device coordinates (ranging from -1 to 1)
* to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with * to Cogl window/framebuffer coordinates (ranging from 0 to buffer-size) with

View File

@ -1066,7 +1066,7 @@ _cogl_texture_draw_and_read (CoglHandle handle,
framebuffer = cogl_get_draw_framebuffer (); framebuffer = cogl_get_draw_framebuffer ();
/* Viewport needs to have some size and be inside the window for this */ /* Viewport needs to have some size and be inside the window for this */
_cogl_framebuffer_get_viewport4fv (framebuffer, viewport); cogl_framebuffer_get_viewport4fv (framebuffer, viewport);
if (viewport[0] < 0 || viewport[1] < 0 || if (viewport[0] < 0 || viewport[1] < 0 ||
viewport[2] <= 0 || viewport[3] <= 0) viewport[2] <= 0 || viewport[3] <= 0)
return FALSE; return FALSE;

View File

@ -349,7 +349,7 @@ cogl_set_viewport (int x,
framebuffer = cogl_get_draw_framebuffer (); framebuffer = cogl_get_draw_framebuffer ();
_cogl_framebuffer_set_viewport (framebuffer, cogl_framebuffer_set_viewport (framebuffer,
x, x,
y, y,
width, width,
@ -393,7 +393,7 @@ cogl_get_viewport (float viewport[4])
_COGL_GET_CONTEXT (ctx, NO_RETVAL); _COGL_GET_CONTEXT (ctx, NO_RETVAL);
framebuffer = cogl_get_draw_framebuffer (); framebuffer = cogl_get_draw_framebuffer ();
_cogl_framebuffer_get_viewport4fv (framebuffer, viewport); cogl_framebuffer_get_viewport4fv (framebuffer, viewport);
} }
void void