summaryrefslogtreecommitdiff
path: root/cogl-pango
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-pango
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-pango')
-rw-r--r--cogl-pango/Makefile.am2
-rw-r--r--cogl-pango/cogl-pango-display-list.c45
2 files changed, 25 insertions, 22 deletions
diff --git a/cogl-pango/Makefile.am b/cogl-pango/Makefile.am
index b57e1474..afd96d6b 100644
--- a/cogl-pango/Makefile.am
+++ b/cogl-pango/Makefile.am
@@ -40,6 +40,8 @@ INCLUDES = \
-DG_DISABLE_SINGLE_INCLUDES \
-DCLUTTER_COMPILATION \
-DG_LOG_DOMAIN=\"CoglPango\" \
+ -I$(top_srcdir)/cogl \
+ -I$(top_srcdir)/cogl/winsys \
-I$(top_srcdir) \
-I$(top_builddir)
diff --git a/cogl-pango/cogl-pango-display-list.c b/cogl-pango/cogl-pango-display-list.c
index a79cf0f1..84400066 100644
--- a/cogl-pango/cogl-pango-display-list.c
+++ b/cogl-pango/cogl-pango-display-list.c
@@ -30,6 +30,7 @@
#include <string.h>
#include "cogl-pango-display-list.h"
+#include "cogl/cogl-context-private.h"
typedef enum
{
@@ -265,6 +266,8 @@ emit_rectangles_through_journal (CoglPangoDisplayListNode *node)
static void
emit_vertex_buffer_geometry (CoglPangoDisplayListNode *node)
{
+ _COGL_GET_CONTEXT (ctx, NO_RETVAL);
+
/* It's expensive to go through the Cogl journal for large runs
* of text in part because the journal transforms the quads in software
* to avoid changing the modelview matrix. So for larger runs of text
@@ -293,29 +296,27 @@ emit_vertex_buffer_geometry (CoglPangoDisplayListNode *node)
node->d.texture.vertex_buffer = vb;
}
-
#ifdef CLUTTER_COGL_HAS_GL
-
- cogl_vertex_buffer_draw (node->d.texture.vertex_buffer,
- GL_QUADS,
- 0, node->d.texture.verts->len);
-
-#else /* CLUTTER_COGL_HAS_GL */
- {
- /* GLES doesn't support GL_QUADS so instead we use a VBO with
- indexed vertices to generate GL_TRIANGLES from the quads */
-
- int n_indices = node->d.texture.verts->len / 4 * 6;
- CoglHandle indices_vbo
- = cogl_vertex_buffer_indices_get_for_quads (n_indices);
-
- cogl_vertex_buffer_draw_elements (node->d.texture.vertex_buffer,
- COGL_VERTICES_MODE_TRIANGLES,
- indices_vbo,
- 0, node->d.texture.verts->len - 1,
- 0, n_indices);
- }
-#endif /* CLUTTER_COGL_HAS_GL */
+ if (ctx->driver == COGL_DRIVER_GL)
+ cogl_vertex_buffer_draw (node->d.texture.vertex_buffer,
+ GL_QUADS,
+ 0, node->d.texture.verts->len);
+ else
+#endif
+ {
+ /* GLES doesn't support GL_QUADS so instead we use a VBO with
+ indexed vertices to generate GL_TRIANGLES from the quads */
+
+ int n_indices = node->d.texture.verts->len / 4 * 6;
+ CoglHandle indices_vbo
+ = cogl_vertex_buffer_indices_get_for_quads (n_indices);
+
+ cogl_vertex_buffer_draw_elements (node->d.texture.vertex_buffer,
+ COGL_VERTICES_MODE_TRIANGLES,
+ indices_vbo,
+ 0, node->d.texture.verts->len - 1,
+ 0, n_indices);
+ }
}
static void