[cogl] cogl-winsys-wgl: Add a fallback for failed wglGetProcAddress
- From: Neil Roberts <nroberts src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cogl] cogl-winsys-wgl: Add a fallback for failed wglGetProcAddress
- Date: Mon, 1 Aug 2011 13:14:00 +0000 (UTC)
commit 38deb97478ace8a3fa19fe55f0a987a2ad6599d0
Author: Neil Roberts <neil linux intel com>
Date: Fri Jul 29 18:06:36 2011 +0100
cogl-winsys-wgl: Add a fallback for failed wglGetProcAddress
The documentation for wglGetProcAddress implies that it should only be
used for extension functions. The rest of Cogl assumes that it can
dynamically resolve all GL symbols so it would crash if this
happens. This patch makes it fallback to trying to resolve the symbol
using GModule to open the opengl32 library if wglGetProcAddress fails.
https://bugzilla.gnome.org/show_bug.cgi?id=655510
Reviewed-by: Robert Bragg <robert linux intel com>
cogl/winsys/cogl-winsys-wgl.c | 24 +++++++++++++++++++++++-
1 files changed, 23 insertions(+), 1 deletions(-)
---
diff --git a/cogl/winsys/cogl-winsys-wgl.c b/cogl/winsys/cogl-winsys-wgl.c
index def4d92..f3bc8ba 100644
--- a/cogl/winsys/cogl-winsys-wgl.c
+++ b/cogl/winsys/cogl-winsys-wgl.c
@@ -45,6 +45,8 @@
typedef struct _CoglRendererWgl
{
+ GModule *gl_module;
+
/* Function pointers for GLX specific extensions */
#define COGL_WINSYS_FEATURE_BEGIN(a, b, c, d, e, f)
@@ -125,12 +127,32 @@ static CoglFuncPtr
_cogl_winsys_renderer_get_proc_address (CoglRenderer *renderer,
const char *name)
{
- return (CoglFuncPtr) wglGetProcAddress ((LPCSTR) name);
+ CoglRendererWgl *wgl_renderer = renderer->winsys;
+ void *proc = wglGetProcAddress ((LPCSTR) name);
+
+ /* The documentation for wglGetProcAddress implies that it only
+ returns pointers to extension functions so if it fails we'll try
+ resolving the symbol directly from the the GL library */
+ if (proc == NULL)
+ {
+ if (wgl_renderer->gl_module == NULL)
+ wgl_renderer->gl_module = g_module_open ("opengl32", 0);
+
+ if (wgl_renderer->gl_module)
+ g_module_symbol (wgl_renderer->gl_module, name, &proc);
+ }
+
+ return proc;
}
static void
_cogl_winsys_renderer_disconnect (CoglRenderer *renderer)
{
+ CoglRendererWgl *wgl_renderer = renderer->winsys;
+
+ if (wgl_renderer->gl_module)
+ g_module_close (wgl_renderer->gl_module);
+
g_slice_free (CoglRendererWgl, renderer->winsys);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]