glx_context.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. //========================================================================
  2. // GLFW 3.4 GLX - www.glfw.org
  3. //------------------------------------------------------------------------
  4. // Copyright (c) 2002-2006 Marcus Geelnard
  5. // Copyright (c) 2006-2017 Camilla Löwy <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. #define GLX_VENDOR 1
  28. #define GLX_RGBA_BIT 0x00000001
  29. #define GLX_WINDOW_BIT 0x00000001
  30. #define GLX_DRAWABLE_TYPE 0x8010
  31. #define GLX_RENDER_TYPE 0x8011
  32. #define GLX_RGBA_TYPE 0x8014
  33. #define GLX_DOUBLEBUFFER 5
  34. #define GLX_STEREO 6
  35. #define GLX_AUX_BUFFERS 7
  36. #define GLX_RED_SIZE 8
  37. #define GLX_GREEN_SIZE 9
  38. #define GLX_BLUE_SIZE 10
  39. #define GLX_ALPHA_SIZE 11
  40. #define GLX_DEPTH_SIZE 12
  41. #define GLX_STENCIL_SIZE 13
  42. #define GLX_ACCUM_RED_SIZE 14
  43. #define GLX_ACCUM_GREEN_SIZE 15
  44. #define GLX_ACCUM_BLUE_SIZE 16
  45. #define GLX_ACCUM_ALPHA_SIZE 17
  46. #define GLX_SAMPLES 0x186a1
  47. #define GLX_VISUAL_ID 0x800b
  48. #define GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB 0x20b2
  49. #define GLX_CONTEXT_DEBUG_BIT_ARB 0x00000001
  50. #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
  51. #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB 0x00000001
  52. #define GLX_CONTEXT_PROFILE_MASK_ARB 0x9126
  53. #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
  54. #define GLX_CONTEXT_MAJOR_VERSION_ARB 0x2091
  55. #define GLX_CONTEXT_MINOR_VERSION_ARB 0x2092
  56. #define GLX_CONTEXT_FLAGS_ARB 0x2094
  57. #define GLX_CONTEXT_ES2_PROFILE_BIT_EXT 0x00000004
  58. #define GLX_CONTEXT_ROBUST_ACCESS_BIT_ARB 0x00000004
  59. #define GLX_LOSE_CONTEXT_ON_RESET_ARB 0x8252
  60. #define GLX_CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB 0x8256
  61. #define GLX_NO_RESET_NOTIFICATION_ARB 0x8261
  62. #define GLX_CONTEXT_RELEASE_BEHAVIOR_ARB 0x2097
  63. #define GLX_CONTEXT_RELEASE_BEHAVIOR_NONE_ARB 0
  64. #define GLX_CONTEXT_RELEASE_BEHAVIOR_FLUSH_ARB 0x2098
  65. #define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31b3
  66. typedef XID GLXWindow;
  67. typedef XID GLXDrawable;
  68. typedef struct __GLXFBConfig* GLXFBConfig;
  69. typedef struct __GLXcontext* GLXContext;
  70. typedef void (*__GLXextproc)(void);
  71. typedef int (*PFNGLXGETFBCONFIGATTRIBPROC)(Display*,GLXFBConfig,int,int*);
  72. typedef GLXFBConfig* (*PFNGLXCHOOSEFBCONFIGPROC)(Display*,int,const int*,int*);
  73. typedef const char* (*PFNGLXGETCLIENTSTRINGPROC)(Display*,int);
  74. typedef Bool (*PFNGLXQUERYEXTENSIONPROC)(Display*,int*,int*);
  75. typedef Bool (*PFNGLXQUERYVERSIONPROC)(Display*,int*,int*);
  76. typedef void (*PFNGLXDESTROYCONTEXTPROC)(Display*,GLXContext);
  77. typedef Bool (*PFNGLXMAKECURRENTPROC)(Display*,GLXDrawable,GLXContext);
  78. typedef void (*PFNGLXSWAPBUFFERSPROC)(Display*,GLXDrawable);
  79. typedef const char* (*PFNGLXQUERYEXTENSIONSSTRINGPROC)(Display*,int);
  80. typedef GLXFBConfig* (*PFNGLXGETFBCONFIGSPROC)(Display*,int,int*);
  81. typedef GLXContext (*PFNGLXCREATENEWCONTEXTPROC)(Display*,GLXFBConfig,int,GLXContext,Bool);
  82. typedef __GLXextproc (* PFNGLXGETPROCADDRESSPROC)(const GLubyte *procName);
  83. typedef void (*PFNGLXSWAPINTERVALEXTPROC)(Display*,GLXDrawable,int);
  84. typedef XVisualInfo* (*PFNGLXGETVISUALFROMFBCONFIGPROC)(Display*,GLXFBConfig);
  85. typedef GLXWindow (*PFNGLXCREATEWINDOWPROC)(Display*,GLXFBConfig,Window,const int*);
  86. typedef void (*PFNGLXDESTROYWINDOWPROC)(Display*,GLXWindow);
  87. typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
  88. typedef int (*PFNGLXSWAPINTERVALSGIPROC)(int);
  89. typedef GLXContext (*PFNGLXCREATECONTEXTATTRIBSARBPROC)(Display*,GLXFBConfig,GLXContext,Bool,const int*);
  90. // libGL.so function pointer typedefs
  91. #define glXGetFBConfigs _glfw.glx.GetFBConfigs
  92. #define glXGetFBConfigAttrib _glfw.glx.GetFBConfigAttrib
  93. #define glXChooseFBConfig _glfw.glx.ChooseFBConfig
  94. #define glXGetClientString _glfw.glx.GetClientString
  95. #define glXQueryExtension _glfw.glx.QueryExtension
  96. #define glXQueryVersion _glfw.glx.QueryVersion
  97. #define glXDestroyContext _glfw.glx.DestroyContext
  98. #define glXMakeCurrent _glfw.glx.MakeCurrent
  99. #define glXSwapBuffers _glfw.glx.SwapBuffers
  100. #define glXQueryExtensionsString _glfw.glx.QueryExtensionsString
  101. #define glXCreateNewContext _glfw.glx.CreateNewContext
  102. #define glXGetVisualFromFBConfig _glfw.glx.GetVisualFromFBConfig
  103. #define glXCreateWindow _glfw.glx.CreateWindow
  104. #define glXDestroyWindow _glfw.glx.DestroyWindow
  105. #define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx;
  106. #define _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE _GLFWlibraryGLX glx;
  107. // GLX-specific per-context data
  108. //
  109. typedef struct _GLFWcontextGLX
  110. {
  111. GLXContext handle;
  112. GLXWindow window;
  113. } _GLFWcontextGLX;
  114. // GLX-specific global data
  115. //
  116. typedef struct _GLFWlibraryGLX
  117. {
  118. int major, minor;
  119. int eventBase;
  120. int errorBase;
  121. // dlopen handle for libGL.so.1
  122. void* handle;
  123. // GLX 1.3 functions
  124. PFNGLXGETFBCONFIGSPROC GetFBConfigs;
  125. PFNGLXGETFBCONFIGATTRIBPROC GetFBConfigAttrib;
  126. PFNGLXCHOOSEFBCONFIGPROC ChooseFBConfig;
  127. PFNGLXGETCLIENTSTRINGPROC GetClientString;
  128. PFNGLXQUERYEXTENSIONPROC QueryExtension;
  129. PFNGLXQUERYVERSIONPROC QueryVersion;
  130. PFNGLXDESTROYCONTEXTPROC DestroyContext;
  131. PFNGLXMAKECURRENTPROC MakeCurrent;
  132. PFNGLXSWAPBUFFERSPROC SwapBuffers;
  133. PFNGLXQUERYEXTENSIONSSTRINGPROC QueryExtensionsString;
  134. PFNGLXCREATENEWCONTEXTPROC CreateNewContext;
  135. PFNGLXGETVISUALFROMFBCONFIGPROC GetVisualFromFBConfig;
  136. PFNGLXCREATEWINDOWPROC CreateWindow;
  137. PFNGLXDESTROYWINDOWPROC DestroyWindow;
  138. // GLX 1.4 and extension functions
  139. PFNGLXGETPROCADDRESSPROC GetProcAddress;
  140. PFNGLXGETPROCADDRESSPROC GetProcAddressARB;
  141. PFNGLXSWAPINTERVALSGIPROC SwapIntervalSGI;
  142. PFNGLXSWAPINTERVALEXTPROC SwapIntervalEXT;
  143. PFNGLXSWAPINTERVALMESAPROC SwapIntervalMESA;
  144. PFNGLXCREATECONTEXTATTRIBSARBPROC CreateContextAttribsARB;
  145. bool SGI_swap_control;
  146. bool EXT_swap_control;
  147. bool MESA_swap_control;
  148. bool ARB_multisample;
  149. bool ARB_framebuffer_sRGB;
  150. bool EXT_framebuffer_sRGB;
  151. bool ARB_create_context;
  152. bool ARB_create_context_profile;
  153. bool ARB_create_context_robustness;
  154. bool EXT_create_context_es2_profile;
  155. bool ARB_create_context_no_error;
  156. bool ARB_context_flush_control;
  157. } _GLFWlibraryGLX;
  158. bool _glfwInitGLX(void);
  159. void _glfwTerminateGLX(void);
  160. bool _glfwCreateContextGLX(_GLFWwindow* window,
  161. const _GLFWctxconfig* ctxconfig,
  162. const _GLFWfbconfig* fbconfig);
  163. void _glfwDestroyContextGLX(_GLFWwindow* window);
  164. bool _glfwChooseVisualGLX(const _GLFWwndconfig* wndconfig,
  165. const _GLFWctxconfig* ctxconfig,
  166. const _GLFWfbconfig* fbconfig,
  167. Visual** visual, int* depth);