Added GLX version check and assures context is set to none on failure.

Fixed the location glewExperimental was being set to just before glewInit() (where it should be).
master
Zachary Lund 2014-01-04 01:08:49 -06:00
parent ffd80449d3
commit 8df5293be1
1 changed files with 14 additions and 2 deletions

View File

@ -138,6 +138,17 @@ struct gl_platform *gl_platform_create(device_t device,
XSetErrorHandler(GLXErrorHandler); XSetErrorHandler(GLXErrorHandler);
/* We require glX version 1.4 */
{
int major = 0, minor = 0;
glXQueryVersion(display, &major, &minor);
if (major < 1 || minor < 4) {
blog(LOG_ERROR, "GLX version isn't high enough.");
goto fail0;
}
}
glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress("glXCreateContextAttribsARB"); glXCreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)glXGetProcAddress("glXCreateContextAttribsARB");
if (!glXCreateContextAttribsARB) { if (!glXCreateContextAttribsARB) {
blog(LOG_ERROR, "ARB_GLX_create_context not supported!"); blog(LOG_ERROR, "ARB_GLX_create_context not supported!");
@ -170,8 +181,8 @@ struct gl_platform *gl_platform_create(device_t device,
/* Initialize GLEW */ /* Initialize GLEW */
{ {
GLenum err = glewInit();
glewExperimental = true; glewExperimental = true;
GLenum err = glewInit();
if (GLEW_OK != err) { if (GLEW_OK != err) {
blog(LOG_ERROR, glewGetErrorString(err)); blog(LOG_ERROR, glewGetErrorString(err));
@ -192,6 +203,7 @@ struct gl_platform *gl_platform_create(device_t device,
return plat; return plat;
fail2: fail2:
glXMakeCurrent(display, None, NULL);
glXDestroyContext(display, plat->context); glXDestroyContext(display, plat->context);
fail1: fail1:
XFree(configs); XFree(configs);