36#ifndef GLXBadProfileARB
37 #define GLXBadProfileARB 13
43static int getGLXFBConfigAttrib(
GLXFBConfig fbconfig,
int attrib)
58 int i, nativeCount, usableCount;
65 if (vendor && strcmp(vendor,
"Chromium") == 0)
70 if (!nativeConfigs || !nativeCount)
79 for (i = 0; i < nativeCount; i++)
126 if (
_glfw.glx.ARB_multisample)
129 if (
_glfw.glx.ARB_framebuffer_sRGB ||
_glfw.glx.EXT_framebuffer_sRGB)
140 XFree(nativeConfigs);
143 return closest !=
NULL;
159static void makeContextCurrentGLX(
_GLFWwindow* window)
168 "GLX: Failed to make context current");
177 "GLX: Failed to clear current context");
190static void swapIntervalGLX(
int interval)
194 if (
_glfw.glx.EXT_swap_control)
200 else if (
_glfw.glx.MESA_swap_control)
201 _glfw.glx.SwapIntervalMESA(interval);
202 else if (
_glfw.glx.SGI_swap_control)
205 _glfw.glx.SwapIntervalSGI(interval);
209static int extensionSupportedGLX(
const char* extension)
211 const char* extensions =
222static GLFWglproc getProcAddressGLX(
const char* procname)
224 if (
_glfw.glx.GetProcAddress)
225 return _glfw.glx.GetProcAddress((
const GLubyte*) procname);
226 else if (
_glfw.glx.GetProcAddressARB)
227 return _glfw.glx.GetProcAddressARB((
const GLubyte*) procname);
234 if (window->
context.glx.window)
237 window->
context.glx.window = None;
240 if (window->
context.glx.handle)
257 const char* sonames[] =
259#if defined(_GLFW_GLX_LIBRARY)
261#elif defined(__CYGWIN__)
273 for (i = 0; sonames[i]; i++)
286 _glfw.glx.GetFBConfigs =
288 _glfw.glx.GetFBConfigAttrib =
290 _glfw.glx.GetClientString =
292 _glfw.glx.QueryExtension =
294 _glfw.glx.QueryVersion =
296 _glfw.glx.DestroyContext =
298 _glfw.glx.MakeCurrent =
300 _glfw.glx.SwapBuffers =
302 _glfw.glx.QueryExtensionsString =
304 _glfw.glx.CreateNewContext =
306 _glfw.glx.CreateWindow =
308 _glfw.glx.DestroyWindow =
310 _glfw.glx.GetProcAddress =
312 _glfw.glx.GetProcAddressARB =
314 _glfw.glx.GetVisualFromFBConfig =
317 if (!
_glfw.glx.GetFBConfigs ||
318 !
_glfw.glx.GetFBConfigAttrib ||
319 !
_glfw.glx.GetClientString ||
320 !
_glfw.glx.QueryExtension ||
321 !
_glfw.glx.QueryVersion ||
322 !
_glfw.glx.DestroyContext ||
323 !
_glfw.glx.MakeCurrent ||
324 !
_glfw.glx.SwapBuffers ||
325 !
_glfw.glx.QueryExtensionsString ||
326 !
_glfw.glx.CreateNewContext ||
327 !
_glfw.glx.CreateWindow ||
328 !
_glfw.glx.DestroyWindow ||
329 !
_glfw.glx.GetProcAddress ||
330 !
_glfw.glx.GetProcAddressARB ||
331 !
_glfw.glx.GetVisualFromFBConfig)
334 "GLX: Failed to load required entry points");
339 &
_glfw.glx.errorBase,
340 &
_glfw.glx.eventBase))
349 "GLX: Failed to query GLX version");
353 if (
_glfw.glx.major == 1 &&
_glfw.glx.minor < 3)
356 "GLX: GLX version 1.3 is required");
360 if (extensionSupportedGLX(
"GLX_EXT_swap_control"))
363 getProcAddressGLX(
"glXSwapIntervalEXT");
365 if (
_glfw.glx.SwapIntervalEXT)
369 if (extensionSupportedGLX(
"GLX_SGI_swap_control"))
372 getProcAddressGLX(
"glXSwapIntervalSGI");
374 if (
_glfw.glx.SwapIntervalSGI)
378 if (extensionSupportedGLX(
"GLX_MESA_swap_control"))
381 getProcAddressGLX(
"glXSwapIntervalMESA");
383 if (
_glfw.glx.SwapIntervalMESA)
387 if (extensionSupportedGLX(
"GLX_ARB_multisample"))
390 if (extensionSupportedGLX(
"GLX_ARB_framebuffer_sRGB"))
393 if (extensionSupportedGLX(
"GLX_EXT_framebuffer_sRGB"))
396 if (extensionSupportedGLX(
"GLX_ARB_create_context"))
399 getProcAddressGLX(
"glXCreateContextAttribsARB");
401 if (
_glfw.glx.CreateContextAttribsARB)
405 if (extensionSupportedGLX(
"GLX_ARB_create_context_robustness"))
408 if (extensionSupportedGLX(
"GLX_ARB_create_context_profile"))
411 if (extensionSupportedGLX(
"GLX_EXT_create_context_es2_profile"))
414 if (extensionSupportedGLX(
"GLX_ARB_create_context_no_error"))
417 if (extensionSupportedGLX(
"GLX_ARB_context_flush_control"))
437#define setAttrib(a, v) \
439 assert(((size_t) index + 1) < sizeof(attribs) / sizeof(attribs[0])); \
440 attribs[index++] = a; \
441 attribs[index++] = v; \
454 if (ctxconfig->
share)
457 if (!chooseGLXFBConfig(fbconfig, &native))
460 "GLX: Failed to find a suitable GLXFBConfig");
466 if (!
_glfw.glx.ARB_create_context ||
467 !
_glfw.glx.ARB_create_context_profile ||
468 !
_glfw.glx.EXT_create_context_es2_profile)
471 "GLX: OpenGL ES requested but GLX_EXT_create_context_es2_profile is unavailable");
478 if (!
_glfw.glx.ARB_create_context)
481 "GLX: Forward compatibility requested but GLX_ARB_create_context_profile is unavailable");
488 if (!
_glfw.glx.ARB_create_context ||
489 !
_glfw.glx.ARB_create_context_profile)
492 "GLX: An OpenGL profile requested but GLX_ARB_create_context_profile is unavailable");
499 if (
_glfw.glx.ARB_create_context)
501 int index = 0, mask = 0, flags = 0;
516 if (ctxconfig->
debug)
521 if (
_glfw.glx.ARB_create_context_robustness)
540 if (
_glfw.glx.ARB_context_flush_control)
557 if (
_glfw.glx.ARB_create_context_no_error)
564 if (ctxconfig->
major != 1 || ctxconfig->
minor != 0)
579 _glfw.glx.CreateContextAttribsARB(
_glfw.x11.display,
589 if (!window->
context.glx.handle)
597 createLegacyContextGLX(window, native, share);
604 createLegacyContextGLX(window, native, share);
609 if (!window->
context.glx.handle)
617 if (!window->
context.glx.window)
640 Visual** visual,
int* depth)
645 if (!chooseGLXFBConfig(fbconfig, &native))
648 "GLX: Failed to find a suitable GLXFBConfig");
656 "GLX: Failed to retrieve Visual for GLXFBConfig");
660 *visual = result->visual;
661 *depth = result->depth;
683 return window->
context.glx.handle;
697 return window->
context.glx.window;
GLFWbool _glfwStringInExtensionString(const char *string, const char *extensions)
const _GLFWfbconfig * _glfwChooseFBConfig(const _GLFWfbconfig *desired, const _GLFWfbconfig *alternatives, unsigned int count)
#define GLFW_OPENGL_ES_API
#define GLFW_RELEASE_BEHAVIOR_FLUSH
#define GLFW_OPENGL_COMPAT_PROFILE
#define GLFW_OPENGL_ANY_PROFILE
#define GLFW_LOSE_CONTEXT_ON_RESET
#define GLFW_NO_RESET_NOTIFICATION
#define GLFW_OPENGL_CORE_PROFILE
#define GLFW_RELEASE_BEHAVIOR_NONE
GLFWbool _glfwCreateContextGLX(_GLFWwindow *window, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig)
void _glfwTerminateGLX(void)
GLFWbool _glfwChooseVisualGLX(const _GLFWwndconfig *wndconfig, const _GLFWctxconfig *ctxconfig, const _GLFWfbconfig *fbconfig, Visual **visual, int *depth)
GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow *handle)
GLFWAPI GLXWindow glfwGetGLXWindow(GLFWwindow *handle)
GLFWbool _glfwInitGLX(void)
#define GLX_NO_RESET_NOTIFICATION_ARB
#define GLX_CONTEXT_DEBUG_BIT_ARB
#define GLX_DRAWABLE_TYPE
GLXContext(* PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display *, GLXFBConfig, GLXContext, Bool, const int *)
#define glXGetClientString
#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB
#define GLX_ACCUM_BLUE_SIZE
struct __GLXcontext * GLXContext
#define GLX_CONTEXT_MINOR_VERSION_ARB
#define glXQueryExtension
#define GLX_CONTEXT_OPENGL_NO_ERROR_ARB
#define GLX_ACCUM_ALPHA_SIZE
#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB
#define glXGetVisualFromFBConfig
struct __GLXFBConfig * GLXFBConfig
#define GLX_CONTEXT_FLAGS_ARB
#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB
int(* PFNGLXSWAPINTERVALMESAPROC)(int)
#define glXCreateNewContext
#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB
#define GLX_CONTEXT_PROFILE_MASK_ARB
int(* PFNGLXSWAPINTERVALSGIPROC)(int)
void(* PFNGLXSWAPINTERVALEXTPROC)(Display *, GLXDrawable, int)
#define GLX_ACCUM_GREEN_SIZE
#define GLX_CONTEXT_MAJOR_VERSION_ARB
#define glXQueryExtensionsString
#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB
#define GLX_ACCUM_RED_SIZE
#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB
#define glXGetFBConfigAttrib
#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT
#define glXDestroyContext
#define GLX_LOSE_CONTEXT_ON_RESET_ARB
#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB
#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB
void(* GLFWglproc)(void)
GLFW API types.
#define GLFW_FORMAT_UNAVAILABLE
The requested format is not supported or available.
#define GLFW_API_UNAVAILABLE
GLFW could not find support for the requested API on the system.
#define GLFW_NO_WINDOW_CONTEXT
The specified window does not have an OpenGL or OpenGL ES context.
#define GLFW_VERSION_UNAVAILABLE
The requested OpenGL or OpenGL ES version is not available.
#define GLFW_PLATFORM_ERROR
A platform-specific error occurred that does not match any of the more specific categories.
struct GLFWwindow GLFWwindow
Opaque window object.
void _glfwInputError(int code, const char *format,...)
void _glfwPlatformSetTls(_GLFWtls *tls, void *value)
#define _GLFW_REQUIRE_INIT_OR_RETURN(x)
void * _glfwPlatformGetTls(_GLFWtls *tls)
_W64 unsigned int uintptr_t
_GLFWswapintervalfun swapInterval
_GLFWswapbuffersfun swapBuffers
_GLFWdestroycontextfun destroy
_GLFWmakecontextcurrentfun makeCurrent
_GLFWextensionsupportedfun extensionSupported
_GLFWgetprocaddressfun getProcAddress
void _glfwInputErrorX11(int error, const char *message)
void _glfwReleaseErrorHandlerX11(void)
void _glfwGrabErrorHandlerX11(void)