GLX context option cleanup.
This commit is contained in:
parent
238da01770
commit
cf38b34f45
@ -221,7 +221,7 @@ static int errorHandler(Display *display, XErrorEvent* event)
|
|||||||
// Create the actual OpenGL context
|
// Create the actual OpenGL context
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#define setGLXattrib(attribs, index, attribName, attribValue) \
|
#define setGLXattrib(attribName, attribValue) \
|
||||||
attribs[index++] = attribName; \
|
attribs[index++] = attribName; \
|
||||||
attribs[index++] = attribValue;
|
attribs[index++] = attribValue;
|
||||||
|
|
||||||
@ -230,7 +230,6 @@ static int createContext(_GLFWwindow* window,
|
|||||||
GLXFBConfigID fbconfigID)
|
GLXFBConfigID fbconfigID)
|
||||||
{
|
{
|
||||||
int attribs[40];
|
int attribs[40];
|
||||||
int dummy, index;
|
|
||||||
GLXFBConfig* fbconfig;
|
GLXFBConfig* fbconfig;
|
||||||
GLXContext share = NULL;
|
GLXContext share = NULL;
|
||||||
|
|
||||||
@ -239,14 +238,15 @@ static int createContext(_GLFWwindow* window,
|
|||||||
|
|
||||||
// Retrieve the previously selected GLXFBConfig
|
// Retrieve the previously selected GLXFBConfig
|
||||||
{
|
{
|
||||||
index = 0;
|
int dummy, index = 0;
|
||||||
|
|
||||||
setGLXattrib(attribs, index, GLX_FBCONFIG_ID, (int) fbconfigID);
|
setGLXattrib(GLX_FBCONFIG_ID, (int) fbconfigID);
|
||||||
setGLXattrib(attribs, index, None, None);
|
setGLXattrib(None, None);
|
||||||
|
|
||||||
if (_glfwLibrary.GLX.SGIX_fbconfig)
|
if (_glfwLibrary.GLX.SGIX_fbconfig)
|
||||||
{
|
{
|
||||||
fbconfig = _glfwLibrary.GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
fbconfig =
|
||||||
|
_glfwLibrary.GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
|
||||||
_glfwLibrary.X11.screen,
|
_glfwLibrary.X11.screen,
|
||||||
attribs,
|
attribs,
|
||||||
&dummy);
|
&dummy);
|
||||||
@ -270,7 +270,8 @@ static int createContext(_GLFWwindow* window,
|
|||||||
// Retrieve the corresponding visual
|
// Retrieve the corresponding visual
|
||||||
if (_glfwLibrary.GLX.SGIX_fbconfig)
|
if (_glfwLibrary.GLX.SGIX_fbconfig)
|
||||||
{
|
{
|
||||||
window->GLX.visual = _glfwLibrary.GLX.GetVisualFromFBConfigSGIX(_glfwLibrary.X11.display,
|
window->GLX.visual =
|
||||||
|
_glfwLibrary.GLX.GetVisualFromFBConfigSGIX(_glfwLibrary.X11.display,
|
||||||
*fbconfig);
|
*fbconfig);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -288,23 +289,10 @@ static int createContext(_GLFWwindow* window,
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfwLibrary.GLX.ARB_create_context)
|
|
||||||
{
|
|
||||||
index = 0;
|
|
||||||
|
|
||||||
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
|
||||||
{
|
|
||||||
// NOTE: Only request an explicitly versioned context when
|
|
||||||
// necessary, as explicitly requesting version 1.0 does not always
|
|
||||||
// return the highest available version
|
|
||||||
|
|
||||||
setGLXattrib(attribs, index, GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
|
||||||
setGLXattrib(attribs, index, GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
|
||||||
{
|
{
|
||||||
if (!_glfwLibrary.GLX.ARB_create_context_profile ||
|
if (!_glfwLibrary.GLX.ARB_create_context ||
|
||||||
|
!_glfwLibrary.GLX.ARB_create_context_profile ||
|
||||||
!_glfwLibrary.GLX.EXT_create_context_es2_profile)
|
!_glfwLibrary.GLX.EXT_create_context_es2_profile)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||||
@ -312,73 +300,87 @@ static int createContext(_GLFWwindow* window,
|
|||||||
"GLX_EXT_create_context_es2_profile is unavailable");
|
"GLX_EXT_create_context_es2_profile is unavailable");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
setGLXattrib(attribs, index,
|
|
||||||
GLX_CONTEXT_PROFILE_MASK_ARB,
|
|
||||||
GLX_CONTEXT_ES2_PROFILE_BIT_EXT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glForward || wndconfig->glDebug || wndconfig->glRobustness)
|
|
||||||
{
|
|
||||||
int flags = 0;
|
|
||||||
|
|
||||||
if (wndconfig->glForward)
|
if (wndconfig->glForward)
|
||||||
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
{
|
||||||
|
if (!_glfwLibrary.GLX.ARB_create_context)
|
||||||
if (wndconfig->glDebug)
|
{
|
||||||
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
|
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||||
|
"GLX: Forward compatibility requested but "
|
||||||
if (wndconfig->glRobustness)
|
"GLX_ARB_create_context_profile is unavailable");
|
||||||
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
return GL_FALSE;
|
||||||
|
}
|
||||||
setGLXattrib(attribs, index, GLX_CONTEXT_FLAGS_ARB, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glProfile)
|
if (wndconfig->glProfile)
|
||||||
{
|
{
|
||||||
int flags = 0;
|
if (!_glfwLibrary.GLX.ARB_create_context ||
|
||||||
|
!_glfwLibrary.GLX.ARB_create_context_profile)
|
||||||
if (!_glfwLibrary.GLX.ARB_create_context_profile)
|
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||||
"GLX: An OpenGL profile requested but "
|
"GLX: An OpenGL profile requested but "
|
||||||
"GLX_ARB_create_context_profile is unavailable");
|
"GLX_ARB_create_context_profile is unavailable");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_glfwLibrary.GLX.ARB_create_context)
|
||||||
|
{
|
||||||
|
int index = 0, mask = 0, flags = 0, strategy = 0;
|
||||||
|
|
||||||
|
if (wndconfig->clientAPI == GLFW_OPENGL_API)
|
||||||
|
{
|
||||||
|
if (wndconfig->glForward)
|
||||||
|
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
||||||
|
|
||||||
|
if (wndconfig->glDebug)
|
||||||
|
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
|
||||||
|
|
||||||
|
if (wndconfig->glProfile)
|
||||||
|
{
|
||||||
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
if (wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE)
|
||||||
flags = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
||||||
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
else if (wndconfig->glProfile == GLFW_OPENGL_COMPAT_PROFILE)
|
||||||
flags = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
||||||
|
|
||||||
setGLXattrib(attribs, index, GLX_CONTEXT_PROFILE_MASK_ARB, flags);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (wndconfig->glRobustness)
|
|
||||||
{
|
|
||||||
int strategy;
|
|
||||||
|
|
||||||
if (!_glfwLibrary.GLX.ARB_create_context_robustness)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
|
||||||
"GLX: An OpenGL robustness strategy was "
|
|
||||||
"requested but GLX_ARB_create_context_robustness "
|
|
||||||
"is unavailable");
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
||||||
|
|
||||||
|
if (wndconfig->glRobustness != GLFW_NO_ROBUSTNESS)
|
||||||
|
{
|
||||||
|
if (_glfwLibrary.GLX.ARB_create_context_robustness)
|
||||||
|
{
|
||||||
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
|
||||||
strategy = GLX_NO_RESET_NOTIFICATION_ARB;
|
strategy = GLX_NO_RESET_NOTIFICATION_ARB;
|
||||||
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
else if (wndconfig->glRobustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
||||||
strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
|
strategy = GLX_LOSE_CONTEXT_ON_RESET_ARB;
|
||||||
|
|
||||||
setGLXattrib(attribs,
|
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
||||||
index,
|
}
|
||||||
GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
|
||||||
strategy);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setGLXattrib(attribs, index, None, None);
|
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
|
||||||
|
{
|
||||||
|
// NOTE: Only request an explicitly versioned context when
|
||||||
|
// necessary, as explicitly requesting version 1.0 does not always
|
||||||
|
// return the highest available version
|
||||||
|
|
||||||
|
setGLXattrib(GLX_CONTEXT_MAJOR_VERSION_ARB, wndconfig->glMajor);
|
||||||
|
setGLXattrib(GLX_CONTEXT_MINOR_VERSION_ARB, wndconfig->glMinor);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mask)
|
||||||
|
setGLXattrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
|
||||||
|
|
||||||
|
if (flags)
|
||||||
|
setGLXattrib(GLX_CONTEXT_FLAGS_ARB, flags);
|
||||||
|
|
||||||
|
if (strategy)
|
||||||
|
setGLXattrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB, strategy);
|
||||||
|
|
||||||
|
setGLXattrib(None, None);
|
||||||
|
|
||||||
// This is the only place we set an Xlib error handler, and we only do
|
// This is the only place we set an Xlib error handler, and we only do
|
||||||
// it because glXCreateContextAttribsARB generates a BadMatch error if
|
// it because glXCreateContextAttribsARB generates a BadMatch error if
|
||||||
@ -424,7 +426,7 @@ static int createContext(_GLFWwindow* window,
|
|||||||
// TODO: Handle all the various error codes here
|
// TODO: Handle all the various error codes here
|
||||||
|
|
||||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||||
"GLX: Failed to create OpenGL context");
|
"GLX: Failed to create context");
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user