mirror of
https://github.com/nigels-com/glew.git
synced 2025-02-19 15:10:41 +00:00
glxewInit check for current X11 display rather than crashing
This commit is contained in:
parent
7f92f9adf7
commit
2c6ad763af
@ -14,9 +14,13 @@ GLboolean glxewGetExtension (const char* name)
|
|||||||
|
|
||||||
GLenum glxewInit ()
|
GLenum glxewInit ()
|
||||||
{
|
{
|
||||||
|
Display* display;
|
||||||
int major, minor;
|
int major, minor;
|
||||||
const GLubyte* extStart;
|
const GLubyte* extStart;
|
||||||
const GLubyte* extEnd;
|
const GLubyte* extEnd;
|
||||||
|
/* check for a display */
|
||||||
|
display = glXGetCurrentDisplay();
|
||||||
|
if (display == NULL) return GLEW_ERROR_NO_GLX_DISPLAY;
|
||||||
/* initialize core GLX 1.2 */
|
/* initialize core GLX 1.2 */
|
||||||
if (_glewInit_GLX_VERSION_1_2()) return GLEW_ERROR_GLX_VERSION_11_ONLY;
|
if (_glewInit_GLX_VERSION_1_2()) return GLEW_ERROR_GLX_VERSION_11_ONLY;
|
||||||
/* initialize flags */
|
/* initialize flags */
|
||||||
@ -26,7 +30,7 @@ GLenum glxewInit ()
|
|||||||
GLXEW_VERSION_1_3 = GL_TRUE;
|
GLXEW_VERSION_1_3 = GL_TRUE;
|
||||||
GLXEW_VERSION_1_4 = GL_TRUE;
|
GLXEW_VERSION_1_4 = GL_TRUE;
|
||||||
/* query GLX version */
|
/* query GLX version */
|
||||||
glXQueryVersion(glXGetCurrentDisplay(), &major, &minor);
|
glXQueryVersion(display, &major, &minor);
|
||||||
if (major == 1 && minor <= 3)
|
if (major == 1 && minor <= 3)
|
||||||
{
|
{
|
||||||
switch (minor)
|
switch (minor)
|
||||||
@ -46,7 +50,7 @@ GLenum glxewInit ()
|
|||||||
/* query GLX extension string */
|
/* query GLX extension string */
|
||||||
extStart = 0;
|
extStart = 0;
|
||||||
if (glXGetCurrentDisplay != NULL)
|
if (glXGetCurrentDisplay != NULL)
|
||||||
extStart = (const GLubyte*)glXGetClientString(glXGetCurrentDisplay(), GLX_EXTENSIONS);
|
extStart = (const GLubyte*)glXGetClientString(display, GLX_EXTENSIONS);
|
||||||
if (extStart == 0)
|
if (extStart == 0)
|
||||||
extStart = (const GLubyte *)"";
|
extStart = (const GLubyte *)"";
|
||||||
extEnd = extStart + _glewStrLen(extStart);
|
extEnd = extStart + _glewStrLen(extStart);
|
||||||
|
@ -6,6 +6,7 @@
|
|||||||
#define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */
|
#define GLEW_ERROR_NO_GL_VERSION 1 /* missing GL version */
|
||||||
#define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* Need at least OpenGL 1.1 */
|
#define GLEW_ERROR_GL_VERSION_10_ONLY 2 /* Need at least OpenGL 1.1 */
|
||||||
#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* Need at least GLX 1.2 */
|
#define GLEW_ERROR_GLX_VERSION_11_ONLY 3 /* Need at least GLX 1.2 */
|
||||||
|
#define GLEW_ERROR_NO_GLX_DISPLAY 4 /* Need GLX display for GLX support */
|
||||||
|
|
||||||
/* string codes */
|
/* string codes */
|
||||||
#define GLEW_VERSION 1
|
#define GLEW_VERSION 1
|
||||||
|
Loading…
Reference in New Issue
Block a user