1//========================================================================
2// GLFW 3.2 GLX - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2016 Camilla Berglund <elmindreda@glfw.org>
6//
7// This software is provided 'as-is', without any express or implied
8// warranty. In no event will the authors be held liable for any damages
9// arising from the use of this software.
10//
11// Permission is granted to anyone to use this software for any purpose,
12// including commercial applications, and to alter it and redistribute it
13// freely, subject to the following restrictions:
14//
15// 1. The origin of this software must not be misrepresented; you must not
16// claim that you wrote the original software. If you use this software
17// in a product, an acknowledgment in the product documentation would
18// be appreciated but is not required.
19//
20// 2. Altered source versions must be plainly marked as such, and must not
21// be misrepresented as being the original software.
22//
23// 3. This notice may not be removed or altered from any source
24// distribution.
25//
26//========================================================================
27
28#ifndef _glfw3_glx_context_h_
29#define _glfw3_glx_context_h_
30
31#define GLX_VENDOR 1
32#define GLX_RGBA_BIT 0x00000001
33#define GLX_WINDOW_BIT 0x00000001
34#define GLX_DRAWABLE_TYPE 0x8010
35#define GLX_RENDER_TYPE 0x8011
36#define GLX_RGBA_TYPE 0x8014
37#define GLX_DOUBLEBUFFER 5
38#define GLX_STEREO 6
39#define GLX_AUX_BUFFERS 7
40#define GLX_RED_SIZE 8
41#define GLX_GREEN_SIZE 9
42#define GLX_BLUE_SIZE 10
43#define GLX_ALPHA_SIZE 11
44#define GLX_DEPTH_SIZE 12
45#define GLX_STENCIL_SIZE 13
46#define GLX_ACCUM_RED_SIZE 14
47#define GLX_ACCUM_GREEN_SIZE 15
48#define GLX_ACCUM_BLUE_SIZE 16
49#define GLX_ACCUM_ALPHA_SIZE 17
50#define GLX_SAMPLES 0x186a1
51#define GLX_VISUAL_ID 0x800b
52
53#define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
54#define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
55#define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
56#define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
57#define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
58#define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
59#define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
60#define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
61#define GLX_CONTEXT_FLAGS_ARB 0x2094
62#define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
63#define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
64#define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252
65#define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
66#define GLX_NO_RESET_NOTIFICATION_ARB 0x8261
67#define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
68#define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
69#define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
70
71typedef XID GLXWindow;
72typedef XID GLXDrawable;
73typedef struct __GLXFBConfig* GLXFBConfig;
74typedef struct __GLXcontext* GLXContext;
75typedef void (*__GLXextproc)(void);
76
77typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);
78typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);
79typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);
80typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);
81typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext);
82typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext);
83typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);
84typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);
85typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*);
86typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool);
87typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC) (const GLubyte *procName);
88typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
89typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
90typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
91typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*);
92typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
93typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*);
94typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
95
96// libGL.so function pointer typedefs
97#define glXGetFBConfigs _glfw.glx.GetFBConfigs
98#define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
99#define glXGetClientString _glfw.glx.GetClientString
100#define glXQueryExtension _glfw.glx.QueryExtension
101#define glXQueryVersion _glfw.glx.QueryVersion
102#define glXDestroyContext _glfw.glx.DestroyContext
103#define glXMakeCurrent _glfw.glx.MakeCurrent
104#define glXSwapBuffers _glfw.glx.SwapBuffers
105#define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
106#define glXCreateNewContext _glfw.glx.CreateNewContext
107#define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
108#define glXCreateWindow _glfw.glx.CreateWindow
109#define glXDestroyWindow _glfw.glx.DestroyWindow
110
111#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
112#define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx
113
114
115// GLX-specific per-context data
116//
117typedef struct _GLFWcontextGLX
118{
119 GLXContext handle;
120 GLXWindow window;
121
122} _GLFWcontextGLX;
123
124
125// GLX-specific global data
126//
127typedef struct _GLFWlibraryGLX
128{
129 int major, minor;
130 int eventBase;
131 int errorBase;
132
133 // dlopen handle for libGL.so.1
134 void* handle;
135
136 // GLX 1.3 functions
137 PFNGLXGETFBCONFIGSPROC GetFBConfigs;
138 PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib;
139 PFNGLXGETCLIENTSTRINGPROC GetClientString;
140 PFNGLXQUERYEXTENSIONPROC QueryExtension;
141 PFNGLXQUERYVERSIONPROC QueryVersion;
142 PFNGLXDESTROYCONTEXTPROC DestroyContext;
143 PFNGLXMAKECURRENTPROC MakeCurrent;
144 PFNGLXSWAPBUFFERSPROC SwapBuffers;
145 PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString;
146 PFNGLXCREATENEWCONTEXTPROC CreateNewContext;
147 PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig;
148 PFNGLXCREATEWINDOWPROC CreateWindow;
149 PFNGLXDESTROYWINDOWPROC DestroyWindow;
150
151 // GLX 1.4 and extension functions
152 PFNGLXGETPROCADDRESSPROC GetProcAddress;
153 PFNGLXGETPROCADDRESSPROC GetProcAddressARB;
154 PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
155 PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
156 PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
157 PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
158 GLFWbool SGI_swap_control;
159 GLFWbool EXT_swap_control;
160 GLFWbool MESA_swap_control;
161 GLFWbool ARB_multisample;
162 GLFWbool ARB_framebuffer_sRGB;
163 GLFWbool EXT_framebuffer_sRGB;
164 GLFWbool ARB_create_context;
165 GLFWbool ARB_create_context_profile;
166 GLFWbool ARB_create_context_robustness;
167 GLFWbool EXT_create_context_es2_profile;
168 GLFWbool ARB_context_flush_control;
169
170} _GLFWlibraryGLX;
171
172
173GLFWbool _glfwInitGLX(void);
174void _glfwTerminateGLX(void);
175GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
176 const _GLFWctxconfig* ctxconfig,
177 const _GLFWfbconfig* fbconfig);
178void _glfwDestroyContextGLX(_GLFWwindow* window);
179GLFWbool _glfwChooseVisualGLX(const _GLFWctxconfig* ctxconfig,
180 const _GLFWfbconfig* fbconfig,
181 Visual** visual, int* depth);
182
183#endif // _glfw3_glx_context_h_
184