[cogl] cache the viewport width and height

This avoids some calls to glGetFloatv, which have at least proven to be very
in-efficient in mesa at this point in time, since it always updates all derived
state even when it may not relate to the state being requested.
This commit is contained in:
Robert Bragg
2009-07-01 12:57:30 +01:00
parent fdc048ddd0
commit 82ef6b51b9
4 changed files with 23 additions and 15 deletions

View File

@ -92,6 +92,9 @@ cogl_create_context ()
_context->in_begin_gl_block = FALSE;
_context->viewport_width = 0;
_context->viewport_height = 0;
_context->pf_glGenRenderbuffersEXT = NULL;
_context->pf_glBindRenderbufferEXT = NULL;
_context->pf_glRenderbufferStorageEXT = NULL;

View File

@ -112,6 +112,9 @@ typedef struct
gboolean in_begin_gl_block;
guint viewport_width;
guint viewport_height;
/* Relying on glext.h to define these */
COGL_PFNGLGENRENDERBUFFERSEXTPROC pf_glGenRenderbuffersEXT;
COGL_PFNGLDELETERENDERBUFFERSEXTPROC pf_glDeleteRenderbuffersEXT;

View File

@ -209,7 +209,7 @@ cogl_set_draw_buffer (CoglBufferTarget target, CoglHandle offscreen)
}
/* Setup new viewport and matrices */
GE( glViewport (0, 0, fbo->width, fbo->height) );
cogl_viewport (fbo->width, fbo->height);
_cogl_current_matrix_translate (-1.0f, -1.0f, 0.0f);
_cogl_current_matrix_scale (2.0f / fbo->width, 2.0f / fbo->height, 1.0f);