1 //======================================================================== 2 // GLFW 3.5 - www.glfw.org 3 //------------------------------------------------------------------------ 4 // Copyright (c) 2002-2006 Marcus Geelnard 5 // Copyright (c) 2006-2019 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 #pragma once 29 30 #if defined(_GLFW_USE_CONFIG_H) 31 #include "glfw_config.h" 32 #endif 33 34 #if defined(GLFW_INCLUDE_GLCOREARB) || \ 35 defined(GLFW_INCLUDE_ES1) || \ 36 defined(GLFW_INCLUDE_ES2) || \ 37 defined(GLFW_INCLUDE_ES3) || \ 38 defined(GLFW_INCLUDE_ES31) || \ 39 defined(GLFW_INCLUDE_ES32) || \ 40 defined(GLFW_INCLUDE_NONE) || \ 41 defined(GLFW_INCLUDE_GLEXT) || \ 42 defined(GLFW_INCLUDE_GLU) || \ 43 defined(GLFW_INCLUDE_VULKAN) || \ 44 defined(GLFW_DLL) 45 #error "You must not define any header option macros when compiling GLFW" 46 #endif 47 48 #define GLFW_INCLUDE_NONE 49 #include "../include/GLFW/glfw3.h" 50 51 #include <stdbool.h> 52 53 #define _GLFW_INSERT_FIRST 0 54 #define _GLFW_INSERT_LAST 1 55 56 #define _GLFW_POLL_PRESENCE 0 57 #define _GLFW_POLL_AXES 1 58 #define _GLFW_POLL_BUTTONS 2 59 #define _GLFW_POLL_ALL (_GLFW_POLL_AXES | _GLFW_POLL_BUTTONS) 60 61 #define _GLFW_MESSAGE_SIZE 1024 62 63 typedef int GLFWbool; 64 typedef void (*GLFWproc)(void); 65 66 typedef struct _GLFWerror _GLFWerror; 67 typedef struct _GLFWinitconfig _GLFWinitconfig; 68 typedef struct _GLFWwndconfig _GLFWwndconfig; 69 typedef struct _GLFWctxconfig _GLFWctxconfig; 70 typedef struct _GLFWfbconfig _GLFWfbconfig; 71 typedef struct _GLFWcontext _GLFWcontext; 72 typedef struct _GLFWwindow _GLFWwindow; 73 typedef struct _GLFWplatform _GLFWplatform; 74 typedef struct _GLFWlibrary _GLFWlibrary; 75 typedef struct _GLFWmonitor _GLFWmonitor; 76 typedef struct _GLFWcursor _GLFWcursor; 77 typedef struct _GLFWmapelement _GLFWmapelement; 78 typedef struct _GLFWmapping _GLFWmapping; 79 typedef struct _GLFWjoystick _GLFWjoystick; 80 typedef struct _GLFWtls _GLFWtls; 81 typedef struct _GLFWmutex _GLFWmutex; 82 83 #define GL_VERSION 0x1f02 84 #define GL_NONE 0 85 #define GL_COLOR_BUFFER_BIT 0x00004000 86 #define GL_UNSIGNED_BYTE 0x1401 87 #define GL_EXTENSIONS 0x1f03 88 #define GL_NUM_EXTENSIONS 0x821d 89 #define GL_CONTEXT_FLAGS 0x821e 90 #define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 91 #define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 92 #define GL_CONTEXT_PROFILE_MASK 0x9126 93 #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 94 #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 95 #define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 96 #define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 97 #define GL_NO_RESET_NOTIFICATION_ARB 0x8261 98 #define GL_CONTEXT_RELEASE_BEHAVIOR 0x82fb 99 #define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc 100 #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 101 102 typedef int GLint; 103 typedef unsigned int GLuint; 104 typedef unsigned int GLenum; 105 typedef unsigned int GLbitfield; 106 typedef unsigned char GLubyte; 107 108 typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield); 109 typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum); 110 typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*); 111 typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); 112 113 #define EGL_SUCCESS 0x3000 114 #define EGL_NOT_INITIALIZED 0x3001 115 #define EGL_BAD_ACCESS 0x3002 116 #define EGL_BAD_ALLOC 0x3003 117 #define EGL_BAD_ATTRIBUTE 0x3004 118 #define EGL_BAD_CONFIG 0x3005 119 #define EGL_BAD_CONTEXT 0x3006 120 #define EGL_BAD_CURRENT_SURFACE 0x3007 121 #define EGL_BAD_DISPLAY 0x3008 122 #define EGL_BAD_MATCH 0x3009 123 #define EGL_BAD_NATIVE_PIXMAP 0x300a 124 #define EGL_BAD_NATIVE_WINDOW 0x300b 125 #define EGL_BAD_PARAMETER 0x300c 126 #define EGL_BAD_SURFACE 0x300d 127 #define EGL_CONTEXT_LOST 0x300e 128 #define EGL_COLOR_BUFFER_TYPE 0x303f 129 #define EGL_RGB_BUFFER 0x308e 130 #define EGL_SURFACE_TYPE 0x3033 131 #define EGL_WINDOW_BIT 0x0004 132 #define EGL_RENDERABLE_TYPE 0x3040 133 #define EGL_OPENGL_ES_BIT 0x0001 134 #define EGL_OPENGL_ES2_BIT 0x0004 135 #define EGL_OPENGL_BIT 0x0008 136 #define EGL_ALPHA_SIZE 0x3021 137 #define EGL_BLUE_SIZE 0x3022 138 #define EGL_GREEN_SIZE 0x3023 139 #define EGL_RED_SIZE 0x3024 140 #define EGL_DEPTH_SIZE 0x3025 141 #define EGL_STENCIL_SIZE 0x3026 142 #define EGL_SAMPLES 0x3031 143 #define EGL_OPENGL_ES_API 0x30a0 144 #define EGL_OPENGL_API 0x30a2 145 #define EGL_NONE 0x3038 146 #define EGL_RENDER_BUFFER 0x3086 147 #define EGL_SINGLE_BUFFER 0x3085 148 #define EGL_EXTENSIONS 0x3055 149 #define EGL_CONTEXT_CLIENT_VERSION 0x3098 150 #define EGL_NATIVE_VISUAL_ID 0x302e 151 #define EGL_NO_SURFACE ((EGLSurface) 0) 152 #define EGL_NO_DISPLAY ((EGLDisplay) 0) 153 #define EGL_NO_CONTEXT ((EGLContext) 0) 154 #define EGL_DEFAULT_DISPLAY ((EGLNativeDisplayType) 0) 155 #define EGL_PBUFFER_BIT 0x0001 156 #define EGL_WIDTH 0x3057 157 #define EGL_HEIGHT 0x3056 158 159 #define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 160 #define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 161 #define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 162 #define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 163 #define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31bd 164 #define EGL_NO_RESET_NOTIFICATION_KHR 0x31be 165 #define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31bf 166 #define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 167 #define EGL_CONTEXT_MAJOR_VERSION_KHR 0x3098 168 #define EGL_CONTEXT_MINOR_VERSION_KHR 0x30fb 169 #define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30fd 170 #define EGL_CONTEXT_FLAGS_KHR 0x30fc 171 #define EGL_CONTEXT_OPENGL_NO_ERROR_KHR 0x31b3 172 #define EGL_GL_COLORSPACE_KHR 0x309d 173 #define EGL_GL_COLORSPACE_SRGB_KHR 0x3089 174 #define EGL_CONTEXT_RELEASE_BEHAVIOR_KHR 0x2097 175 #define EGL_CONTEXT_RELEASE_BEHAVIOR_NONE_KHR 0 176 #define EGL_CONTEXT_RELEASE_BEHAVIOR_FLUSH_KHR 0x2098 177 #define EGL_PLATFORM_X11_EXT 0x31d5 178 #define EGL_PLATFORM_WAYLAND_EXT 0x31d8 179 #define EGL_PRESENT_OPAQUE_EXT 0x31df 180 #define EGL_PLATFORM_ANGLE_ANGLE 0x3202 181 #define EGL_PLATFORM_ANGLE_TYPE_ANGLE 0x3203 182 #define EGL_PLATFORM_ANGLE_TYPE_OPENGL_ANGLE 0x320d 183 #define EGL_PLATFORM_ANGLE_TYPE_OPENGLES_ANGLE 0x320e 184 #define EGL_PLATFORM_ANGLE_TYPE_D3D9_ANGLE 0x3207 185 #define EGL_PLATFORM_ANGLE_TYPE_D3D11_ANGLE 0x3208 186 #define EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE 0x3450 187 #define EGL_PLATFORM_ANGLE_TYPE_METAL_ANGLE 0x3489 188 #define EGL_PLATFORM_ANGLE_NATIVE_PLATFORM_TYPE_ANGLE 0x348f 189 #define EGL_PLATFORM_SURFACELESS_MESA 0x31dd 190 191 typedef int EGLint; 192 typedef unsigned int EGLBoolean; 193 typedef unsigned int EGLenum; 194 typedef void* EGLConfig; 195 typedef void* EGLContext; 196 typedef void* EGLDisplay; 197 typedef void* EGLSurface; 198 199 typedef void* EGLNativeDisplayType; 200 typedef void* EGLNativeWindowType; 201 202 // EGL function pointer typedefs 203 typedef EGLBoolean (APIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*); 204 typedef EGLBoolean (APIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*); 205 typedef EGLDisplay (APIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType); 206 typedef EGLint (APIENTRY * PFN_eglGetError)(void); 207 typedef EGLBoolean (APIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*); 208 typedef EGLBoolean (APIENTRY * PFN_eglTerminate)(EGLDisplay); 209 typedef EGLBoolean (APIENTRY * PFN_eglBindAPI)(EGLenum); 210 typedef EGLContext (APIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*); 211 typedef EGLBoolean (APIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface); 212 typedef EGLBoolean (APIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext); 213 typedef EGLSurface (APIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*); 214 typedef EGLSurface (APIENTRY * PFN_eglCreatePbufferSurface)(EGLDisplay,EGLContext,const EGLint*); 215 typedef EGLBoolean (APIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext); 216 typedef EGLBoolean (APIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface); 217 typedef EGLBoolean (APIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint); 218 typedef const char* (APIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint); 219 typedef GLFWglproc (APIENTRY * PFN_eglGetProcAddress)(const char*); 220 #define eglGetConfigAttrib _glfw.egl.GetConfigAttrib 221 #define eglGetConfigs _glfw.egl.GetConfigs 222 #define eglGetDisplay _glfw.egl.GetDisplay 223 #define eglGetError _glfw.egl.GetError 224 #define eglInitialize _glfw.egl.Initialize 225 #define eglTerminate _glfw.egl.Terminate 226 #define eglBindAPI _glfw.egl.BindAPI 227 #define eglCreateContext _glfw.egl.CreateContext 228 #define eglDestroySurface _glfw.egl.DestroySurface 229 #define eglDestroyContext _glfw.egl.DestroyContext 230 #define eglCreateWindowSurface _glfw.egl.CreateWindowSurface 231 #define eglCreatePbufferSurface _glfw.egl.CreatePbufferSurface 232 #define eglMakeCurrent _glfw.egl.MakeCurrent 233 #define eglSwapBuffers _glfw.egl.SwapBuffers 234 #define eglSwapInterval _glfw.egl.SwapInterval 235 #define eglQueryString _glfw.egl.QueryString 236 #define eglGetProcAddress _glfw.egl.GetProcAddress 237 238 typedef EGLDisplay (APIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*); 239 typedef EGLSurface (APIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*); 240 #define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT 241 #define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT 242 243 #define OSMESA_RGBA 0x1908 244 #define OSMESA_FORMAT 0x22 245 #define OSMESA_DEPTH_BITS 0x30 246 #define OSMESA_STENCIL_BITS 0x31 247 #define OSMESA_ACCUM_BITS 0x32 248 #define OSMESA_PROFILE 0x33 249 #define OSMESA_CORE_PROFILE 0x34 250 #define OSMESA_COMPAT_PROFILE 0x35 251 #define OSMESA_CONTEXT_MAJOR_VERSION 0x36 252 #define OSMESA_CONTEXT_MINOR_VERSION 0x37 253 254 typedef void* OSMesaContext; 255 typedef void (*OSMESAproc)(void); 256 257 typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext); 258 typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext); 259 typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext); 260 typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int); 261 typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**); 262 typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**); 263 typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*); 264 #define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt 265 #define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs 266 #define OSMesaDestroyContext _glfw.osmesa.DestroyContext 267 #define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent 268 #define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer 269 #define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer 270 #define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress 271 272 #define VK_NULL_HANDLE 0 273 274 typedef void* VkInstance; 275 typedef void* VkPhysicalDevice; 276 typedef uint64_t VkSurfaceKHR; 277 typedef uint32_t VkFlags; 278 typedef uint32_t VkBool32; 279 280 typedef enum VkStructureType 281 { 282 VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, 283 VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000, 284 VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, 285 VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, 286 VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000, 287 VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000, 288 VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT = 1000256000, 289 VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF 290 } VkStructureType; 291 292 typedef enum VkResult 293 { 294 VK_SUCCESS = 0, 295 VK_NOT_READY = 1, 296 VK_TIMEOUT = 2, 297 VK_EVENT_SET = 3, 298 VK_EVENT_RESET = 4, 299 VK_INCOMPLETE = 5, 300 VK_ERROR_OUT_OF_HOST_MEMORY = -1, 301 VK_ERROR_OUT_OF_DEVICE_MEMORY = -2, 302 VK_ERROR_INITIALIZATION_FAILED = -3, 303 VK_ERROR_DEVICE_LOST = -4, 304 VK_ERROR_MEMORY_MAP_FAILED = -5, 305 VK_ERROR_LAYER_NOT_PRESENT = -6, 306 VK_ERROR_EXTENSION_NOT_PRESENT = -7, 307 VK_ERROR_FEATURE_NOT_PRESENT = -8, 308 VK_ERROR_INCOMPATIBLE_DRIVER = -9, 309 VK_ERROR_TOO_MANY_OBJECTS = -10, 310 VK_ERROR_FORMAT_NOT_SUPPORTED = -11, 311 VK_ERROR_SURFACE_LOST_KHR = -1000000000, 312 VK_SUBOPTIMAL_KHR = 1000001003, 313 VK_ERROR_OUT_OF_DATE_KHR = -1000001004, 314 VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, 315 VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, 316 VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, 317 VK_RESULT_MAX_ENUM = 0x7FFFFFFF 318 } VkResult; 319 320 typedef struct VkAllocationCallbacks VkAllocationCallbacks; 321 322 typedef struct VkExtensionProperties 323 { 324 char extensionName[256]; 325 uint32_t specVersion; 326 } VkExtensionProperties; 327 328 typedef void (APIENTRY * PFN_vkVoidFunction)(void); 329 330 typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*); 331 typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*); 332 #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr 333 334 #include "platform.h" 335 336 #define GLFW_NATIVE_INCLUDE_NONE 337 #include "../include/GLFW/glfw3native.h" 338 339 // Checks for whether the library has been initialized 340 #define _GLFW_REQUIRE_INIT() \ 341 if (!_glfw.initialized) \ 342 { \ 343 _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ 344 return; \ 345 } 346 #define _GLFW_REQUIRE_INIT_OR_RETURN(x) \ 347 if (!_glfw.initialized) \ 348 { \ 349 _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ 350 return x; \ 351 } 352 353 // Swaps the provided pointers 354 #define _GLFW_SWAP(type, x, y) \ 355 { \ 356 type t; \ 357 t = x; \ 358 x = y; \ 359 y = t; \ 360 } 361 362 // Per-thread error structure 363 // 364 struct _GLFWerror 365 { 366 _GLFWerror* next; 367 int code; 368 char description[_GLFW_MESSAGE_SIZE]; 369 }; 370 371 // Initialization configuration 372 // 373 // Parameters relating to the initialization of the library 374 // 375 struct _GLFWinitconfig 376 { 377 GLFWbool hatButtons; 378 int angleType; 379 int platformID; 380 PFN_vkGetInstanceProcAddr vulkanLoader; 381 struct { 382 GLFWbool menubar; 383 GLFWbool chdir; 384 } ns; 385 struct { 386 GLFWbool xcbVulkanSurface; 387 } x11; 388 struct { 389 int libdecorMode; 390 } wl; 391 }; 392 393 // Window configuration 394 // 395 // Parameters relating to the creation of the window but not directly related 396 // to the framebuffer. This is used to pass window creation parameters from 397 // shared code to the platform API. 398 // 399 struct _GLFWwndconfig 400 { 401 int xpos; 402 int ypos; 403 int width; 404 int height; 405 const char* title; 406 GLFWbool resizable; 407 GLFWbool visible; 408 GLFWbool decorated; 409 GLFWbool focused; 410 GLFWbool autoIconify; 411 GLFWbool floating; 412 GLFWbool maximized; 413 GLFWbool centerCursor; 414 GLFWbool focusOnShow; 415 GLFWbool mousePassthrough; 416 GLFWbool scaleToMonitor; 417 GLFWbool scaleFramebuffer; 418 struct { 419 char frameName[256]; 420 } ns; 421 struct { 422 char className[256]; 423 char instanceName[256]; 424 } x11; 425 struct { 426 GLFWbool keymenu; 427 GLFWbool showDefault; 428 } win32; 429 struct { 430 char appId[256]; 431 } wl; 432 }; 433 434 // Context configuration 435 // 436 // Parameters relating to the creation of the context but not directly related 437 // to the framebuffer. This is used to pass context creation parameters from 438 // shared code to the platform API. 439 // 440 struct _GLFWctxconfig 441 { 442 int client; 443 int source; 444 int major; 445 int minor; 446 GLFWbool forward; 447 GLFWbool debug; 448 GLFWbool noerror; 449 int profile; 450 int robustness; 451 int release; 452 _GLFWwindow* share; 453 struct { 454 GLFWbool offline; 455 } nsgl; 456 }; 457 458 // Framebuffer configuration 459 // 460 // This describes buffers and their sizes. It also contains 461 // a platform-specific ID used to map back to the backend API object. 462 // 463 // It is used to pass framebuffer parameters from shared code to the platform 464 // API and also to enumerate and select available framebuffer configs. 465 // 466 struct _GLFWfbconfig 467 { 468 int redBits; 469 int greenBits; 470 int blueBits; 471 int alphaBits; 472 int depthBits; 473 int stencilBits; 474 int accumRedBits; 475 int accumGreenBits; 476 int accumBlueBits; 477 int accumAlphaBits; 478 int auxBuffers; 479 GLFWbool stereo; 480 int samples; 481 GLFWbool sRGB; 482 GLFWbool doublebuffer; 483 GLFWbool transparent; 484 uintptr_t handle; 485 }; 486 487 // Context structure 488 // 489 struct _GLFWcontext 490 { 491 int client; 492 int source; 493 int major, minor, revision; 494 GLFWbool forward, debug, noerror; 495 int profile; 496 int robustness; 497 int release; 498 499 PFNGLGETSTRINGIPROC GetStringi; 500 PFNGLGETINTEGERVPROC GetIntegerv; 501 PFNGLGETSTRINGPROC GetString; 502 503 void (*makeCurrent)(_GLFWwindow*); 504 void (*swapBuffers)(_GLFWwindow*); 505 void (*swapInterval)(int); 506 int (*extensionSupported)(const char*); 507 GLFWglproc (*getProcAddress)(const char*); 508 void (*destroy)(_GLFWwindow*); 509 510 struct { 511 EGLConfig config; 512 EGLContext handle; 513 EGLSurface surface; 514 void* client; 515 } egl; 516 517 struct { 518 OSMesaContext handle; 519 int width; 520 int height; 521 void* buffer; 522 } osmesa; 523 524 // This is defined in platform.h 525 GLFW_PLATFORM_CONTEXT_STATE 526 }; 527 528 // Window and context structure 529 // 530 struct _GLFWwindow 531 { 532 struct _GLFWwindow* next; 533 534 // Window settings and state 535 GLFWbool resizable; 536 GLFWbool decorated; 537 GLFWbool autoIconify; 538 GLFWbool floating; 539 GLFWbool focusOnShow; 540 GLFWbool mousePassthrough; 541 GLFWbool shouldClose; 542 void* userPointer; 543 GLFWbool doublebuffer; 544 GLFWvidmode videoMode; 545 _GLFWmonitor* monitor; 546 _GLFWcursor* cursor; 547 char* title; 548 549 int minwidth, minheight; 550 int maxwidth, maxheight; 551 int numer, denom; 552 553 GLFWbool stickyKeys; 554 GLFWbool stickyMouseButtons; 555 GLFWbool lockKeyMods; 556 GLFWbool disableMouseButtonLimit; 557 int cursorMode; 558 char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1]; 559 char keys[GLFW_KEY_LAST + 1]; 560 // Virtual cursor position when cursor is disabled 561 double virtualCursorPosX, virtualCursorPosY; 562 GLFWbool rawMouseMotion; 563 564 _GLFWcontext context; 565 566 struct { 567 GLFWwindowposfun pos; 568 GLFWwindowsizefun size; 569 GLFWwindowclosefun close; 570 GLFWwindowrefreshfun refresh; 571 GLFWwindowfocusfun focus; 572 GLFWwindowiconifyfun iconify; 573 GLFWwindowmaximizefun maximize; 574 GLFWframebuffersizefun fbsize; 575 GLFWwindowcontentscalefun scale; 576 GLFWmousebuttonfun mouseButton; 577 GLFWcursorposfun cursorPos; 578 GLFWcursorenterfun cursorEnter; 579 GLFWscrollfun scroll; 580 GLFWkeyfun key; 581 GLFWcharfun character; 582 GLFWcharmodsfun charmods; 583 GLFWdropfun drop; 584 } callbacks; 585 586 // This is defined in platform.h 587 GLFW_PLATFORM_WINDOW_STATE 588 }; 589 590 // Monitor structure 591 // 592 struct _GLFWmonitor 593 { 594 char name[128]; 595 void* userPointer; 596 597 // Physical dimensions in millimeters. 598 int widthMM, heightMM; 599 600 // The window whose video mode is current on this monitor 601 _GLFWwindow* window; 602 603 GLFWvidmode* modes; 604 int modeCount; 605 GLFWvidmode currentMode; 606 607 GLFWgammaramp originalRamp; 608 GLFWgammaramp currentRamp; 609 610 // This is defined in platform.h 611 GLFW_PLATFORM_MONITOR_STATE 612 }; 613 614 // Cursor structure 615 // 616 struct _GLFWcursor 617 { 618 _GLFWcursor* next; 619 // This is defined in platform.h 620 GLFW_PLATFORM_CURSOR_STATE 621 }; 622 623 // Gamepad mapping element structure 624 // 625 struct _GLFWmapelement 626 { 627 uint8_t type; 628 uint8_t index; 629 int8_t axisScale; 630 int8_t axisOffset; 631 }; 632 633 // Gamepad mapping structure 634 // 635 struct _GLFWmapping 636 { 637 char name[128]; 638 char guid[33]; 639 _GLFWmapelement buttons[15]; 640 _GLFWmapelement axes[6]; 641 }; 642 643 // Joystick structure 644 // 645 struct _GLFWjoystick 646 { 647 GLFWbool allocated; 648 GLFWbool connected; 649 float* axes; 650 int axisCount; 651 unsigned char* buttons; 652 int buttonCount; 653 unsigned char* hats; 654 int hatCount; 655 char name[128]; 656 void* userPointer; 657 char guid[33]; 658 _GLFWmapping* mapping; 659 660 // This is defined in platform.h 661 GLFW_PLATFORM_JOYSTICK_STATE 662 }; 663 664 // Thread local storage structure 665 // 666 struct _GLFWtls 667 { 668 // This is defined in platform.h 669 GLFW_PLATFORM_TLS_STATE 670 }; 671 672 // Mutex structure 673 // 674 struct _GLFWmutex 675 { 676 // This is defined in platform.h 677 GLFW_PLATFORM_MUTEX_STATE 678 }; 679 680 // Platform API structure 681 // 682 struct _GLFWplatform 683 { 684 int platformID; 685 // init 686 GLFWbool (*init)(void); 687 void (*terminate)(void); 688 // input 689 void (*getCursorPos)(_GLFWwindow*,double*,double*); 690 void (*setCursorPos)(_GLFWwindow*,double,double); 691 void (*setCursorMode)(_GLFWwindow*,int); 692 void (*setRawMouseMotion)(_GLFWwindow*,GLFWbool); 693 GLFWbool (*rawMouseMotionSupported)(void); 694 GLFWbool (*createCursor)(_GLFWcursor*,const GLFWimage*,int,int); 695 GLFWbool (*createStandardCursor)(_GLFWcursor*,int); 696 void (*destroyCursor)(_GLFWcursor*); 697 void (*setCursor)(_GLFWwindow*,_GLFWcursor*); 698 const char* (*getScancodeName)(int); 699 int (*getKeyScancode)(int); 700 void (*setClipboardString)(const char*); 701 const char* (*getClipboardString)(void); 702 GLFWbool (*initJoysticks)(void); 703 void (*terminateJoysticks)(void); 704 GLFWbool (*pollJoystick)(_GLFWjoystick*,int); 705 const char* (*getMappingName)(void); 706 void (*updateGamepadGUID)(char*); 707 // monitor 708 void (*freeMonitor)(_GLFWmonitor*); 709 void (*getMonitorPos)(_GLFWmonitor*,int*,int*); 710 void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*); 711 void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*); 712 GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*); 713 GLFWbool (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*); 714 GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*); 715 void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*); 716 // window 717 GLFWbool (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*); 718 void (*destroyWindow)(_GLFWwindow*); 719 void (*setWindowTitle)(_GLFWwindow*,const char*); 720 void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*); 721 void (*getWindowPos)(_GLFWwindow*,int*,int*); 722 void (*setWindowPos)(_GLFWwindow*,int,int); 723 void (*getWindowSize)(_GLFWwindow*,int*,int*); 724 void (*setWindowSize)(_GLFWwindow*,int,int); 725 void (*setWindowSizeLimits)(_GLFWwindow*,int,int,int,int); 726 void (*setWindowAspectRatio)(_GLFWwindow*,int,int); 727 void (*getFramebufferSize)(_GLFWwindow*,int*,int*); 728 void (*getWindowFrameSize)(_GLFWwindow*,int*,int*,int*,int*); 729 void (*getWindowContentScale)(_GLFWwindow*,float*,float*); 730 void (*iconifyWindow)(_GLFWwindow*); 731 void (*restoreWindow)(_GLFWwindow*); 732 void (*maximizeWindow)(_GLFWwindow*); 733 void (*showWindow)(_GLFWwindow*); 734 void (*hideWindow)(_GLFWwindow*); 735 void (*requestWindowAttention)(_GLFWwindow*); 736 void (*focusWindow)(_GLFWwindow*); 737 void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int); 738 GLFWbool (*windowFocused)(_GLFWwindow*); 739 GLFWbool (*windowIconified)(_GLFWwindow*); 740 GLFWbool (*windowVisible)(_GLFWwindow*); 741 GLFWbool (*windowMaximized)(_GLFWwindow*); 742 GLFWbool (*windowHovered)(_GLFWwindow*); 743 GLFWbool (*framebufferTransparent)(_GLFWwindow*); 744 float (*getWindowOpacity)(_GLFWwindow*); 745 void (*setWindowResizable)(_GLFWwindow*,GLFWbool); 746 void (*setWindowDecorated)(_GLFWwindow*,GLFWbool); 747 void (*setWindowFloating)(_GLFWwindow*,GLFWbool); 748 void (*setWindowOpacity)(_GLFWwindow*,float); 749 void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool); 750 void (*pollEvents)(void); 751 void (*waitEvents)(void); 752 void (*waitEventsTimeout)(double); 753 void (*postEmptyEvent)(void); 754 // EGL 755 EGLenum (*getEGLPlatform)(EGLint**); 756 EGLNativeDisplayType (*getEGLNativeDisplay)(void); 757 EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*); 758 // vulkan 759 void (*getRequiredInstanceExtensions)(char**); 760 GLFWbool (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t); 761 VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*); 762 }; 763 764 // Library global data 765 // 766 struct _GLFWlibrary 767 { 768 GLFWbool initialized; 769 GLFWallocator allocator; 770 771 _GLFWplatform platform; 772 773 struct { 774 _GLFWinitconfig init; 775 _GLFWfbconfig framebuffer; 776 _GLFWwndconfig window; 777 _GLFWctxconfig context; 778 int refreshRate; 779 } hints; 780 781 _GLFWerror* errorListHead; 782 _GLFWcursor* cursorListHead; 783 _GLFWwindow* windowListHead; 784 785 _GLFWmonitor** monitors; 786 int monitorCount; 787 788 GLFWbool joysticksInitialized; 789 _GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1]; 790 _GLFWmapping* mappings; 791 int mappingCount; 792 793 _GLFWtls errorSlot; 794 _GLFWtls contextSlot; 795 _GLFWmutex errorLock; 796 797 struct { 798 uint64_t offset; 799 // This is defined in platform.h 800 GLFW_PLATFORM_LIBRARY_TIMER_STATE 801 } timer; 802 803 struct { 804 EGLenum platform; 805 EGLDisplay display; 806 EGLint major, minor; 807 GLFWbool prefix; 808 809 GLFWbool KHR_create_context; 810 GLFWbool KHR_create_context_no_error; 811 GLFWbool KHR_gl_colorspace; 812 GLFWbool KHR_get_all_proc_addresses; 813 GLFWbool KHR_context_flush_control; 814 GLFWbool EXT_client_extensions; 815 GLFWbool EXT_platform_base; 816 GLFWbool EXT_platform_x11; 817 GLFWbool EXT_platform_wayland; 818 GLFWbool EXT_present_opaque; 819 GLFWbool ANGLE_platform_angle; 820 GLFWbool ANGLE_platform_angle_opengl; 821 GLFWbool ANGLE_platform_angle_d3d; 822 GLFWbool ANGLE_platform_angle_vulkan; 823 GLFWbool ANGLE_platform_angle_metal; 824 GLFWbool MESA_platform_surfaceless; 825 826 void* handle; 827 828 PFN_eglGetConfigAttrib GetConfigAttrib; 829 PFN_eglGetConfigs GetConfigs; 830 PFN_eglGetDisplay GetDisplay; 831 PFN_eglGetError GetError; 832 PFN_eglInitialize Initialize; 833 PFN_eglTerminate Terminate; 834 PFN_eglBindAPI BindAPI; 835 PFN_eglCreateContext CreateContext; 836 PFN_eglDestroySurface DestroySurface; 837 PFN_eglDestroyContext DestroyContext; 838 PFN_eglCreateWindowSurface CreateWindowSurface; 839 PFN_eglCreatePbufferSurface CreatePbufferSurface; 840 PFN_eglMakeCurrent MakeCurrent; 841 PFN_eglSwapBuffers SwapBuffers; 842 PFN_eglSwapInterval SwapInterval; 843 PFN_eglQueryString QueryString; 844 PFN_eglGetProcAddress GetProcAddress; 845 846 PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT; 847 PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT; 848 } egl; 849 850 struct { 851 void* handle; 852 853 PFN_OSMesaCreateContextExt CreateContextExt; 854 PFN_OSMesaCreateContextAttribs CreateContextAttribs; 855 PFN_OSMesaDestroyContext DestroyContext; 856 PFN_OSMesaMakeCurrent MakeCurrent; 857 PFN_OSMesaGetColorBuffer GetColorBuffer; 858 PFN_OSMesaGetDepthBuffer GetDepthBuffer; 859 PFN_OSMesaGetProcAddress GetProcAddress; 860 861 } osmesa; 862 863 struct { 864 GLFWbool available; 865 void* handle; 866 char* extensions[2]; 867 PFN_vkGetInstanceProcAddr GetInstanceProcAddr; 868 GLFWbool KHR_surface; 869 GLFWbool KHR_win32_surface; 870 GLFWbool MVK_macos_surface; 871 GLFWbool EXT_metal_surface; 872 GLFWbool KHR_xlib_surface; 873 GLFWbool KHR_xcb_surface; 874 GLFWbool KHR_wayland_surface; 875 GLFWbool EXT_headless_surface; 876 } vk; 877 878 struct { 879 GLFWmonitorfun monitor; 880 GLFWjoystickfun joystick; 881 } callbacks; 882 883 // These are defined in platform.h 884 GLFW_PLATFORM_LIBRARY_WINDOW_STATE 885 GLFW_PLATFORM_LIBRARY_CONTEXT_STATE 886 GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE 887 }; 888 889 // Global state shared between compilation units of GLFW 890 // 891 extern _GLFWlibrary _glfw; 892 893 894 ////////////////////////////////////////////////////////////////////////// 895 ////// GLFW platform API ////// 896 ////////////////////////////////////////////////////////////////////////// 897 898 void _glfwPlatformInitTimer(void); 899 uint64_t _glfwPlatformGetTimerValue(void); 900 uint64_t _glfwPlatformGetTimerFrequency(void); 901 902 GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls); 903 void _glfwPlatformDestroyTls(_GLFWtls* tls); 904 void* _glfwPlatformGetTls(_GLFWtls* tls); 905 void _glfwPlatformSetTls(_GLFWtls* tls, void* value); 906 907 GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex); 908 void _glfwPlatformDestroyMutex(_GLFWmutex* mutex); 909 void _glfwPlatformLockMutex(_GLFWmutex* mutex); 910 void _glfwPlatformUnlockMutex(_GLFWmutex* mutex); 911 912 void* _glfwPlatformLoadModule(const char* path); 913 void _glfwPlatformFreeModule(void* module); 914 GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name); 915 916 917 ////////////////////////////////////////////////////////////////////////// 918 ////// GLFW event API ////// 919 ////////////////////////////////////////////////////////////////////////// 920 921 void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused); 922 void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos); 923 void _glfwInputWindowSize(_GLFWwindow* window, int width, int height); 924 void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height); 925 void _glfwInputWindowContentScale(_GLFWwindow* window, 926 float xscale, float yscale); 927 void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified); 928 void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized); 929 void _glfwInputWindowDamage(_GLFWwindow* window); 930 void _glfwInputWindowCloseRequest(_GLFWwindow* window); 931 void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor); 932 933 void _glfwInputKey(_GLFWwindow* window, 934 int key, int scancode, int action, int mods); 935 void _glfwInputChar(_GLFWwindow* window, 936 uint32_t codepoint, int mods, GLFWbool plain); 937 void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset); 938 void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods); 939 void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos); 940 void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered); 941 void _glfwInputDrop(_GLFWwindow* window, int count, const char** names); 942 void _glfwInputJoystick(_GLFWjoystick* js, int event); 943 void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value); 944 void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value); 945 void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value); 946 947 void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement); 948 void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window); 949 950 #if defined(__GNUC__) 951 void _glfwInputError(int code, const char* format, ...) 952 __attribute__((format(printf, 2, 3))); 953 #else 954 void _glfwInputError(int code, const char* format, ...); 955 #endif 956 957 958 ////////////////////////////////////////////////////////////////////////// 959 ////// GLFW internal API ////// 960 ////////////////////////////////////////////////////////////////////////// 961 962 GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform* platform); 963 964 GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions); 965 const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, 966 const _GLFWfbconfig* alternatives, 967 unsigned int count); 968 GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window, 969 const _GLFWctxconfig* ctxconfig); 970 GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig); 971 972 const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor, 973 const GLFWvidmode* desired); 974 int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second); 975 _GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM); 976 void _glfwFreeMonitor(_GLFWmonitor* monitor); 977 void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size); 978 void _glfwFreeGammaArrays(GLFWgammaramp* ramp); 979 void _glfwSplitBPP(int bpp, int* red, int* green, int* blue); 980 981 void _glfwInitGamepadMappings(void); 982 _GLFWjoystick* _glfwAllocJoystick(const char* name, 983 const char* guid, 984 int axisCount, 985 int buttonCount, 986 int hatCount); 987 void _glfwFreeJoystick(_GLFWjoystick* js); 988 void _glfwCenterCursorInContentArea(_GLFWwindow* window); 989 990 GLFWbool _glfwInitEGL(void); 991 void _glfwTerminateEGL(void); 992 GLFWbool _glfwCreateContextEGL(_GLFWwindow* window, 993 const _GLFWctxconfig* ctxconfig, 994 const _GLFWfbconfig* fbconfig); 995 #if defined(_GLFW_X11) 996 GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig, 997 const _GLFWctxconfig* ctxconfig, 998 const _GLFWfbconfig* fbconfig, 999 Visual** visual, int* depth); 1000 #endif /*_GLFW_X11*/ 1001 1002 GLFWbool _glfwInitOSMesa(void); 1003 void _glfwTerminateOSMesa(void); 1004 GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window, 1005 const _GLFWctxconfig* ctxconfig, 1006 const _GLFWfbconfig* fbconfig); 1007 1008 GLFWbool _glfwInitVulkan(int mode); 1009 void _glfwTerminateVulkan(void); 1010 const char* _glfwGetVulkanResultString(VkResult result); 1011 1012 size_t _glfwEncodeUTF8(char* s, uint32_t codepoint); 1013 char** _glfwParseUriList(char* text, int* count); 1014 1015 char* _glfw_strdup(const char* source); 1016 int _glfw_min(int a, int b); 1017 int _glfw_max(int a, int b); 1018 1019 void* _glfw_calloc(size_t count, size_t size); 1020 void* _glfw_realloc(void* pointer, size_t size); 1021 void _glfw_free(void* pointer); 1022 1023