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