Moved remaining X visual management into opengl module.

This commit is contained in:
Camilla Berglund 2012-04-23 22:31:55 +02:00
parent f77c8f8b21
commit a22fbf7e9b
3 changed files with 21 additions and 9 deletions

View File

@ -637,6 +637,12 @@ int _glfwCreateContext(_GLFWwindow* window,
void _glfwDestroyContext(_GLFWwindow* window) void _glfwDestroyContext(_GLFWwindow* window)
{ {
if (window->GLX.visual)
{
XFree(window->GLX.visual);
window->GLX.visual = NULL;
}
if (window->GLX.context) if (window->GLX.context)
{ {
// Release and destroy the context // Release and destroy the context
@ -647,6 +653,16 @@ void _glfwDestroyContext(_GLFWwindow* window)
} }
//========================================================================
// Return the X visual associated with the specified context
//========================================================================
XVisualInfo* _glfwGetContextVisual(_GLFWwindow* window)
{
return window->GLX.visual;
}
//======================================================================== //========================================================================
// Make the OpenGL context associated with the specified window current // Make the OpenGL context associated with the specified window current
//======================================================================== //========================================================================

View File

@ -289,6 +289,7 @@ int _glfwCreateContext(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig, const _GLFWwndconfig* wndconfig,
const _GLFWfbconfig* fbconfig); const _GLFWfbconfig* fbconfig);
void _glfwDestroyContext(_GLFWwindow* window); void _glfwDestroyContext(_GLFWwindow* window);
XVisualInfo* _glfwGetContextVisual(_GLFWwindow* window);
// Fullscreen support // Fullscreen support
int _glfwGetClosestVideoMode(int* width, int* height, int* rate); int _glfwGetClosestVideoMode(int* width, int* height, int* rate);

View File

@ -97,13 +97,14 @@ static GLboolean createWindow(_GLFWwindow* window,
XEvent event; XEvent event;
unsigned long wamask; unsigned long wamask;
XSetWindowAttributes wa; XSetWindowAttributes wa;
XVisualInfo* visual = _glfwGetContextVisual(window);
// Every window needs a colormap // Every window needs a colormap
// Create one based on the visual used by the current context // Create one based on the visual used by the current context
window->X11.colormap = XCreateColormap(_glfwLibrary.X11.display, window->X11.colormap = XCreateColormap(_glfwLibrary.X11.display,
_glfwLibrary.X11.root, _glfwLibrary.X11.root,
window->GLX.visual->visual, visual->visual,
AllocNone); AllocNone);
// Create the actual window // Create the actual window
@ -133,9 +134,9 @@ static GLboolean createWindow(_GLFWwindow* window,
0, 0, // Upper left corner of this window on root 0, 0, // Upper left corner of this window on root
window->width, window->height, window->width, window->height,
0, // Border width 0, // Border width
window->GLX.visual->depth, // Color depth visual->depth, // Color depth
InputOutput, InputOutput,
window->GLX.visual->visual, visual->visual,
wamask, wamask,
&wa &wa
); );
@ -979,12 +980,6 @@ void _glfwPlatformCloseWindow(_GLFWwindow* window)
_glfwDestroyContext(window); _glfwDestroyContext(window);
if (window->GLX.visual)
{
XFree(window->GLX.visual);
window->GLX.visual = NULL;
}
if (window->X11.handle) if (window->X11.handle)
{ {
XUnmapWindow(_glfwLibrary.X11.display, window->X11.handle); XUnmapWindow(_glfwLibrary.X11.display, window->X11.handle);