summaryrefslogtreecommitdiff
path: root/cogl/cogl.c
diff options
context:
space:
mode:
authorNeil Roberts <neil@linux.intel.com>2011-07-07 20:44:56 +0100
committerNeil Roberts <neil@linux.intel.com>2011-07-11 12:57:38 +0100
commitb2e735ff7f4094056765ff6adb5c74fd51d11e4a (patch)
treefa2d813eef3d138c86208d0a263fb94580059367 /cogl/cogl.c
parent5f181973a68ba9048f89cbf623ddcdc95ce7c415 (diff)
downloadcogl-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.c')
-rw-r--r--cogl/cogl.c38
1 files changed, 18 insertions, 20 deletions
diff --git a/cogl/cogl.c b/cogl/cogl.c
index b77a6230..7b2990ec 100644
--- a/cogl/cogl.c
+++ b/cogl/cogl.c
@@ -164,15 +164,7 @@ toggle_flag (CoglContext *ctx,
return FALSE;
}
-#ifdef HAVE_COGL_GLES2
-
-/* Under GLES2 there are no builtin client flags so toggle_client_flag
- should never be reached */
-
-#define toggle_client_flag(ctx, new_flags, flag, gl_flag) \
- g_assert (((new_flags) & (flag)) == 0)
-
-#else /* HAVE_COGL_GLES2 */
+#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
static gboolean
toggle_client_flag (CoglContext *ctx,
@@ -180,6 +172,8 @@ toggle_client_flag (CoglContext *ctx,
unsigned long flag,
GLenum gl_flag)
{
+ g_return_val_if_fail (ctx->driver != COGL_DRIVER_GLES2, FALSE);
+
/* Toggles and caches a single client-side enable flag
* on or off by comparing to current state
*/
@@ -201,7 +195,7 @@ toggle_client_flag (CoglContext *ctx,
return FALSE;
}
-#endif /* HAVE_COGL_GLES2 */
+#endif
void
_cogl_enable (unsigned long flags)
@@ -215,13 +209,18 @@ _cogl_enable (unsigned long flags)
COGL_ENABLE_BACKFACE_CULLING,
GL_CULL_FACE);
- toggle_client_flag (ctx, flags,
- COGL_ENABLE_VERTEX_ARRAY,
- GL_VERTEX_ARRAY);
+#if defined (HAVE_COGL_GL) || defined (HAVE_COGL_GLES)
+ if (ctx->driver != COGL_DRIVER_GLES2)
+ {
+ toggle_client_flag (ctx, flags,
+ COGL_ENABLE_VERTEX_ARRAY,
+ GL_VERTEX_ARRAY);
- toggle_client_flag (ctx, flags,
- COGL_ENABLE_COLOR_ARRAY,
- GL_COLOR_ARRAY);
+ toggle_client_flag (ctx, flags,
+ COGL_ENABLE_COLOR_ARRAY,
+ GL_COLOR_ARRAY);
+ }
+#endif
}
unsigned long
@@ -557,9 +556,9 @@ _cogl_read_pixels_with_rowstride (int x,
GL_RGBA/GL_UNSIGNED_BYTE and convert if necessary. We also need
to use this intermediate buffer if the rowstride has padding
because GLES does not support setting GL_ROW_LENGTH */
-#ifndef COGL_HAS_GL
- if (gl_format != GL_RGBA || gl_type != GL_UNSIGNED_BYTE ||
- rowstride != 4 * width)
+ if (ctx->driver != COGL_DRIVER_GL &&
+ (gl_format != GL_RGBA || gl_type != GL_UNSIGNED_BYTE ||
+ rowstride != 4 * width))
{
CoglBitmap *tmp_bmp, *dst_bmp;
guint8 *tmp_data = g_malloc (width * height * 4);
@@ -599,7 +598,6 @@ _cogl_read_pixels_with_rowstride (int x,
cogl_object_unref (tmp_bmp);
}
else
-#endif
{
ctx->texture_driver->prep_gl_for_pixels_download (rowstride, bpp);