[cogl-draw-buffer] fix Cogl -> GL viewport coord conversion

Before we call glViewport we need to convert Cogl viewport coordinates
(where the origin is defined to be top left) to OpenGL coordinates
(where the origin is defined to be bottom left)

We weren't considering that offscreen rendering is always upside down
and in this case Cogl coordinates == OpenGL coordinates.
This commit is contained in:
Robert Bragg 2009-10-31 00:00:33 +00:00
parent 149e3e168a
commit 90dbae5aa9

View File

@ -567,10 +567,17 @@ _cogl_draw_buffer_flush_state (CoglHandle handle,
if (ctx->dirty_gl_viewport)
{
int gl_viewport_y;
/* 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.) */
int gl_viewport_y = draw_buffer->height -
* 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
* need to convert the y offset in this case. */
if (cogl_is_offscreen (draw_buffer))
gl_viewport_y = draw_buffer->viewport_y;
else
gl_viewport_y = draw_buffer->height -
(draw_buffer->viewport_y + draw_buffer->viewport_height);
GE (glViewport (draw_buffer->viewport_x,