1
0
Fork 0

cogl-gles2-context: Fix the default viewport and scissor size

In GL, the default viewport and scissor should be set to the size of
the first surface that the context is bound to. If a CoglGLES2Context
is first used with an offscreen framebuffer then this surface will
actually be the dummy 1x1 window which will mess up the defaults. To
fix that, this patch makes it just always override the viewport and
scissor the first time the context is bound to something.

Reviewed-by: Robert Bragg <robert@linux.intel.com>

(cherry picked from commit 02567b3e6b64e6849b9f7c6aa2137401be7ece8d)
This commit is contained in:
Neil Roberts 2012-08-07 16:15:55 +01:00 committed by Robert Bragg
parent f373c4aba4
commit 0cd88bd676
2 changed files with 26 additions and 0 deletions

View file

@ -52,6 +52,11 @@ struct _CoglGLES2Context
CoglContext *context;
/* This is set to FALSE until the first time the GLES2 context is
* bound to something. We need to keep track of this so we can set
* the viewport and scissor the first time it is bound. */
CoglBool has_been_bound;
CoglFramebuffer *read_buffer;
CoglGLES2Offscreen *gles2_read_buffer;
CoglFramebuffer *write_buffer;

View file

@ -483,6 +483,27 @@ cogl_push_gles2_context (CoglContext *ctx,
}
current_gles2_context = gles2_ctx;
/* If this is the first time this gles2 context has been used then
* we'll force the viewport and scissor to the right size. GL has
* the semantics that the viewport and scissor default to the size
* of the first surface the context is used with. If the first
* CoglFramebuffer that this context is used with is an offscreen,
* then the surface from GL's point of view will be the 1x1 dummy
* surface so the viewport will be wrong. Therefore we just override
* the default viewport and scissor here */
if (!gles2_ctx->has_been_bound)
{
int fb_width = cogl_framebuffer_get_width (write_buffer);
int fb_height = cogl_framebuffer_get_height (write_buffer);
gles2_ctx->vtable->glViewport (0, 0, /* x/y */
fb_width, fb_height);
gles2_ctx->vtable->glScissor (0, 0, /* x/y */
fb_width, fb_height);
gles2_ctx->has_been_bound = TRUE;
}
return TRUE;
}