From affeeb6494acc85fe3f40c4f58d4015e2ee87867 Mon Sep 17 00:00:00 2001 From: ikits Date: Sun, 4 May 2003 19:47:45 +0000 Subject: [PATCH] *** empty log message *** git-svn-id: https://glew.svn.sourceforge.net/svnroot/glew/trunk/glew@61 783a27ee-832a-0410-bc00-9f386506c6dd --- src/glew.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/glew.c b/src/glew.c index d35e687..32e9337 100644 --- a/src/glew.c +++ b/src/glew.c @@ -3264,9 +3264,16 @@ static GLint _wglewInit () GLboolean glxewGetExtension (const char *name) { char *p, *end; + Display *dpy; int len = _glewStrLen(name); - if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; - p = (char*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay())); + if (glXQueryExtensionsString == NULL) return GL_FALSE; + /* if (glXQueryExtensionsString == NULL || glXGetCurrentDisplay == NULL) return GL_FALSE; + p = (char*)glXQueryExtensionsString(glXGetCurrentDisplay(), DefaultScreen(glXGetCurrentDisplay())); */ + /* Temporary fix to avoid using glXGetCurrentDisplay, which crashes GLEW on some configurations. */ + dpy = XOpenDisplay(NULL); + if (dpy == NULL) return GL_FALSE; + p = (char*)glXQueryExtensionsString(dpy, DefaultScreen(dpy)); + XCloseDisplay(dpy); if (0 == p) return GL_FALSE; end = p + _glewStrLen(p); while (p < end) @@ -3281,12 +3288,18 @@ GLboolean glxewGetExtension (const char *name) static GLint _glxewInit () { int major, minor; + Display* dpy; /* intialize glxew struct */ _glewMemSet(&glxew, 0, sizeof(glxew)); /* initialize core GLX 1.0-1.2 */ - if (_glxewInit_10() || _glxewInit_11() || _glxewInit_12() || glXGetCurrentDisplay == NULL) return GLEW_ERROR_GLX_VERSION_11_ONLY; + if (_glxewInit_10() || _glxewInit_11() || _glxewInit_12()) return GLEW_ERROR_GLX_VERSION_11_ONLY; /* query GLX version */ - glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); + /* glXQueryVersion(glXGetCurrentDisplay(), &major, &minor); */ + /* Temporary fix to avoid using glXGetCurrentDisplay, which crashes GLEW on some configurations. */ + dpy = XOpenDisplay(NULL); + if (dpy == NULL) return GLEW_ERROR_GLX_VERSION_11_ONLY; + glXQueryVersion(dpy, &major, &minor); + XCloseDisplay(dpy); switch (minor) { case 2: