summaryrefslogtreecommitdiff
path: root/cogl/cogl-buffer.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-buffer.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-buffer.c')
-rw-r--r--cogl/cogl-buffer.c18
1 files changed, 5 insertions, 13 deletions
diff --git a/cogl/cogl-buffer.c b/cogl/cogl-buffer.c
index 207b1700..7a6c77aa 100644
--- a/cogl/cogl-buffer.c
+++ b/cogl/cogl-buffer.c
@@ -316,33 +316,25 @@ _cogl_buffer_access_to_gl_enum (CoglBufferAccess access)
return GL_READ_ONLY;
}
-/* OpenGL ES 1.1 and 2 only know about STATIC_DRAW and DYNAMIC_DRAW */
-#if defined (COGL_HAS_GLES)
-GLenum
-_cogl_buffer_hints_to_gl_enum (CoglBufferUsageHint usage_hint,
- CoglBufferUpdateHint update_hint)
-{
- /* usage hint is always TEXTURE for now */
- if (update_hint == COGL_BUFFER_UPDATE_HINT_STATIC)
- return GL_STATIC_DRAW;
- return GL_DYNAMIC_DRAW;
-}
-#else
GLenum
_cogl_buffer_hints_to_gl_enum (CoglBufferUsageHint usage_hint,
CoglBufferUpdateHint update_hint)
{
+ _COGL_GET_CONTEXT (ctx, 0);
+
/* usage hint is always TEXTURE for now */
if (update_hint == COGL_BUFFER_UPDATE_HINT_STATIC)
return GL_STATIC_DRAW;
if (update_hint == COGL_BUFFER_UPDATE_HINT_DYNAMIC)
return GL_DYNAMIC_DRAW;
+ /* OpenGL ES 1.1 and 2 only know about STATIC_DRAW and DYNAMIC_DRAW */
+#ifdef HAVE_COGL_GL
if (update_hint == COGL_BUFFER_UPDATE_HINT_STREAM)
return GL_STREAM_DRAW;
+#endif
return GL_STATIC_DRAW;
}
-#endif
void *
_cogl_buffer_bind (CoglBuffer *buffer, CoglBufferBindTarget target)