1 //========================================================================
2 // GLFW 3.0 GLX - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2002-2006 Marcus Geelnard
5 // Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.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 _glx_platform_h_
29 #define _glx_platform_h_
30 
31 #include <pthread.h>
32 
33 #define GLX_GLXEXT_LEGACY
34 #include <GL/glx.h>
35 
36 // This path may need to be changed if you build GLFW using your own setup
37 // We ship and use our own copy of glxext.h since GLFW uses fairly new
38 // extensions and not all operating systems come with an up-to-date version
39 #include "../deps/GL/glxext.h"
40 
41 // Do we have support for dlopen/dlsym?
42 #if defined(_GLFW_HAS_DLOPEN)
43  #include <dlfcn.h>
44 #endif
45 
46 // We support four different ways for getting addresses for GL/GLX
47 // extension functions: glXGetProcAddress, glXGetProcAddressARB,
48 // glXGetProcAddressEXT, and dlsym
49 #if defined(_GLFW_HAS_GLXGETPROCADDRESSARB)
50  #define _glfw_glXGetProcAddress(x) glXGetProcAddressARB(x)
51 #elif defined(_GLFW_HAS_GLXGETPROCADDRESS)
52  #define _glfw_glXGetProcAddress(x) glXGetProcAddress(x)
53 #elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT)
54  #define _glfw_glXGetProcAddress(x) glXGetProcAddressEXT(x)
55 #elif defined(_GLFW_HAS_DLOPEN)
56  #define _glfw_glXGetProcAddress(x) dlsym(_glfw.glx.libGL, x)
57  #define _GLFW_DLOPEN_LIBGL
58 #else
59  #error "No OpenGL entry point retrieval mechanism was enabled"
60 #endif
61 
62 #define _GLFW_PLATFORM_FBCONFIG             GLXFBConfig     glx
63 #define _GLFW_PLATFORM_CONTEXT_STATE        _GLFWcontextGLX glx
64 #define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryGLX glx
65 
66 #ifndef GLX_MESA_swap_control
67 typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
68 #endif
69 
70 
71 //========================================================================
72 // GLFW platform specific types
73 //========================================================================
74 
75 //------------------------------------------------------------------------
76 // Platform-specific OpenGL context structure
77 //------------------------------------------------------------------------
78 typedef struct _GLFWcontextGLX
79 {
80     GLXContext      context; // OpenGL rendering context
81     XVisualInfo*    visual;  // Visual for selected GLXFBConfig
82 
83 } _GLFWcontextGLX;
84 
85 
86 //------------------------------------------------------------------------
87 // Platform-specific library global data for GLX
88 //------------------------------------------------------------------------
89 typedef struct _GLFWlibraryGLX
90 {
91     // Server-side GLX version
92     int             versionMajor, versionMinor;
93     int             eventBase;
94     int             errorBase;
95 
96     // TLS key for per-thread current context/window
97     pthread_key_t   current;
98 
99     // GLX extensions
100     PFNGLXSWAPINTERVALSGIPROC             SwapIntervalSGI;
101     PFNGLXSWAPINTERVALEXTPROC             SwapIntervalEXT;
102     PFNGLXSWAPINTERVALMESAPROC            SwapIntervalMESA;
103     PFNGLXGETFBCONFIGATTRIBSGIXPROC       GetFBConfigAttribSGIX;
104     PFNGLXCHOOSEFBCONFIGSGIXPROC          ChooseFBConfigSGIX;
105     PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC CreateContextWithConfigSGIX;
106     PFNGLXGETVISUALFROMFBCONFIGSGIXPROC   GetVisualFromFBConfigSGIX;
107     PFNGLXCREATECONTEXTATTRIBSARBPROC     CreateContextAttribsARB;
108     GLboolean       SGIX_fbconfig;
109     GLboolean       SGI_swap_control;
110     GLboolean       EXT_swap_control;
111     GLboolean       MESA_swap_control;
112     GLboolean       ARB_multisample;
113     GLboolean       ARB_framebuffer_sRGB;
114     GLboolean       ARB_create_context;
115     GLboolean       ARB_create_context_profile;
116     GLboolean       ARB_create_context_robustness;
117     GLboolean       EXT_create_context_es2_profile;
118 
119 #if defined(_GLFW_DLOPEN_LIBGL)
120     void*           libGL;  // dlopen handle for libGL.so
121 #endif
122 } _GLFWlibraryGLX;
123 
124 
125 #endif // _glx_platform_h_
126