mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
Make GLX backend more readable
This commit is contained in:
parent
02fdd6459e
commit
66b462d6e1
@ -42,7 +42,7 @@
|
||||
static int getFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
|
||||
{
|
||||
int value;
|
||||
_glfw_glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
|
||||
glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
|
||||
return value;
|
||||
}
|
||||
|
||||
@ -59,12 +59,12 @@ static GLFWbool chooseFBConfig(const _GLFWfbconfig* desired, GLXFBConfig* result
|
||||
|
||||
// HACK: This is a (hopefully temporary) workaround for Chromium
|
||||
// (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)
|
||||
trustWindowBit = GLFW_FALSE;
|
||||
|
||||
nativeConfigs = _glfw_glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen,
|
||||
&nativeCount);
|
||||
nativeConfigs =
|
||||
glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
|
||||
if (!nativeCount)
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
|
||||
@ -136,11 +136,11 @@ static GLXContext createLegacyContext(_GLFWwindow* window,
|
||||
GLXFBConfig fbconfig,
|
||||
GLXContext share)
|
||||
{
|
||||
return _glfw_glXCreateNewContext(_glfw.x11.display,
|
||||
fbconfig,
|
||||
GLX_RGBA_TYPE,
|
||||
share,
|
||||
True);
|
||||
return glXCreateNewContext(_glfw.x11.display,
|
||||
fbconfig,
|
||||
GLX_RGBA_TYPE,
|
||||
share,
|
||||
True);
|
||||
}
|
||||
|
||||
|
||||
@ -212,17 +212,15 @@ int _glfwInitContextAPI(void)
|
||||
_glfw.glx.GetVisualFromFBConfig =
|
||||
dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
|
||||
|
||||
if (!_glfw_glXQueryExtension(_glfw.x11.display,
|
||||
&_glfw.glx.errorBase,
|
||||
&_glfw.glx.eventBase))
|
||||
if (!glXQueryExtension(_glfw.x11.display,
|
||||
&_glfw.glx.errorBase,
|
||||
&_glfw.glx.eventBase))
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
if (!_glfw_glXQueryVersion(_glfw.x11.display,
|
||||
&_glfw.glx.major,
|
||||
&_glfw.glx.minor))
|
||||
if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
|
||||
{
|
||||
_glfwInputError(GLFW_API_UNAVAILABLE,
|
||||
"GLX: Failed to query GLX version");
|
||||
@ -483,8 +481,8 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
window->context.glx.window = _glfw_glXCreateWindow(_glfw.x11.display, native,
|
||||
window->x11.handle, NULL);
|
||||
window->context.glx.window =
|
||||
glXCreateWindow(_glfw.x11.display, native, window->x11.handle, NULL);
|
||||
if (!window->context.glx.window)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
|
||||
@ -502,13 +500,13 @@ void _glfwDestroyContext(_GLFWwindow* 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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@ -529,7 +527,7 @@ GLFWbool _glfwChooseVisual(const _GLFWctxconfig* ctxconfig,
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
result = _glfw_glXGetVisualFromFBConfig(_glfw.x11.display, native);
|
||||
result = glXGetVisualFromFBConfig(_glfw.x11.display, native);
|
||||
if (!result)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
@ -553,19 +551,19 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
||||
{
|
||||
if (window)
|
||||
{
|
||||
_glfw_glXMakeCurrent(_glfw.x11.display,
|
||||
window->context.glx.window,
|
||||
window->context.glx.handle);
|
||||
glXMakeCurrent(_glfw.x11.display,
|
||||
window->context.glx.window,
|
||||
window->context.glx.handle);
|
||||
}
|
||||
else
|
||||
_glfw_glXMakeCurrent(_glfw.x11.display, None, NULL);
|
||||
glXMakeCurrent(_glfw.x11.display, None, NULL);
|
||||
|
||||
_glfwSetContextTLS(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)
|
||||
@ -590,7 +588,7 @@ void _glfwPlatformSwapInterval(int interval)
|
||||
int _glfwPlatformExtensionSupported(const char* extension)
|
||||
{
|
||||
const char* extensions =
|
||||
_glfw_glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
|
||||
glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
|
||||
if (extensions)
|
||||
{
|
||||
if (_glfwStringInExtensionString(extension, extensions))
|
||||
|
@ -49,6 +49,7 @@
|
||||
#define GLX_ACCUM_ALPHA_SIZE 17
|
||||
#define GLX_SAMPLES 0x186a1
|
||||
#define GLX_VISUAL_ID 0x800b
|
||||
|
||||
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
|
||||
#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
|
||||
#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);
|
||||
|
||||
// libGL.so function pointer typedefs
|
||||
#define _glfw_glXGetFBConfigs _glfw.glx.GetFBConfigs
|
||||
#define _glfw_glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
|
||||
#define _glfw_glXGetClientString _glfw.glx.GetClientString
|
||||
#define _glfw_glXQueryExtension _glfw.glx.QueryExtension
|
||||
#define _glfw_glXQueryVersion _glfw.glx.QueryVersion
|
||||
#define _glfw_glXDestroyContext _glfw.glx.DestroyContext
|
||||
#define _glfw_glXMakeCurrent _glfw.glx.MakeCurrent
|
||||
#define _glfw_glXSwapBuffers _glfw.glx.SwapBuffers
|
||||
#define _glfw_glXQueryExtensionsString _glfw.glx.QueryExtensionsString
|
||||
#define _glfw_glXCreateNewContext _glfw.glx.CreateNewContext
|
||||
#define _glfw_glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
|
||||
#define _glfw_glXCreateWindow _glfw.glx.CreateWindow
|
||||
#define _glfw_glXDestroyWindow _glfw.glx.DestroyWindow
|
||||
#define glXGetFBConfigs _glfw.glx.GetFBConfigs
|
||||
#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
|
||||
#define glXGetClientString _glfw.glx.GetClientString
|
||||
#define glXQueryExtension _glfw.glx.QueryExtension
|
||||
#define glXQueryVersion _glfw.glx.QueryVersion
|
||||
#define glXDestroyContext _glfw.glx.DestroyContext
|
||||
#define glXMakeCurrent _glfw.glx.MakeCurrent
|
||||
#define glXSwapBuffers _glfw.glx.SwapBuffers
|
||||
#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
|
||||
#define glXCreateNewContext _glfw.glx.CreateNewContext
|
||||
#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
|
||||
#define glXCreateWindow _glfw.glx.CreateWindow
|
||||
#define glXDestroyWindow _glfw.glx.DestroyWindow
|
||||
|
||||
#define _GLFW_PLATFORM_FBCONFIG GLXFBConfig glx
|
||||
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
|
||||
|
Loading…
Reference in New Issue
Block a user