Use GLXWindow renderables on X11

Fixes #507.
This commit is contained in:
Camilla Berglund 2015-10-15 20:10:24 +02:00
parent 496f559c9a
commit 962497bdc9
3 changed files with 30 additions and 3 deletions

View File

@ -72,6 +72,7 @@ used by the tests and examples and are not required to build the library.
- [Cocoa] Removed support for OS X 10.6
- [X11] Bugfix: Monitor connection and disconnection events were not reported
- [WGL] Removed dependency on external WGL headers
- [GLX] Replaced legacy renderable with `GLXWindow`
- [GLX] Removed dependency on external GLX headers
- [EGL] Removed dependency on external EGL headers

View File

@ -188,6 +188,10 @@ int _glfwInitContextAPI(void)
dlsym(_glfw.glx.handle, "glXQueryExtensionsString");
_glfw.glx.CreateNewContext =
dlsym(_glfw.glx.handle, "glXCreateNewContext");
_glfw.glx.CreateWindow =
dlsym(_glfw.glx.handle, "glXCreateWindow");
_glfw.glx.DestroyWindow =
dlsym(_glfw.glx.handle, "glXDestroyWindow");
_glfw.glx.GetProcAddress =
dlsym(_glfw.glx.handle, "glXGetProcAddress");
_glfw.glx.GetProcAddressARB =
@ -463,6 +467,14 @@ int _glfwCreateContext(_GLFWwindow* window,
return GLFW_FALSE;
}
window->glx.window = _glfw_glXCreateWindow(_glfw.x11.display, native,
window->x11.handle, NULL);
if (!window->glx.window)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
return GLFW_FALSE;
}
return GLFW_TRUE;
}
@ -472,6 +484,12 @@ int _glfwCreateContext(_GLFWwindow* window,
//
void _glfwDestroyContext(_GLFWwindow* window)
{
if (window->glx.window)
{
_glfw_glXDestroyWindow(_glfw.x11.display, window->glx.window);
window->glx.window = None;
}
if (window->glx.context)
{
_glfw_glXDestroyContext(_glfw.x11.display, window->glx.context);
@ -520,7 +538,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
if (window)
{
_glfw_glXMakeCurrent(_glfw.x11.display,
window->x11.handle,
window->glx.window,
window->glx.context);
}
else
@ -531,7 +549,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{
_glfw_glXSwapBuffers(_glfw.x11.display, window->x11.handle);
_glfw_glXSwapBuffers(_glfw.x11.display, window->glx.window);
}
void _glfwPlatformSwapInterval(int interval)
@ -541,7 +559,7 @@ void _glfwPlatformSwapInterval(int interval)
if (_glfw.glx.EXT_swap_control)
{
_glfw.glx.SwapIntervalEXT(_glfw.x11.display,
window->x11.handle,
window->glx.window,
interval);
}
else if (_glfw.glx.MESA_swap_control)

View File

@ -67,6 +67,7 @@
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
typedef XID GLXWindow;
typedef XID GLXDrawable;
typedef struct __GLXFBConfig* GLXFBConfig;
typedef struct __GLXcontext* GLXContext;
@ -88,6 +89,8 @@ typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*);
typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*);
typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
// libGL.so function pointer typedefs
#define _glfw_glXGetFBConfigs _glfw.glx.GetFBConfigs
@ -101,6 +104,8 @@ typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
#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 _GLFW_PLATFORM_FBCONFIG GLXFBConfig glx
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
@ -112,6 +117,7 @@ typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
typedef struct _GLFWcontextGLX
{
GLXContext context;
GLXWindow window;
} _GLFWcontextGLX;
@ -139,6 +145,8 @@ typedef struct _GLFWlibraryGLX
PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString;
PFNGLXCREATENEWCONTEXTPROC CreateNewContext;
PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig;
PFNGLXCREATEWINDOWPROC CreateWindow;
PFNGLXDESTROYWINDOWPROC DestroyWindow;
// GLX 1.4 and extension functions
PFNGLXGETPROCADDRESSPROC GetProcAddress;