Make GLX backend more readable

This commit is contained in:
Camilla Berglund 2015-12-03 04:09:26 +01:00
parent 02fdd6459e
commit 66b462d6e1
2 changed files with 38 additions and 39 deletions

View File

@ -42,7 +42,7 @@
static int getFBConfigAttrib(GLXFBConfig fbconfig, int attrib) static int getFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
{ {
int value; int value;
_glfw_glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value); glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
return value; return value;
} }
@ -59,12 +59,12 @@ static GLFWbool chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* result
// HACK: This is a (hopefully temporary) workaround for Chromium // HACK: This is a (hopefully temporary) workaround for Chromium
// (VirtualBox GL) not setting the window bit on any GLXFBConfigs // (VirtualBox GL) not setting the window bit on any GLXFBConfigs
vendor = _glfw_glXGetClientString(_glfw.x11.display, GLX_VENDOR); vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
if (strcmp(vendor, "Chromium") == 0) if (strcmp(vendor, "Chromium") == 0)
trustWindowBit = GLFW_FALSE; trustWindowBit = GLFW_FALSE;
nativeConfigs = _glfw_glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, nativeConfigs =
&nativeCount); glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
if (!nativeCount) if (!nativeCount)
{ {
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned"); _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
@ -136,11 +136,11 @@ static GLXContext createLegacyContext(_GLFWwindow* window,
GLXFBConfig fbconfig, GLXFBConfig fbconfig,
GLXContext share) GLXContext share)
{ {
return _glfw_glXCreateNewContext(_glfw.x11.display, return glXCreateNewContext(_glfw.x11.display,
fbconfig, fbconfig,
GLX_RGBA_TYPE, GLX_RGBA_TYPE,
share, share,
True); True);
} }
@ -212,17 +212,15 @@ int _glfwInitContextAPI(void)
_glfw.glx.GetVisualFromFBConfig = _glfw.glx.GetVisualFromFBConfig =
dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig"); dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
if (!_glfw_glXQueryExtension(_glfw.x11.display, if (!glXQueryExtension(_glfw.x11.display,
&_glfw.glx.errorBase, &_glfw.glx.errorBase,
&_glfw.glx.eventBase)) &_glfw.glx.eventBase))
{ {
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found"); _glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
return GLFW_FALSE; return GLFW_FALSE;
} }
if (!_glfw_glXQueryVersion(_glfw.x11.display, if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
&_glfw.glx.major,
&_glfw.glx.minor))
{ {
_glfwInputError(GLFW_API_UNAVAILABLE, _glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: Failed to query GLX version"); "GLX: Failed to query GLX version");
@ -483,8 +481,8 @@ int _glfwCreateContext(_GLFWwindow* window,
return GLFW_FALSE; return GLFW_FALSE;
} }
window->context.glx.window = _glfw_glXCreateWindow(_glfw.x11.display, native, window->context.glx.window =
window->x11.handle, NULL); glXCreateWindow(_glfw.x11.display, native, window->x11.handle, NULL);
if (!window->context.glx.window) if (!window->context.glx.window)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window"); _glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
@ -502,13 +500,13 @@ void _glfwDestroyContext(_GLFWwindow* window)
{ {
if (window->context.glx.window) if (window->context.glx.window)
{ {
_glfw_glXDestroyWindow(_glfw.x11.display, window->context.glx.window); glXDestroyWindow(_glfw.x11.display, window->context.glx.window);
window->context.glx.window = None; window->context.glx.window = None;
} }
if (window->context.glx.handle) if (window->context.glx.handle)
{ {
_glfw_glXDestroyContext(_glfw.x11.display, window->context.glx.handle); glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
window->context.glx.handle = NULL; window->context.glx.handle = NULL;
} }
} }
@ -529,7 +527,7 @@ GLFWbool _glfwChooseVisual(const _GLFWctxconfig* ctxconfig,
return GLFW_FALSE; return GLFW_FALSE;
} }
result = _glfw_glXGetVisualFromFBConfig(_glfw.x11.display, native); result = glXGetVisualFromFBConfig(_glfw.x11.display, native);
if (!result) if (!result)
{ {
_glfwInputError(GLFW_PLATFORM_ERROR, _glfwInputError(GLFW_PLATFORM_ERROR,
@ -553,19 +551,19 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{ {
if (window) if (window)
{ {
_glfw_glXMakeCurrent(_glfw.x11.display, glXMakeCurrent(_glfw.x11.display,
window->context.glx.window, window->context.glx.window,
window->context.glx.handle); window->context.glx.handle);
} }
else else
_glfw_glXMakeCurrent(_glfw.x11.display, None, NULL); glXMakeCurrent(_glfw.x11.display, None, NULL);
_glfwSetContextTLS(window); _glfwSetContextTLS(window);
} }
void _glfwPlatformSwapBuffers(_GLFWwindow* window) void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{ {
_glfw_glXSwapBuffers(_glfw.x11.display, window->context.glx.window); glXSwapBuffers(_glfw.x11.display, window->context.glx.window);
} }
void _glfwPlatformSwapInterval(int interval) void _glfwPlatformSwapInterval(int interval)
@ -590,7 +588,7 @@ void _glfwPlatformSwapInterval(int interval)
int _glfwPlatformExtensionSupported(const char* extension) int _glfwPlatformExtensionSupported(const char* extension)
{ {
const char* extensions = const char* extensions =
_glfw_glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen); glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
if (extensions) if (extensions)
{ {
if (_glfwStringInExtensionString(extension, extensions)) if (_glfwStringInExtensionString(extension, extensions))

View File

@ -49,6 +49,7 @@
#define GLX_ACCUM_ALPHA_SIZE 17 #define GLX_ACCUM_ALPHA_SIZE 17
#define GLX_SAMPLES 0x186a1 #define GLX_SAMPLES 0x186a1
#define GLX_VISUAL_ID 0x800b #define GLX_VISUAL_ID 0x800b
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2 #define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001 #define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002 #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
@ -93,19 +94,19 @@ typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const in
typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow); typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
// libGL.so function pointer typedefs // libGL.so function pointer typedefs
#define _glfw_glXGetFBConfigs _glfw.glx.GetFBConfigs #define glXGetFBConfigs _glfw.glx.GetFBConfigs
#define _glfw_glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib #define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
#define _glfw_glXGetClientString _glfw.glx.GetClientString #define glXGetClientString _glfw.glx.GetClientString
#define _glfw_glXQueryExtension _glfw.glx.QueryExtension #define glXQueryExtension _glfw.glx.QueryExtension
#define _glfw_glXQueryVersion _glfw.glx.QueryVersion #define glXQueryVersion _glfw.glx.QueryVersion
#define _glfw_glXDestroyContext _glfw.glx.DestroyContext #define glXDestroyContext _glfw.glx.DestroyContext
#define _glfw_glXMakeCurrent _glfw.glx.MakeCurrent #define glXMakeCurrent _glfw.glx.MakeCurrent
#define _glfw_glXSwapBuffers _glfw.glx.SwapBuffers #define glXSwapBuffers _glfw.glx.SwapBuffers
#define _glfw_glXQueryExtensionsString _glfw.glx.QueryExtensionsString #define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
#define _glfw_glXCreateNewContext _glfw.glx.CreateNewContext #define glXCreateNewContext _glfw.glx.CreateNewContext
#define _glfw_glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig #define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
#define _glfw_glXCreateWindow _glfw.glx.CreateWindow #define glXCreateWindow _glfw.glx.CreateWindow
#define _glfw_glXDestroyWindow _glfw.glx.DestroyWindow #define glXDestroyWindow _glfw.glx.DestroyWindow
#define _GLFW_PLATFORM_FBCONFIG GLXFBConfig glx #define _GLFW_PLATFORM_FBCONFIG GLXFBConfig glx
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx