platform.h (6421B)
1 //======================================================================== 2 // GLFW 3.4 - www.glfw.org 3 //------------------------------------------------------------------------ 4 // Copyright (c) 2002-2006 Marcus Geelnard 5 // Copyright (c) 2006-2018 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 28 #if defined(GLFW_BUILD_WIN32_TIMER) || \ 29 defined(GLFW_BUILD_WIN32_MODULE) || \ 30 defined(GLFW_BUILD_WIN32_THREAD) || \ 31 defined(GLFW_BUILD_COCOA_TIMER) || \ 32 defined(GLFW_BUILD_POSIX_TIMER) || \ 33 defined(GLFW_BUILD_POSIX_MODULE) || \ 34 defined(GLFW_BUILD_POSIX_THREAD) || \ 35 defined(GLFW_BUILD_POSIX_POLL) || \ 36 defined(GLFW_BUILD_LINUX_JOYSTICK) 37 #error "You must not define these; define zero or more _GLFW_<platform> macros instead" 38 #endif 39 40 #include "null_platform.h" 41 #define GLFW_EXPOSE_NATIVE_EGL 42 #define GLFW_EXPOSE_NATIVE_OSMESA 43 44 #if defined(_GLFW_WIN32) 45 #include "win32_platform.h" 46 #define GLFW_EXPOSE_NATIVE_WIN32 47 #define GLFW_EXPOSE_NATIVE_WGL 48 #else 49 #define GLFW_WIN32_WINDOW_STATE 50 #define GLFW_WIN32_MONITOR_STATE 51 #define GLFW_WIN32_CURSOR_STATE 52 #define GLFW_WIN32_LIBRARY_WINDOW_STATE 53 #define GLFW_WGL_CONTEXT_STATE 54 #define GLFW_WGL_LIBRARY_CONTEXT_STATE 55 #endif 56 57 #if defined(_GLFW_COCOA) 58 #include "cocoa_platform.h" 59 #define GLFW_EXPOSE_NATIVE_COCOA 60 #define GLFW_EXPOSE_NATIVE_NSGL 61 #else 62 #define GLFW_COCOA_WINDOW_STATE 63 #define GLFW_COCOA_MONITOR_STATE 64 #define GLFW_COCOA_CURSOR_STATE 65 #define GLFW_COCOA_LIBRARY_WINDOW_STATE 66 #define GLFW_NSGL_CONTEXT_STATE 67 #define GLFW_NSGL_LIBRARY_CONTEXT_STATE 68 #endif 69 70 #if defined(_GLFW_WAYLAND) 71 #include "wl_platform.h" 72 #define GLFW_EXPOSE_NATIVE_WAYLAND 73 #else 74 #define GLFW_WAYLAND_WINDOW_STATE 75 #define GLFW_WAYLAND_MONITOR_STATE 76 #define GLFW_WAYLAND_CURSOR_STATE 77 #define GLFW_WAYLAND_LIBRARY_WINDOW_STATE 78 #endif 79 80 #if defined(_GLFW_X11) 81 #include "x11_platform.h" 82 #define GLFW_EXPOSE_NATIVE_X11 83 #define GLFW_EXPOSE_NATIVE_GLX 84 #else 85 #define GLFW_X11_WINDOW_STATE 86 #define GLFW_X11_MONITOR_STATE 87 #define GLFW_X11_CURSOR_STATE 88 #define GLFW_X11_LIBRARY_WINDOW_STATE 89 #define GLFW_GLX_CONTEXT_STATE 90 #define GLFW_GLX_LIBRARY_CONTEXT_STATE 91 #endif 92 93 #include "null_joystick.h" 94 95 #if defined(_GLFW_WIN32) 96 #include "win32_joystick.h" 97 #else 98 #define GLFW_WIN32_JOYSTICK_STATE 99 #define GLFW_WIN32_LIBRARY_JOYSTICK_STATE 100 #endif 101 102 #if defined(_GLFW_COCOA) 103 #include "cocoa_joystick.h" 104 #else 105 #define GLFW_COCOA_JOYSTICK_STATE 106 #define GLFW_COCOA_LIBRARY_JOYSTICK_STATE 107 #endif 108 109 #if (defined(_GLFW_X11) || defined(_GLFW_WAYLAND)) && defined(__linux__) 110 #define GLFW_BUILD_LINUX_JOYSTICK 111 #endif 112 113 #if defined(GLFW_BUILD_LINUX_JOYSTICK) 114 #include "linux_joystick.h" 115 #else 116 #define GLFW_LINUX_JOYSTICK_STATE 117 #define GLFW_LINUX_LIBRARY_JOYSTICK_STATE 118 #endif 119 120 #define GLFW_PLATFORM_WINDOW_STATE \ 121 GLFW_WIN32_WINDOW_STATE \ 122 GLFW_COCOA_WINDOW_STATE \ 123 GLFW_WAYLAND_WINDOW_STATE \ 124 GLFW_X11_WINDOW_STATE \ 125 GLFW_NULL_WINDOW_STATE \ 126 127 #define GLFW_PLATFORM_MONITOR_STATE \ 128 GLFW_WIN32_MONITOR_STATE \ 129 GLFW_COCOA_MONITOR_STATE \ 130 GLFW_WAYLAND_MONITOR_STATE \ 131 GLFW_X11_MONITOR_STATE \ 132 GLFW_NULL_MONITOR_STATE \ 133 134 #define GLFW_PLATFORM_CURSOR_STATE \ 135 GLFW_WIN32_CURSOR_STATE \ 136 GLFW_COCOA_CURSOR_STATE \ 137 GLFW_WAYLAND_CURSOR_STATE \ 138 GLFW_X11_CURSOR_STATE \ 139 GLFW_NULL_CURSOR_STATE \ 140 141 #define GLFW_PLATFORM_JOYSTICK_STATE \ 142 GLFW_WIN32_JOYSTICK_STATE \ 143 GLFW_COCOA_JOYSTICK_STATE \ 144 GLFW_LINUX_JOYSTICK_STATE 145 146 #define GLFW_PLATFORM_LIBRARY_WINDOW_STATE \ 147 GLFW_WIN32_LIBRARY_WINDOW_STATE \ 148 GLFW_COCOA_LIBRARY_WINDOW_STATE \ 149 GLFW_WAYLAND_LIBRARY_WINDOW_STATE \ 150 GLFW_X11_LIBRARY_WINDOW_STATE \ 151 GLFW_NULL_LIBRARY_WINDOW_STATE \ 152 153 #define GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \ 154 GLFW_WIN32_LIBRARY_JOYSTICK_STATE \ 155 GLFW_COCOA_LIBRARY_JOYSTICK_STATE \ 156 GLFW_LINUX_LIBRARY_JOYSTICK_STATE 157 158 #define GLFW_PLATFORM_CONTEXT_STATE \ 159 GLFW_WGL_CONTEXT_STATE \ 160 GLFW_NSGL_CONTEXT_STATE \ 161 GLFW_GLX_CONTEXT_STATE 162 163 #define GLFW_PLATFORM_LIBRARY_CONTEXT_STATE \ 164 GLFW_WGL_LIBRARY_CONTEXT_STATE \ 165 GLFW_NSGL_LIBRARY_CONTEXT_STATE \ 166 GLFW_GLX_LIBRARY_CONTEXT_STATE 167 168 #if defined(_WIN32) 169 #define GLFW_BUILD_WIN32_THREAD 170 #else 171 #define GLFW_BUILD_POSIX_THREAD 172 #endif 173 174 #if defined(GLFW_BUILD_WIN32_THREAD) 175 #include "win32_thread.h" 176 #define GLFW_PLATFORM_TLS_STATE GLFW_WIN32_TLS_STATE 177 #define GLFW_PLATFORM_MUTEX_STATE GLFW_WIN32_MUTEX_STATE 178 #elif defined(GLFW_BUILD_POSIX_THREAD) 179 #include "posix_thread.h" 180 #define GLFW_PLATFORM_TLS_STATE GLFW_POSIX_TLS_STATE 181 #define GLFW_PLATFORM_MUTEX_STATE GLFW_POSIX_MUTEX_STATE 182 #endif 183 184 #if defined(_WIN32) 185 #define GLFW_BUILD_WIN32_TIMER 186 #elif defined(__APPLE__) 187 #define GLFW_BUILD_COCOA_TIMER 188 #else 189 #define GLFW_BUILD_POSIX_TIMER 190 #endif 191 192 #if defined(GLFW_BUILD_WIN32_TIMER) 193 #include "win32_time.h" 194 #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_WIN32_LIBRARY_TIMER_STATE 195 #elif defined(GLFW_BUILD_COCOA_TIMER) 196 #include "cocoa_time.h" 197 #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_COCOA_LIBRARY_TIMER_STATE 198 #elif defined(GLFW_BUILD_POSIX_TIMER) 199 #include "posix_time.h" 200 #define GLFW_PLATFORM_LIBRARY_TIMER_STATE GLFW_POSIX_LIBRARY_TIMER_STATE 201 #endif 202 203 #if defined(_WIN32) 204 #define GLFW_BUILD_WIN32_MODULE 205 #else 206 #define GLFW_BUILD_POSIX_MODULE 207 #endif 208 209 #if defined(_GLFW_WAYLAND) || defined(_GLFW_X11) 210 #define GLFW_BUILD_POSIX_POLL 211 #endif 212