2010-09-07 17:34:51 +02:00
|
|
|
//========================================================================
|
2016-08-18 23:42:15 +02:00
|
|
|
// GLFW 3.3 GLX - www.glfw.org
|
2010-09-07 17:34:51 +02:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
2016-11-21 16:23:59 +01:00
|
|
|
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
|
2010-09-07 17:34:51 +02:00
|
|
|
//
|
|
|
|
// This software is provided 'as-is', without any express or implied
|
|
|
|
// warranty. In no event will the authors be held liable for any damages
|
|
|
|
// arising from the use of this software.
|
|
|
|
//
|
|
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
|
|
// including commercial applications, and to alter it and redistribute it
|
|
|
|
// freely, subject to the following restrictions:
|
|
|
|
//
|
|
|
|
// 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
// claim that you wrote the original software. If you use this software
|
|
|
|
// in a product, an acknowledgment in the product documentation would
|
|
|
|
// be appreciated but is not required.
|
|
|
|
//
|
|
|
|
// 2. Altered source versions must be plainly marked as such, and must not
|
|
|
|
// be misrepresented as being the original software.
|
|
|
|
//
|
|
|
|
// 3. This notice may not be removed or altered from any source
|
|
|
|
// distribution.
|
|
|
|
//
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
2012-06-03 16:33:48 +02:00
|
|
|
#include <string.h>
|
2012-04-23 12:48:57 +02:00
|
|
|
#include <stdlib.h>
|
2013-01-15 20:00:27 +01:00
|
|
|
#include <assert.h>
|
2010-09-07 17:34:51 +02:00
|
|
|
|
2012-12-30 18:13:04 +01:00
|
|
|
#ifndef GLXBadProfileARB
|
|
|
|
#define GLXBadProfileARB 13
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
2013-05-13 15:49:59 +02:00
|
|
|
// Returns the specified attribute of the specified GLXFBConfig
|
|
|
|
//
|
2016-06-14 12:27:19 +02:00
|
|
|
static int getGLXFBConfigAttrib(GLXFBConfig fbconfig, int attrib)
|
2013-05-13 15:49:59 +02:00
|
|
|
{
|
|
|
|
int value;
|
2015-12-03 04:09:26 +01:00
|
|
|
glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
|
2013-05-13 15:49:59 +02:00
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
// Return the GLXFBConfig most closely matching the specified hints
|
2013-05-13 15:49:59 +02:00
|
|
|
//
|
2016-02-22 18:08:15 +01:00
|
|
|
static GLFWbool chooseGLXFBConfig(
|
|
|
|
const _GLFWfbconfig* desired,
|
|
|
|
GLXFBConfig* result,
|
|
|
|
GLFWbool findTransparent)
|
2013-05-13 15:49:59 +02:00
|
|
|
{
|
|
|
|
GLXFBConfig* nativeConfigs;
|
|
|
|
_GLFWfbconfig* usableConfigs;
|
|
|
|
const _GLFWfbconfig* closest;
|
|
|
|
int i, nativeCount, usableCount;
|
|
|
|
const char* vendor;
|
2015-08-23 19:30:04 +02:00
|
|
|
GLFWbool trustWindowBit = GLFW_TRUE;
|
2013-05-13 15:49:59 +02:00
|
|
|
|
2016-02-22 18:08:15 +01:00
|
|
|
if ( !(_glfw.xrender.major || _glfw.xrender.minor) ) {
|
|
|
|
findTransparent = GLFW_FALSE;
|
|
|
|
}
|
|
|
|
|
2015-04-07 02:51:45 +02:00
|
|
|
// HACK: This is a (hopefully temporary) workaround for Chromium
|
|
|
|
// (VirtualBox GL) not setting the window bit on any GLXFBConfigs
|
2015-12-03 04:09:26 +01:00
|
|
|
vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
|
2016-12-07 00:19:05 +01:00
|
|
|
if (vendor && strcmp(vendor, "Chromium") == 0)
|
2015-08-23 19:30:04 +02:00
|
|
|
trustWindowBit = GLFW_FALSE;
|
2013-05-13 15:49:59 +02:00
|
|
|
|
2015-12-03 04:09:26 +01:00
|
|
|
nativeConfigs =
|
|
|
|
glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &nativeCount);
|
2017-07-07 10:23:58 +02:00
|
|
|
if (!nativeConfigs || !nativeCount)
|
2013-05-13 15:49:59 +02:00
|
|
|
{
|
2014-03-06 16:45:40 +01:00
|
|
|
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: No GLXFBConfigs returned");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2013-05-13 15:49:59 +02:00
|
|
|
}
|
|
|
|
|
2013-07-04 14:54:07 +02:00
|
|
|
usableConfigs = calloc(nativeCount, sizeof(_GLFWfbconfig));
|
2013-05-13 15:49:59 +02:00
|
|
|
usableCount = 0;
|
|
|
|
|
2016-02-22 18:08:15 +01:00
|
|
|
selectionloop:
|
2013-05-13 15:49:59 +02:00
|
|
|
for (i = 0; i < nativeCount; i++)
|
|
|
|
{
|
|
|
|
const GLXFBConfig n = nativeConfigs[i];
|
|
|
|
_GLFWfbconfig* u = usableConfigs + usableCount;
|
|
|
|
|
2015-04-07 02:51:45 +02:00
|
|
|
// Only consider RGBA GLXFBConfigs
|
2016-06-14 12:27:19 +02:00
|
|
|
if (!(getGLXFBConfigAttrib(n, GLX_RENDER_TYPE) & GLX_RGBA_BIT))
|
2013-05-13 15:49:59 +02:00
|
|
|
continue;
|
|
|
|
|
2015-04-07 02:51:45 +02:00
|
|
|
// Only consider window GLXFBConfigs
|
2016-06-14 12:27:19 +02:00
|
|
|
if (!(getGLXFBConfigAttrib(n, GLX_DRAWABLE_TYPE) & GLX_WINDOW_BIT))
|
2013-05-13 15:49:59 +02:00
|
|
|
{
|
|
|
|
if (trustWindowBit)
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-02-22 18:08:15 +01:00
|
|
|
if( findTransparent ) {
|
|
|
|
XVisualInfo *visualinfo;
|
|
|
|
XRenderPictFormat *pictFormat;
|
|
|
|
|
|
|
|
visualinfo = glXGetVisualFromFBConfig(_glfw.x11.display, n);
|
|
|
|
if (!visualinfo)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
pictFormat = XRenderFindVisualFormat(_glfw.x11.display, visualinfo->visual);
|
|
|
|
if( !pictFormat ) {
|
|
|
|
XFree( visualinfo );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !pictFormat->direct.alphaMask ) {
|
|
|
|
XFree( visualinfo );
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
XFree( visualinfo );
|
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
u->redBits = getGLXFBConfigAttrib(n, GLX_RED_SIZE);
|
|
|
|
u->greenBits = getGLXFBConfigAttrib(n, GLX_GREEN_SIZE);
|
|
|
|
u->blueBits = getGLXFBConfigAttrib(n, GLX_BLUE_SIZE);
|
2013-05-13 15:49:59 +02:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
u->alphaBits = getGLXFBConfigAttrib(n, GLX_ALPHA_SIZE);
|
|
|
|
u->depthBits = getGLXFBConfigAttrib(n, GLX_DEPTH_SIZE);
|
|
|
|
u->stencilBits = getGLXFBConfigAttrib(n, GLX_STENCIL_SIZE);
|
2013-05-13 15:49:59 +02:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
u->accumRedBits = getGLXFBConfigAttrib(n, GLX_ACCUM_RED_SIZE);
|
|
|
|
u->accumGreenBits = getGLXFBConfigAttrib(n, GLX_ACCUM_GREEN_SIZE);
|
|
|
|
u->accumBlueBits = getGLXFBConfigAttrib(n, GLX_ACCUM_BLUE_SIZE);
|
|
|
|
u->accumAlphaBits = getGLXFBConfigAttrib(n, GLX_ACCUM_ALPHA_SIZE);
|
2013-05-13 15:49:59 +02:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
u->auxBuffers = getGLXFBConfigAttrib(n, GLX_AUX_BUFFERS);
|
2014-04-24 19:21:10 +02:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (getGLXFBConfigAttrib(n, GLX_STEREO))
|
2015-08-23 19:30:04 +02:00
|
|
|
u->stereo = GLFW_TRUE;
|
2016-06-14 12:27:19 +02:00
|
|
|
if (getGLXFBConfigAttrib(n, GLX_DOUBLEBUFFER))
|
2015-08-23 19:30:04 +02:00
|
|
|
u->doublebuffer = GLFW_TRUE;
|
2013-05-13 15:49:59 +02:00
|
|
|
|
|
|
|
if (_glfw.glx.ARB_multisample)
|
2016-06-14 12:27:19 +02:00
|
|
|
u->samples = getGLXFBConfigAttrib(n, GLX_SAMPLES);
|
2013-05-13 15:49:59 +02:00
|
|
|
|
2015-07-14 15:44:13 +02:00
|
|
|
if (_glfw.glx.ARB_framebuffer_sRGB || _glfw.glx.EXT_framebuffer_sRGB)
|
2016-06-14 12:27:19 +02:00
|
|
|
u->sRGB = getGLXFBConfigAttrib(n, GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
|
2013-05-13 15:49:59 +02:00
|
|
|
|
2016-03-28 20:11:22 +02:00
|
|
|
u->handle = (uintptr_t) n;
|
2013-05-13 15:49:59 +02:00
|
|
|
usableCount++;
|
|
|
|
}
|
2016-02-22 18:08:15 +01:00
|
|
|
// reiterate the selection loop without looking for transparency supporting
|
|
|
|
// formats if no matchig FB configs for a transparent window were found.
|
|
|
|
if( findTransparent && !usableCount ) {
|
|
|
|
findTransparent = GLFW_FALSE;
|
|
|
|
goto selectionloop;
|
|
|
|
}
|
2013-05-13 15:49:59 +02:00
|
|
|
|
|
|
|
closest = _glfwChooseFBConfig(desired, usableConfigs, usableCount);
|
|
|
|
if (closest)
|
2016-03-28 20:11:22 +02:00
|
|
|
*result = (GLXFBConfig) closest->handle;
|
2013-05-13 15:49:59 +02:00
|
|
|
|
|
|
|
XFree(nativeConfigs);
|
|
|
|
free(usableConfigs);
|
|
|
|
|
2016-03-28 20:11:22 +02:00
|
|
|
return closest != NULL;
|
2013-05-13 15:49:59 +02:00
|
|
|
}
|
|
|
|
|
2013-01-15 20:00:27 +01:00
|
|
|
// Create the OpenGL context using legacy API
|
2013-02-04 13:22:10 +01:00
|
|
|
//
|
2016-06-14 12:27:19 +02:00
|
|
|
static GLXContext createLegacyContextGLX(_GLFWwindow* window,
|
|
|
|
GLXFBConfig fbconfig,
|
|
|
|
GLXContext share)
|
2013-01-15 20:00:27 +01:00
|
|
|
{
|
2015-12-03 04:09:26 +01:00
|
|
|
return glXCreateNewContext(_glfw.x11.display,
|
|
|
|
fbconfig,
|
|
|
|
GLX_RGBA_TYPE,
|
|
|
|
share,
|
|
|
|
True);
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
static void makeContextCurrentGLX(_GLFWwindow* window)
|
2016-03-28 13:19:31 +02:00
|
|
|
{
|
|
|
|
if (window)
|
|
|
|
{
|
|
|
|
if (!glXMakeCurrent(_glfw.x11.display,
|
|
|
|
window->context.glx.window,
|
|
|
|
window->context.glx.handle))
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
"GLX: Failed to make context current");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!glXMakeCurrent(_glfw.x11.display, None, NULL))
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
"GLX: Failed to clear current context");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-05-25 18:23:09 +02:00
|
|
|
_glfwPlatformSetTls(&_glfw.contextSlot, window);
|
2016-03-28 13:19:31 +02:00
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
static void swapBuffersGLX(_GLFWwindow* window)
|
2016-03-28 13:19:31 +02:00
|
|
|
{
|
|
|
|
glXSwapBuffers(_glfw.x11.display, window->context.glx.window);
|
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
static void swapIntervalGLX(int interval)
|
2016-03-28 13:19:31 +02:00
|
|
|
{
|
2017-05-25 18:23:09 +02:00
|
|
|
_GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot);
|
2016-03-28 13:19:31 +02:00
|
|
|
|
|
|
|
if (_glfw.glx.EXT_swap_control)
|
|
|
|
{
|
|
|
|
_glfw.glx.SwapIntervalEXT(_glfw.x11.display,
|
|
|
|
window->context.glx.window,
|
|
|
|
interval);
|
|
|
|
}
|
|
|
|
else if (_glfw.glx.MESA_swap_control)
|
|
|
|
_glfw.glx.SwapIntervalMESA(interval);
|
|
|
|
else if (_glfw.glx.SGI_swap_control)
|
|
|
|
{
|
|
|
|
if (interval > 0)
|
|
|
|
_glfw.glx.SwapIntervalSGI(interval);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
static int extensionSupportedGLX(const char* extension)
|
2016-03-28 13:19:31 +02:00
|
|
|
{
|
|
|
|
const char* extensions =
|
|
|
|
glXQueryExtensionsString(_glfw.x11.display, _glfw.x11.screen);
|
|
|
|
if (extensions)
|
|
|
|
{
|
|
|
|
if (_glfwStringInExtensionString(extension, extensions))
|
|
|
|
return GLFW_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return GLFW_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
static GLFWglproc getProcAddressGLX(const char* procname)
|
2016-03-28 13:19:31 +02:00
|
|
|
{
|
|
|
|
if (_glfw.glx.GetProcAddress)
|
|
|
|
return _glfw.glx.GetProcAddress((const GLubyte*) procname);
|
|
|
|
else if (_glfw.glx.GetProcAddressARB)
|
|
|
|
return _glfw.glx.GetProcAddressARB((const GLubyte*) procname);
|
|
|
|
else
|
|
|
|
return dlsym(_glfw.glx.handle, procname);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Destroy the OpenGL context
|
|
|
|
//
|
2016-06-14 12:27:19 +02:00
|
|
|
static void destroyContextGLX(_GLFWwindow* window)
|
2016-03-28 13:19:31 +02:00
|
|
|
{
|
|
|
|
if (window->context.glx.window)
|
|
|
|
{
|
|
|
|
glXDestroyWindow(_glfw.x11.display, window->context.glx.window);
|
|
|
|
window->context.glx.window = None;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (window->context.glx.handle)
|
|
|
|
{
|
|
|
|
glXDestroyContext(_glfw.x11.display, window->context.glx.handle);
|
|
|
|
window->context.glx.handle = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2013-01-15 20:00:27 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
////// GLFW internal API //////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
// Initialize GLX
|
2013-02-04 13:22:10 +01:00
|
|
|
//
|
2015-12-10 17:10:05 +01:00
|
|
|
GLFWbool _glfwInitGLX(void)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2015-11-17 23:29:08 +01:00
|
|
|
int i;
|
|
|
|
const char* sonames[] =
|
|
|
|
{
|
2017-09-10 21:02:26 +02:00
|
|
|
#if defined(_GLFW_GLX_LIBRARY)
|
|
|
|
_GLFW_GLX_LIBRARY,
|
|
|
|
#elif defined(__CYGWIN__)
|
2015-11-17 23:29:08 +01:00
|
|
|
"libGL-1.so",
|
2015-08-18 16:56:19 +02:00
|
|
|
#else
|
2015-11-17 23:29:08 +01:00
|
|
|
"libGL.so.1",
|
|
|
|
"libGL.so",
|
2015-08-18 16:56:19 +02:00
|
|
|
#endif
|
2015-11-17 23:29:08 +01:00
|
|
|
NULL
|
|
|
|
};
|
|
|
|
|
2016-07-20 12:52:06 +02:00
|
|
|
if (_glfw.glx.handle)
|
|
|
|
return GLFW_TRUE;
|
|
|
|
|
2015-11-17 23:29:08 +01:00
|
|
|
for (i = 0; sonames[i]; i++)
|
|
|
|
{
|
|
|
|
_glfw.glx.handle = dlopen(sonames[i], RTLD_LAZY | RTLD_GLOBAL);
|
|
|
|
if (_glfw.glx.handle)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2015-05-27 01:06:36 +02:00
|
|
|
if (!_glfw.glx.handle)
|
2013-01-15 20:00:27 +01:00
|
|
|
{
|
2015-11-17 23:29:08 +01:00
|
|
|
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: Failed to load GLX");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2013-01-15 20:00:27 +01:00
|
|
|
}
|
2015-05-27 01:06:36 +02:00
|
|
|
|
2015-08-13 00:21:33 +02:00
|
|
|
_glfw.glx.GetFBConfigs =
|
|
|
|
dlsym(_glfw.glx.handle, "glXGetFBConfigs");
|
|
|
|
_glfw.glx.GetFBConfigAttrib =
|
|
|
|
dlsym(_glfw.glx.handle, "glXGetFBConfigAttrib");
|
|
|
|
_glfw.glx.GetClientString =
|
|
|
|
dlsym(_glfw.glx.handle, "glXGetClientString");
|
|
|
|
_glfw.glx.QueryExtension =
|
|
|
|
dlsym(_glfw.glx.handle, "glXQueryExtension");
|
|
|
|
_glfw.glx.QueryVersion =
|
|
|
|
dlsym(_glfw.glx.handle, "glXQueryVersion");
|
|
|
|
_glfw.glx.DestroyContext =
|
|
|
|
dlsym(_glfw.glx.handle, "glXDestroyContext");
|
|
|
|
_glfw.glx.MakeCurrent =
|
|
|
|
dlsym(_glfw.glx.handle, "glXMakeCurrent");
|
|
|
|
_glfw.glx.SwapBuffers =
|
|
|
|
dlsym(_glfw.glx.handle, "glXSwapBuffers");
|
|
|
|
_glfw.glx.QueryExtensionsString =
|
|
|
|
dlsym(_glfw.glx.handle, "glXQueryExtensionsString");
|
|
|
|
_glfw.glx.CreateNewContext =
|
|
|
|
dlsym(_glfw.glx.handle, "glXCreateNewContext");
|
2015-10-15 20:10:24 +02:00
|
|
|
_glfw.glx.CreateWindow =
|
|
|
|
dlsym(_glfw.glx.handle, "glXCreateWindow");
|
|
|
|
_glfw.glx.DestroyWindow =
|
|
|
|
dlsym(_glfw.glx.handle, "glXDestroyWindow");
|
2015-05-27 01:06:36 +02:00
|
|
|
_glfw.glx.GetProcAddress =
|
|
|
|
dlsym(_glfw.glx.handle, "glXGetProcAddress");
|
|
|
|
_glfw.glx.GetProcAddressARB =
|
|
|
|
dlsym(_glfw.glx.handle, "glXGetProcAddressARB");
|
2015-06-18 14:03:02 +02:00
|
|
|
_glfw.glx.GetVisualFromFBConfig =
|
|
|
|
dlsym(_glfw.glx.handle, "glXGetVisualFromFBConfig");
|
2012-06-03 16:31:56 +02:00
|
|
|
|
2016-07-01 18:14:56 +02:00
|
|
|
if (!_glfw.glx.GetFBConfigs ||
|
|
|
|
!_glfw.glx.GetFBConfigAttrib ||
|
|
|
|
!_glfw.glx.GetClientString ||
|
|
|
|
!_glfw.glx.QueryExtension ||
|
|
|
|
!_glfw.glx.QueryVersion ||
|
|
|
|
!_glfw.glx.DestroyContext ||
|
|
|
|
!_glfw.glx.MakeCurrent ||
|
|
|
|
!_glfw.glx.SwapBuffers ||
|
|
|
|
!_glfw.glx.QueryExtensionsString ||
|
|
|
|
!_glfw.glx.CreateNewContext ||
|
|
|
|
!_glfw.glx.CreateWindow ||
|
|
|
|
!_glfw.glx.DestroyWindow ||
|
|
|
|
!_glfw.glx.GetProcAddress ||
|
|
|
|
!_glfw.glx.GetProcAddressARB ||
|
|
|
|
!_glfw.glx.GetVisualFromFBConfig)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
"GLX: Failed to load required entry points");
|
|
|
|
return GLFW_FALSE;
|
|
|
|
}
|
|
|
|
|
2015-12-03 04:09:26 +01:00
|
|
|
if (!glXQueryExtension(_glfw.x11.display,
|
|
|
|
&_glfw.glx.errorBase,
|
|
|
|
&_glfw.glx.eventBase))
|
2012-06-03 16:31:56 +02:00
|
|
|
{
|
2014-03-30 10:45:33 +02:00
|
|
|
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX extension not found");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2012-06-03 16:31:56 +02:00
|
|
|
}
|
|
|
|
|
2015-12-03 04:09:26 +01:00
|
|
|
if (!glXQueryVersion(_glfw.x11.display, &_glfw.glx.major, &_glfw.glx.minor))
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2013-01-15 20:00:27 +01:00
|
|
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
|
|
|
"GLX: Failed to query GLX version");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
2013-01-15 20:00:27 +01:00
|
|
|
|
2015-05-27 14:35:31 +02:00
|
|
|
if (_glfw.glx.major == 1 && _glfw.glx.minor < 3)
|
2014-03-30 10:45:33 +02:00
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
|
|
|
"GLX: GLX version 1.3 is required");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2014-03-30 10:45:33 +02:00
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_EXT_swap_control"))
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2013-01-15 20:00:27 +01:00
|
|
|
_glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
|
2016-06-14 12:27:19 +02:00
|
|
|
getProcAddressGLX("glXSwapIntervalEXT");
|
2013-01-15 20:00:27 +01:00
|
|
|
|
|
|
|
if (_glfw.glx.SwapIntervalEXT)
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.EXT_swap_control = GLFW_TRUE;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_SGI_swap_control"))
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2013-01-15 20:00:27 +01:00
|
|
|
_glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
|
2016-06-14 12:27:19 +02:00
|
|
|
getProcAddressGLX("glXSwapIntervalSGI");
|
2013-01-15 20:00:27 +01:00
|
|
|
|
|
|
|
if (_glfw.glx.SwapIntervalSGI)
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.SGI_swap_control = GLFW_TRUE;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_MESA_swap_control"))
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2013-01-15 20:00:27 +01:00
|
|
|
_glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
|
2016-06-14 12:27:19 +02:00
|
|
|
getProcAddressGLX("glXSwapIntervalMESA");
|
2012-06-03 16:40:54 +02:00
|
|
|
|
2013-01-15 20:00:27 +01:00
|
|
|
if (_glfw.glx.SwapIntervalMESA)
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.MESA_swap_control = GLFW_TRUE;
|
2013-01-15 20:00:27 +01:00
|
|
|
}
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_ARB_multisample"))
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.ARB_multisample = GLFW_TRUE;
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_ARB_framebuffer_sRGB"))
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.ARB_framebuffer_sRGB = GLFW_TRUE;
|
2012-12-02 16:10:00 +01:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_EXT_framebuffer_sRGB"))
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.EXT_framebuffer_sRGB = GLFW_TRUE;
|
2015-07-14 15:44:13 +02:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_ARB_create_context"))
|
2013-01-15 20:00:27 +01:00
|
|
|
{
|
|
|
|
_glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
|
2016-06-14 12:27:19 +02:00
|
|
|
getProcAddressGLX("glXCreateContextAttribsARB");
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2013-01-15 20:00:27 +01:00
|
|
|
if (_glfw.glx.CreateContextAttribsARB)
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.ARB_create_context = GLFW_TRUE;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_ARB_create_context_robustness"))
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.ARB_create_context_robustness = GLFW_TRUE;
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_ARB_create_context_profile"))
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.ARB_create_context_profile = GLFW_TRUE;
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_EXT_create_context_es2_profile"))
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.EXT_create_context_es2_profile = GLFW_TRUE;
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2017-06-08 15:23:04 +02:00
|
|
|
if (extensionSupportedGLX("GLX_ARB_create_context_no_error"))
|
|
|
|
_glfw.glx.ARB_create_context_no_error = GLFW_TRUE;
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
if (extensionSupportedGLX("GLX_ARB_context_flush_control"))
|
2015-08-23 19:30:04 +02:00
|
|
|
_glfw.glx.ARB_context_flush_control = GLFW_TRUE;
|
2014-08-21 19:21:45 +02:00
|
|
|
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_TRUE;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
|
2013-01-15 20:00:27 +01:00
|
|
|
// Terminate GLX
|
2013-02-04 13:22:10 +01:00
|
|
|
//
|
2015-12-03 18:16:46 +01:00
|
|
|
void _glfwTerminateGLX(void)
|
2012-12-30 18:13:04 +01:00
|
|
|
{
|
2015-12-13 14:07:27 +01:00
|
|
|
// NOTE: This function must not call any X11 functions, as it is called
|
|
|
|
// after XCloseDisplay (see _glfwPlatformTerminate for details)
|
2015-08-13 00:21:33 +02:00
|
|
|
|
2015-05-27 01:06:36 +02:00
|
|
|
if (_glfw.glx.handle)
|
2012-12-30 18:13:04 +01:00
|
|
|
{
|
2015-05-27 01:06:36 +02:00
|
|
|
dlclose(_glfw.glx.handle);
|
|
|
|
_glfw.glx.handle = NULL;
|
2012-12-30 18:13:04 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-08 15:52:55 +02:00
|
|
|
#define setAttrib(a, v) \
|
2013-01-15 20:00:27 +01:00
|
|
|
{ \
|
2017-06-08 15:52:55 +02:00
|
|
|
assert((size_t) (index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
|
|
|
|
attribs[index++] = a; \
|
|
|
|
attribs[index++] = v; \
|
2013-01-15 20:00:27 +01:00
|
|
|
}
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2014-08-20 20:12:59 +02:00
|
|
|
// Create the OpenGL or OpenGL ES context
|
2013-02-04 13:22:10 +01:00
|
|
|
//
|
2015-12-10 17:10:05 +01:00
|
|
|
GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
|
|
|
|
const _GLFWctxconfig* ctxconfig,
|
|
|
|
const _GLFWfbconfig* fbconfig)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
|
|
|
int attribs[40];
|
2015-08-12 18:02:02 +02:00
|
|
|
GLXFBConfig native = NULL;
|
2012-04-23 12:48:57 +02:00
|
|
|
GLXContext share = NULL;
|
|
|
|
|
2014-03-06 20:05:32 +01:00
|
|
|
if (ctxconfig->share)
|
2015-11-09 16:48:55 +01:00
|
|
|
share = ctxconfig->share->context.glx.handle;
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2017-09-19 18:27:45 +02:00
|
|
|
if (!chooseGLXFBConfig(fbconfig, &native, fbconfig->transparent))
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2015-09-16 16:24:21 +02:00
|
|
|
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
2013-05-13 15:49:59 +02:00
|
|
|
"GLX: Failed to find a suitable GLXFBConfig");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
|
2016-03-28 13:19:31 +02:00
|
|
|
if (ctxconfig->client == GLFW_OPENGL_ES_API)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2013-01-02 01:40:42 +01:00
|
|
|
if (!_glfw.glx.ARB_create_context ||
|
|
|
|
!_glfw.glx.ARB_create_context_profile ||
|
|
|
|
!_glfw.glx.EXT_create_context_es2_profile)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2013-08-21 11:56:48 +02:00
|
|
|
_glfwInputError(GLFW_API_UNAVAILABLE,
|
2015-03-10 19:51:14 +01:00
|
|
|
"GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
2012-12-13 20:43:15 +01:00
|
|
|
}
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2014-03-06 20:05:32 +01:00
|
|
|
if (ctxconfig->forward)
|
2012-12-13 20:43:15 +01:00
|
|
|
{
|
2013-01-02 01:40:42 +01:00
|
|
|
if (!_glfw.glx.ARB_create_context)
|
2012-07-22 01:10:59 +02:00
|
|
|
{
|
2012-12-31 21:05:28 +01:00
|
|
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
2015-03-10 19:51:14 +01:00
|
|
|
"GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2012-07-22 01:10:59 +02:00
|
|
|
}
|
2012-12-13 20:43:15 +01:00
|
|
|
}
|
2012-07-22 01:10:59 +02:00
|
|
|
|
2014-03-06 20:05:32 +01:00
|
|
|
if (ctxconfig->profile)
|
2012-12-13 20:43:15 +01:00
|
|
|
{
|
2013-01-02 01:40:42 +01:00
|
|
|
if (!_glfw.glx.ARB_create_context ||
|
|
|
|
!_glfw.glx.ARB_create_context_profile)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2012-12-31 21:05:28 +01:00
|
|
|
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
|
2015-03-10 19:51:14 +01:00
|
|
|
"GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2012-12-13 20:43:15 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-12-03 18:16:46 +01:00
|
|
|
_glfwGrabErrorHandlerX11();
|
2013-01-21 20:19:20 +01:00
|
|
|
|
2013-01-02 01:40:42 +01:00
|
|
|
if (_glfw.glx.ARB_create_context)
|
2012-12-13 20:43:15 +01:00
|
|
|
{
|
2015-04-10 13:18:26 +02:00
|
|
|
int index = 0, mask = 0, flags = 0;
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2016-03-28 13:19:31 +02:00
|
|
|
if (ctxconfig->client == GLFW_OPENGL_API)
|
2012-12-13 20:43:15 +01:00
|
|
|
{
|
2014-03-06 20:05:32 +01:00
|
|
|
if (ctxconfig->forward)
|
2012-04-23 12:48:57 +02:00
|
|
|
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
|
|
|
|
|
2015-04-10 13:18:26 +02:00
|
|
|
if (ctxconfig->profile == GLFW_OPENGL_CORE_PROFILE)
|
|
|
|
mask |= GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
|
|
|
|
else if (ctxconfig->profile == GLFW_OPENGL_COMPAT_PROFILE)
|
|
|
|
mask |= GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
2012-12-13 20:43:15 +01:00
|
|
|
else
|
|
|
|
mask |= GLX_CONTEXT_ES2_PROFILE_BIT_EXT;
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2015-02-27 02:53:21 +01:00
|
|
|
if (ctxconfig->debug)
|
|
|
|
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
|
|
|
|
|
2014-08-20 20:12:59 +02:00
|
|
|
if (ctxconfig->robustness)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2013-01-02 01:40:42 +01:00
|
|
|
if (_glfw.glx.ARB_create_context_robustness)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2014-03-06 20:05:32 +01:00
|
|
|
if (ctxconfig->robustness == GLFW_NO_RESET_NOTIFICATION)
|
2015-04-10 13:18:26 +02:00
|
|
|
{
|
2017-06-08 15:52:55 +02:00
|
|
|
setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
|
|
|
GLX_NO_RESET_NOTIFICATION_ARB);
|
2015-04-10 13:18:26 +02:00
|
|
|
}
|
2014-03-06 20:05:32 +01:00
|
|
|
else if (ctxconfig->robustness == GLFW_LOSE_CONTEXT_ON_RESET)
|
2015-04-10 13:18:26 +02:00
|
|
|
{
|
2017-06-08 15:52:55 +02:00
|
|
|
setAttrib(GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB,
|
|
|
|
GLX_LOSE_CONTEXT_ON_RESET_ARB);
|
2015-04-10 13:18:26 +02:00
|
|
|
}
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2012-12-13 20:43:15 +01:00
|
|
|
flags |= GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB;
|
|
|
|
}
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
|
2014-08-21 19:21:45 +02:00
|
|
|
if (ctxconfig->release)
|
|
|
|
{
|
|
|
|
if (_glfw.glx.ARB_context_flush_control)
|
|
|
|
{
|
|
|
|
if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_NONE)
|
|
|
|
{
|
2017-06-08 15:52:55 +02:00
|
|
|
setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
|
|
|
GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB);
|
2014-08-21 19:21:45 +02:00
|
|
|
}
|
|
|
|
else if (ctxconfig->release == GLFW_RELEASE_BEHAVIOR_FLUSH)
|
|
|
|
{
|
2017-06-08 15:52:55 +02:00
|
|
|
setAttrib(GLX_CONTEXT_RELEASE_BEHAVIOR_ARB,
|
|
|
|
GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB);
|
2014-08-21 19:21:45 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-06-08 15:23:04 +02:00
|
|
|
if (ctxconfig->noerror)
|
|
|
|
{
|
|
|
|
if (_glfw.glx.ARB_create_context_no_error)
|
2017-06-08 15:52:55 +02:00
|
|
|
setAttrib(GLX_CONTEXT_OPENGL_NO_ERROR_ARB, GLFW_TRUE);
|
2017-06-08 15:23:04 +02:00
|
|
|
}
|
|
|
|
|
2015-04-07 02:51:45 +02:00
|
|
|
// NOTE: Only request an explicitly versioned context when necessary, as
|
|
|
|
// explicitly requesting version 1.0 does not always return the
|
|
|
|
// highest version supported by the driver
|
2014-03-06 20:05:32 +01:00
|
|
|
if (ctxconfig->major != 1 || ctxconfig->minor != 0)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2017-06-08 15:52:55 +02:00
|
|
|
setAttrib(GLX_CONTEXT_MAJOR_VERSION_ARB, ctxconfig->major);
|
|
|
|
setAttrib(GLX_CONTEXT_MINOR_VERSION_ARB, ctxconfig->minor);
|
2012-12-13 20:43:15 +01:00
|
|
|
}
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2012-12-13 20:43:15 +01:00
|
|
|
if (mask)
|
2017-06-08 15:52:55 +02:00
|
|
|
setAttrib(GLX_CONTEXT_PROFILE_MASK_ARB, mask);
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2012-12-13 20:43:15 +01:00
|
|
|
if (flags)
|
2017-06-08 15:52:55 +02:00
|
|
|
setAttrib(GLX_CONTEXT_FLAGS_ARB, flags);
|
2012-12-13 20:43:15 +01:00
|
|
|
|
2017-06-08 15:52:55 +02:00
|
|
|
setAttrib(None, None);
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2015-11-09 16:48:55 +01:00
|
|
|
window->context.glx.handle =
|
2013-01-02 01:40:42 +01:00
|
|
|
_glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
|
2013-05-13 15:49:59 +02:00
|
|
|
native,
|
2013-01-02 01:40:42 +01:00
|
|
|
share,
|
|
|
|
True,
|
|
|
|
attribs);
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2015-04-07 02:51:45 +02:00
|
|
|
// HACK: This is a fallback for broken versions of the Mesa
|
|
|
|
// implementation of GLX_ARB_create_context_profile that fail
|
|
|
|
// default 1.0 context creation with a GLXBadProfileARB error in
|
|
|
|
// violation of the extension spec
|
2015-11-09 16:48:55 +01:00
|
|
|
if (!window->context.glx.handle)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2013-07-11 01:23:26 +02:00
|
|
|
if (_glfw.x11.errorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
|
2016-03-28 13:19:31 +02:00
|
|
|
ctxconfig->client == GLFW_OPENGL_API &&
|
2014-03-06 20:05:32 +01:00
|
|
|
ctxconfig->profile == GLFW_OPENGL_ANY_PROFILE &&
|
2015-08-23 19:30:04 +02:00
|
|
|
ctxconfig->forward == GLFW_FALSE)
|
2012-12-30 18:13:04 +01:00
|
|
|
{
|
2015-11-09 16:48:55 +01:00
|
|
|
window->context.glx.handle =
|
2016-06-14 12:27:19 +02:00
|
|
|
createLegacyContextGLX(window, native, share);
|
2012-12-30 18:13:04 +01:00
|
|
|
}
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
}
|
2012-12-30 18:13:04 +01:00
|
|
|
else
|
2016-06-14 12:27:19 +02:00
|
|
|
{
|
|
|
|
window->context.glx.handle =
|
|
|
|
createLegacyContextGLX(window, native, share);
|
|
|
|
}
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2015-12-03 18:16:46 +01:00
|
|
|
_glfwReleaseErrorHandlerX11();
|
2013-01-21 20:19:20 +01:00
|
|
|
|
2015-11-09 16:48:55 +01:00
|
|
|
if (!window->context.glx.handle)
|
2012-04-23 12:48:57 +02:00
|
|
|
{
|
2015-12-03 18:16:46 +01:00
|
|
|
_glfwInputErrorX11(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_FALSE;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
|
2015-12-03 04:09:26 +01:00
|
|
|
window->context.glx.window =
|
|
|
|
glXCreateWindow(_glfw.x11.display, native, window->x11.handle, NULL);
|
2015-11-09 16:48:55 +01:00
|
|
|
if (!window->context.glx.window)
|
2015-10-15 20:10:24 +02:00
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create window");
|
|
|
|
return GLFW_FALSE;
|
|
|
|
}
|
|
|
|
|
2016-06-14 12:27:19 +02:00
|
|
|
window->context.makeCurrent = makeContextCurrentGLX;
|
|
|
|
window->context.swapBuffers = swapBuffersGLX;
|
|
|
|
window->context.swapInterval = swapIntervalGLX;
|
|
|
|
window->context.extensionSupported = extensionSupportedGLX;
|
|
|
|
window->context.getProcAddress = getProcAddressGLX;
|
|
|
|
window->context.destroy = destroyContextGLX;
|
2016-03-28 13:19:31 +02:00
|
|
|
|
2015-08-23 19:30:04 +02:00
|
|
|
return GLFW_TRUE;
|
2012-04-23 12:48:57 +02:00
|
|
|
}
|
|
|
|
|
2017-06-08 15:52:55 +02:00
|
|
|
#undef setAttrib
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2015-06-18 14:03:02 +02:00
|
|
|
// Returns the Visual and depth of the chosen GLXFBConfig
|
|
|
|
//
|
2016-02-22 18:08:15 +01:00
|
|
|
GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
|
|
|
|
const _GLFWctxconfig* ctxconfig,
|
2015-12-03 18:16:46 +01:00
|
|
|
const _GLFWfbconfig* fbconfig,
|
|
|
|
Visual** visual, int* depth)
|
2015-06-18 14:03:02 +02:00
|
|
|
{
|
|
|
|
GLXFBConfig native;
|
|
|
|
XVisualInfo* result;
|
|
|
|
|
2017-09-19 18:27:45 +02:00
|
|
|
if (!chooseGLXFBConfig(fbconfig, &native, fbconfig->transparent))
|
2015-06-18 14:03:02 +02:00
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
|
|
|
|
"GLX: Failed to find a suitable GLXFBConfig");
|
|
|
|
return GLFW_FALSE;
|
|
|
|
}
|
|
|
|
|
2015-12-03 04:09:26 +01:00
|
|
|
result = glXGetVisualFromFBConfig(_glfw.x11.display, native);
|
2015-06-18 14:03:02 +02:00
|
|
|
if (!result)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_PLATFORM_ERROR,
|
|
|
|
"GLX: Failed to retrieve Visual for GLXFBConfig");
|
|
|
|
return GLFW_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
*visual = result->visual;
|
2016-02-22 18:08:15 +01:00
|
|
|
*depth = result->depth;
|
2015-06-18 14:03:02 +02:00
|
|
|
|
|
|
|
XFree(result);
|
|
|
|
return GLFW_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-04-23 12:48:57 +02:00
|
|
|
|
2013-01-15 22:38:14 +01:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
////// GLFW native API //////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow* handle)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-02-20 00:28:08 +01:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2015-06-18 14:03:02 +02:00
|
|
|
|
2016-03-28 13:19:31 +02:00
|
|
|
if (window->context.client == GLFW_NO_API)
|
2015-06-18 14:03:02 +02:00
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2015-11-09 16:48:55 +01:00
|
|
|
return window->context.glx.handle;
|
2013-01-15 22:38:14 +01:00
|
|
|
}
|
|
|
|
|
2015-11-09 23:32:35 +01:00
|
|
|
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow* handle)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(None);
|
|
|
|
|
2016-03-28 13:19:31 +02:00
|
|
|
if (window->context.client == GLFW_NO_API)
|
2015-11-09 23:32:35 +01:00
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
|
|
|
return None;
|
|
|
|
}
|
|
|
|
|
|
|
|
return window->context.glx.window;
|
|
|
|
}
|
|
|
|
|