diff options
author | Neil Roberts <neil@linux.intel.com> | 2011-07-07 20:44:56 +0100 |
---|---|---|
committer | Neil Roberts <neil@linux.intel.com> | 2011-07-11 12:57:38 +0100 |
commit | b2e735ff7f4094056765ff6adb5c74fd51d11e4a (patch) | |
tree | fa2d813eef3d138c86208d0a263fb94580059367 /cogl/cogl-matrix-stack.c | |
parent | 5f181973a68ba9048f89cbf623ddcdc95ce7c415 (diff) | |
download | cogl-b2e735ff7f4094056765ff6adb5c74fd51d11e4a.tar.gz |
Dynamically load the GL or GLES library
The GL or GLES library is now dynamically loaded by the CoglRenderer
so that it can choose between GL, GLES1 and GLES2 at runtime. The
library is loaded by the renderer because it needs to be done before
calling eglInitialize. There is a new environment variable called
COGL_DRIVER to choose between gl, gles1 or gles2.
The #ifdefs for HAVE_COGL_GL, HAVE_COGL_GLES and HAVE_COGL_GLES2 have
been changed so that they don't assume the ifdefs are mutually
exclusive. They haven't been removed entirely so that it's possible to
compile the GLES backends without the the enums from the GL headers.
When using GLX the winsys additionally dynamically loads libGL because
that also contains the GLX API. It can't be linked in directly because
that would probably conflict with the GLES API if the EGL is
selected. When compiling with EGL support the library links directly
to libEGL because it doesn't contain any GL API so it shouldn't have
any conflicts.
When building for WGL or OSX Cogl still directly links against the GL
API so there is a #define in config.h so that Cogl won't try to dlopen
the library.
Cogl-pango previously had a #ifdef to detect when the GL backend is
used so that it can sneakily pass GL_QUADS to
cogl_vertex_buffer_draw. This is now changed so that it queries the
CoglContext for the backend. However to get this to work Cogl now
needs to export the _cogl_context_get_default symbol and cogl-pango
needs some extra -I flags to so that it can include
cogl-context-private.h
Diffstat (limited to 'cogl/cogl-matrix-stack.c')
-rw-r--r-- | cogl/cogl-matrix-stack.c | 106 |
1 files changed, 54 insertions, 52 deletions
diff --git a/cogl/cogl-matrix-stack.c b/cogl/cogl-matrix-stack.c index d761b536..09aa0020 100644 --- a/cogl/cogl-matrix-stack.c +++ b/cogl/cogl-matrix-stack.c @@ -393,7 +393,7 @@ _cogl_matrix_stack_set (CoglMatrixStack *stack, stack->age++; } -#ifndef HAVE_COGL_GLES2 +#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES) static void flush_to_fixed_api_gl (gboolean is_identity, @@ -417,7 +417,7 @@ flush_to_fixed_api_gl (gboolean is_identity, } } -#endif /* HAVE_COGL_GLES2 */ +#endif void _cogl_matrix_stack_prepare_for_flush (CoglMatrixStack *stack, @@ -462,72 +462,74 @@ _cogl_matrix_stack_flush_to_gl (CoglMatrixStack *stack, state = _cogl_matrix_stack_top (stack); -#ifdef HAVE_COGL_GLES2 - - /* Under GLES2 we need to flush the matrices differently because - they are stored in uniforms attached to the program instead of - the global GL context state. At this point we can't be sure that - the right program will be generated so instead we'll just store a - reference to the matrix stack that is intended to be flushed and - update the uniform once the program is ready. */ - - switch (mode) + if (ctx->driver == COGL_DRIVER_GLES2) { - case COGL_MATRIX_MODELVIEW: - cogl_object_ref (stack); - if (ctx->flushed_modelview_stack) - cogl_object_unref (ctx->flushed_modelview_stack); - ctx->flushed_modelview_stack = stack; - break; - - case COGL_MATRIX_PROJECTION: - cogl_object_ref (stack); - if (ctx->flushed_projection_stack) - cogl_object_unref (ctx->flushed_projection_stack); - ctx->flushed_projection_stack = stack; - break; - - case COGL_MATRIX_TEXTURE: - /* This shouldn't happen because the texture matrices are - handled by the GLSL pipeline backend */ - g_assert_not_reached (); - break; - } - -#else /* HAVE_COGL_GLES2 */ - - if (stack->flushed_state == state) - return; - - if (ctx->flushed_matrix_mode != mode) - { - GLenum gl_mode = 0; + /* Under GLES2 we need to flush the matrices differently because + they are stored in uniforms attached to the program instead of + the global GL context state. At this point we can't be sure that + the right program will be generated so instead we'll just store a + reference to the matrix stack that is intended to be flushed and + update the uniform once the program is ready. */ switch (mode) { case COGL_MATRIX_MODELVIEW: - gl_mode = GL_MODELVIEW; + cogl_object_ref (stack); + if (ctx->flushed_modelview_stack) + cogl_object_unref (ctx->flushed_modelview_stack); + ctx->flushed_modelview_stack = stack; break; case COGL_MATRIX_PROJECTION: - gl_mode = GL_PROJECTION; + cogl_object_ref (stack); + if (ctx->flushed_projection_stack) + cogl_object_unref (ctx->flushed_projection_stack); + ctx->flushed_projection_stack = stack; break; case COGL_MATRIX_TEXTURE: - gl_mode = GL_TEXTURE; + /* This shouldn't happen because the texture matrices are + handled by the GLSL pipeline backend */ + g_assert_not_reached (); break; } - - GE (ctx, glMatrixMode (gl_mode)); - ctx->flushed_matrix_mode = mode; } - _cogl_matrix_stack_prepare_for_flush (stack, - mode, - flush_to_fixed_api_gl, - stack); +#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES) + else + { + if (stack->flushed_state == state) + return; + + if (ctx->flushed_matrix_mode != mode) + { + GLenum gl_mode = 0; + + switch (mode) + { + case COGL_MATRIX_MODELVIEW: + gl_mode = GL_MODELVIEW; + break; + + case COGL_MATRIX_PROJECTION: + gl_mode = GL_PROJECTION; + break; -#endif /* HAVE_COGL_GLES2 */ + case COGL_MATRIX_TEXTURE: + gl_mode = GL_TEXTURE; + break; + } + + GE (ctx, glMatrixMode (gl_mode)); + ctx->flushed_matrix_mode = mode; + } + + _cogl_matrix_stack_prepare_for_flush (stack, + mode, + flush_to_fixed_api_gl, + stack); + } +#endif stack->flushed_state = state; } |