1//========================================================================
2// GLFW 3.4 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-2019 Camilla Löwy <[email protected]>
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
61typedef int GLFWbool;
62typedef void (*GLFWproc)(void);
63
64typedef struct _GLFWerror _GLFWerror;
65typedef struct _GLFWinitconfig _GLFWinitconfig;
66typedef struct _GLFWwndconfig _GLFWwndconfig;
67typedef struct _GLFWctxconfig _GLFWctxconfig;
68typedef struct _GLFWfbconfig _GLFWfbconfig;
69typedef struct _GLFWcontext _GLFWcontext;
70typedef struct _GLFWwindow _GLFWwindow;
71typedef struct _GLFWplatform _GLFWplatform;
72typedef struct _GLFWlibrary _GLFWlibrary;
73typedef struct _GLFWmonitor _GLFWmonitor;
74typedef struct _GLFWcursor _GLFWcursor;
75typedef struct _GLFWmapelement _GLFWmapelement;
76typedef struct _GLFWmapping _GLFWmapping;
77typedef struct _GLFWjoystick _GLFWjoystick;
78typedef struct _GLFWtls _GLFWtls;
79typedef 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
100typedef int GLint;
101typedef unsigned int GLuint;
102typedef unsigned int GLenum;
103typedef unsigned int GLbitfield;
104typedef unsigned char GLubyte;
105
106typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield);
107typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum);
108typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*);
109typedef 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_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
190typedef int EGLint;
191typedef unsigned int EGLBoolean;
192typedef unsigned int EGLenum;
193typedef void* EGLConfig;
194typedef void* EGLContext;
195typedef void* EGLDisplay;
196typedef void* EGLSurface;
197
198typedef void* EGLNativeDisplayType;
199typedef void* EGLNativeWindowType;
200
201// EGL function pointer typedefs
202typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigAttrib)(EGLDisplay,EGLConfig,EGLint,EGLint*);
203typedef EGLBoolean (EGLAPIENTRY * PFN_eglGetConfigs)(EGLDisplay,EGLConfig*,EGLint,EGLint*);
204typedef EGLDisplay (EGLAPIENTRY * PFN_eglGetDisplay)(EGLNativeDisplayType);
205typedef EGLint (EGLAPIENTRY * PFN_eglGetError)(void);
206typedef EGLBoolean (EGLAPIENTRY * PFN_eglInitialize)(EGLDisplay,EGLint*,EGLint*);
207typedef EGLBoolean (EGLAPIENTRY * PFN_eglTerminate)(EGLDisplay);
208typedef EGLBoolean (EGLAPIENTRY * PFN_eglBindAPI)(EGLenum);
209typedef EGLContext (EGLAPIENTRY * PFN_eglCreateContext)(EGLDisplay,EGLConfig,EGLContext,const EGLint*);
210typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroySurface)(EGLDisplay,EGLSurface);
211typedef EGLBoolean (EGLAPIENTRY * PFN_eglDestroyContext)(EGLDisplay,EGLContext);
212typedef EGLSurface (EGLAPIENTRY * PFN_eglCreateWindowSurface)(EGLDisplay,EGLConfig,EGLNativeWindowType,const EGLint*);
213typedef EGLBoolean (EGLAPIENTRY * PFN_eglMakeCurrent)(EGLDisplay,EGLSurface,EGLSurface,EGLContext);
214typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapBuffers)(EGLDisplay,EGLSurface);
215typedef EGLBoolean (EGLAPIENTRY * PFN_eglSwapInterval)(EGLDisplay,EGLint);
216typedef const char* (EGLAPIENTRY * PFN_eglQueryString)(EGLDisplay,EGLint);
217typedef GLFWglproc (EGLAPIENTRY * PFN_eglGetProcAddress)(const char*);
218#define eglGetConfigAttrib _glfw.egl.GetConfigAttrib
219#define eglGetConfigs _glfw.egl.GetConfigs
220#define eglGetDisplay _glfw.egl.GetDisplay
221#define eglGetError _glfw.egl.GetError
222#define eglInitialize _glfw.egl.Initialize
223#define eglTerminate _glfw.egl.Terminate
224#define eglBindAPI _glfw.egl.BindAPI
225#define eglCreateContext _glfw.egl.CreateContext
226#define eglDestroySurface _glfw.egl.DestroySurface
227#define eglDestroyContext _glfw.egl.DestroyContext
228#define eglCreateWindowSurface _glfw.egl.CreateWindowSurface
229#define eglMakeCurrent _glfw.egl.MakeCurrent
230#define eglSwapBuffers _glfw.egl.SwapBuffers
231#define eglSwapInterval _glfw.egl.SwapInterval
232#define eglQueryString _glfw.egl.QueryString
233#define eglGetProcAddress _glfw.egl.GetProcAddress
234
235typedef EGLDisplay (EGLAPIENTRY * PFNEGLGETPLATFORMDISPLAYEXTPROC)(EGLenum,void*,const EGLint*);
236typedef EGLSurface (EGLAPIENTRY * PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC)(EGLDisplay,EGLConfig,void*,const EGLint*);
237#define eglGetPlatformDisplayEXT _glfw.egl.GetPlatformDisplayEXT
238#define eglCreatePlatformWindowSurfaceEXT _glfw.egl.CreatePlatformWindowSurfaceEXT
239
240#define OSMESA_RGBA 0x1908
241#define OSMESA_FORMAT 0x22
242#define OSMESA_DEPTH_BITS 0x30
243#define OSMESA_STENCIL_BITS 0x31
244#define OSMESA_ACCUM_BITS 0x32
245#define OSMESA_PROFILE 0x33
246#define OSMESA_CORE_PROFILE 0x34
247#define OSMESA_COMPAT_PROFILE 0x35
248#define OSMESA_CONTEXT_MAJOR_VERSION 0x36
249#define OSMESA_CONTEXT_MINOR_VERSION 0x37
250
251typedef void* OSMesaContext;
252typedef void (*OSMESAproc)(void);
253
254typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextExt)(GLenum,GLint,GLint,GLint,OSMesaContext);
255typedef OSMesaContext (GLAPIENTRY * PFN_OSMesaCreateContextAttribs)(const int*,OSMesaContext);
256typedef void (GLAPIENTRY * PFN_OSMesaDestroyContext)(OSMesaContext);
257typedef int (GLAPIENTRY * PFN_OSMesaMakeCurrent)(OSMesaContext,void*,int,int,int);
258typedef int (GLAPIENTRY * PFN_OSMesaGetColorBuffer)(OSMesaContext,int*,int*,int*,void**);
259typedef int (GLAPIENTRY * PFN_OSMesaGetDepthBuffer)(OSMesaContext,int*,int*,int*,void**);
260typedef GLFWglproc (GLAPIENTRY * PFN_OSMesaGetProcAddress)(const char*);
261#define OSMesaCreateContextExt _glfw.osmesa.CreateContextExt
262#define OSMesaCreateContextAttribs _glfw.osmesa.CreateContextAttribs
263#define OSMesaDestroyContext _glfw.osmesa.DestroyContext
264#define OSMesaMakeCurrent _glfw.osmesa.MakeCurrent
265#define OSMesaGetColorBuffer _glfw.osmesa.GetColorBuffer
266#define OSMesaGetDepthBuffer _glfw.osmesa.GetDepthBuffer
267#define OSMesaGetProcAddress _glfw.osmesa.GetProcAddress
268
269#define VK_NULL_HANDLE 0
270
271typedef void* VkInstance;
272typedef void* VkPhysicalDevice;
273typedef uint64_t VkSurfaceKHR;
274typedef uint32_t VkFlags;
275typedef uint32_t VkBool32;
276
277typedef enum VkStructureType
278{
279 VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000,
280 VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000,
281 VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000,
282 VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000,
283 VK_STRUCTURE_TYPE_MACOS_SURFACE_CREATE_INFO_MVK = 1000123000,
284 VK_STRUCTURE_TYPE_METAL_SURFACE_CREATE_INFO_EXT = 1000217000,
285 VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF
286} VkStructureType;
287
288typedef enum VkResult
289{
290 VK_SUCCESS = 0,
291 VK_NOT_READY = 1,
292 VK_TIMEOUT = 2,
293 VK_EVENT_SET = 3,
294 VK_EVENT_RESET = 4,
295 VK_INCOMPLETE = 5,
296 VK_ERROR_OUT_OF_HOST_MEMORY = -1,
297 VK_ERROR_OUT_OF_DEVICE_MEMORY = -2,
298 VK_ERROR_INITIALIZATION_FAILED = -3,
299 VK_ERROR_DEVICE_LOST = -4,
300 VK_ERROR_MEMORY_MAP_FAILED = -5,
301 VK_ERROR_LAYER_NOT_PRESENT = -6,
302 VK_ERROR_EXTENSION_NOT_PRESENT = -7,
303 VK_ERROR_FEATURE_NOT_PRESENT = -8,
304 VK_ERROR_INCOMPATIBLE_DRIVER = -9,
305 VK_ERROR_TOO_MANY_OBJECTS = -10,
306 VK_ERROR_FORMAT_NOT_SUPPORTED = -11,
307 VK_ERROR_SURFACE_LOST_KHR = -1000000000,
308 VK_SUBOPTIMAL_KHR = 1000001003,
309 VK_ERROR_OUT_OF_DATE_KHR = -1000001004,
310 VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001,
311 VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001,
312 VK_ERROR_VALIDATION_FAILED_EXT = -1000011001,
313 VK_RESULT_MAX_ENUM = 0x7FFFFFFF
314} VkResult;
315
316typedef struct VkAllocationCallbacks VkAllocationCallbacks;
317
318typedef struct VkExtensionProperties
319{
320 char extensionName[256];
321 uint32_t specVersion;
322} VkExtensionProperties;
323
324typedef void (APIENTRY * PFN_vkVoidFunction)(void);
325
326typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*);
327typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*);
328#define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr
329
330#include "platform.h"
331
332// Constructs a version number string from the public header macros
333#define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r
334#define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r)
335#define _GLFW_VERSION_NUMBER _GLFW_MAKE_VERSION(GLFW_VERSION_MAJOR, \
336 GLFW_VERSION_MINOR, \
337 GLFW_VERSION_REVISION)
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//
364struct _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//
375struct _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};
389
390// Window configuration
391//
392// Parameters relating to the creation of the window but not directly related
393// to the framebuffer. This is used to pass window creation parameters from
394// shared code to the platform API.
395//
396struct _GLFWwndconfig
397{
398 int width;
399 int height;
400 const char* title;
401 GLFWbool resizable;
402 GLFWbool visible;
403 GLFWbool decorated;
404 GLFWbool focused;
405 GLFWbool autoIconify;
406 GLFWbool floating;
407 GLFWbool maximized;
408 GLFWbool centerCursor;
409 GLFWbool focusOnShow;
410 GLFWbool mousePassthrough;
411 GLFWbool scaleToMonitor;
412 struct {
413 GLFWbool retina;
414 char frameName[256];
415 } ns;
416 struct {
417 char className[256];
418 char instanceName[256];
419 } x11;
420 struct {
421 GLFWbool keymenu;
422 } win32;
423};
424
425// Context configuration
426//
427// Parameters relating to the creation of the context but not directly related
428// to the framebuffer. This is used to pass context creation parameters from
429// shared code to the platform API.
430//
431struct _GLFWctxconfig
432{
433 int client;
434 int source;
435 int major;
436 int minor;
437 GLFWbool forward;
438 GLFWbool debug;
439 GLFWbool noerror;
440 int profile;
441 int robustness;
442 int release;
443 _GLFWwindow* share;
444 struct {
445 GLFWbool offline;
446 } nsgl;
447};
448
449// Framebuffer configuration
450//
451// This describes buffers and their sizes. It also contains
452// a platform-specific ID used to map back to the backend API object.
453//
454// It is used to pass framebuffer parameters from shared code to the platform
455// API and also to enumerate and select available framebuffer configs.
456//
457struct _GLFWfbconfig
458{
459 int redBits;
460 int greenBits;
461 int blueBits;
462 int alphaBits;
463 int depthBits;
464 int stencilBits;
465 int accumRedBits;
466 int accumGreenBits;
467 int accumBlueBits;
468 int accumAlphaBits;
469 int auxBuffers;
470 GLFWbool stereo;
471 int samples;
472 GLFWbool sRGB;
473 GLFWbool doublebuffer;
474 GLFWbool transparent;
475 uintptr_t handle;
476};
477
478// Context structure
479//
480struct _GLFWcontext
481{
482 int client;
483 int source;
484 int major, minor, revision;
485 GLFWbool forward, debug, noerror;
486 int profile;
487 int robustness;
488 int release;
489
490 PFNGLGETSTRINGIPROC GetStringi;
491 PFNGLGETINTEGERVPROC GetIntegerv;
492 PFNGLGETSTRINGPROC GetString;
493
494 void (*makeCurrent)(_GLFWwindow*);
495 void (*swapBuffers)(_GLFWwindow*);
496 void (*swapInterval)(int);
497 int (*extensionSupported)(const char*);
498 GLFWglproc (*getProcAddress)(const char*);
499 void (*destroy)(_GLFWwindow*);
500
501 struct {
502 EGLConfig config;
503 EGLContext handle;
504 EGLSurface surface;
505 void* client;
506 } egl;
507
508 struct {
509 OSMesaContext handle;
510 int width;
511 int height;
512 void* buffer;
513 } osmesa;
514
515 // This is defined in platform.h
516 GLFW_PLATFORM_CONTEXT_STATE
517};
518
519// Window and context structure
520//
521struct _GLFWwindow
522{
523 struct _GLFWwindow* next;
524
525 // Window settings and state
526 GLFWbool resizable;
527 GLFWbool decorated;
528 GLFWbool autoIconify;
529 GLFWbool floating;
530 GLFWbool focusOnShow;
531 GLFWbool mousePassthrough;
532 GLFWbool shouldClose;
533 void* userPointer;
534 GLFWbool doublebuffer;
535 GLFWvidmode videoMode;
536 _GLFWmonitor* monitor;
537 _GLFWcursor* cursor;
538
539 int minwidth, minheight;
540 int maxwidth, maxheight;
541 int numer, denom;
542
543 GLFWbool stickyKeys;
544 GLFWbool stickyMouseButtons;
545 GLFWbool lockKeyMods;
546 int cursorMode;
547 char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1];
548 char keys[GLFW_KEY_LAST + 1];
549 // Virtual cursor position when cursor is disabled
550 double virtualCursorPosX, virtualCursorPosY;
551 GLFWbool rawMouseMotion;
552
553 _GLFWcontext context;
554
555 struct {
556 GLFWwindowposfun pos;
557 GLFWwindowsizefun size;
558 GLFWwindowclosefun close;
559 GLFWwindowrefreshfun refresh;
560 GLFWwindowfocusfun focus;
561 GLFWwindowiconifyfun iconify;
562 GLFWwindowmaximizefun maximize;
563 GLFWframebuffersizefun fbsize;
564 GLFWwindowcontentscalefun scale;
565 GLFWmousebuttonfun mouseButton;
566 GLFWcursorposfun cursorPos;
567 GLFWcursorenterfun cursorEnter;
568 GLFWscrollfun scroll;
569 GLFWkeyfun key;
570 GLFWcharfun character;
571 GLFWcharmodsfun charmods;
572 GLFWdropfun drop;
573 } callbacks;
574
575 // This is defined in platform.h
576 GLFW_PLATFORM_WINDOW_STATE
577};
578
579// Monitor structure
580//
581struct _GLFWmonitor
582{
583 char name[128];
584 void* userPointer;
585
586 // Physical dimensions in millimeters.
587 int widthMM, heightMM;
588
589 // The window whose video mode is current on this monitor
590 _GLFWwindow* window;
591
592 GLFWvidmode* modes;
593 int modeCount;
594 GLFWvidmode currentMode;
595
596 GLFWgammaramp originalRamp;
597 GLFWgammaramp currentRamp;
598
599 // This is defined in platform.h
600 GLFW_PLATFORM_MONITOR_STATE
601};
602
603// Cursor structure
604//
605struct _GLFWcursor
606{
607 _GLFWcursor* next;
608 // This is defined in platform.h
609 GLFW_PLATFORM_CURSOR_STATE
610};
611
612// Gamepad mapping element structure
613//
614struct _GLFWmapelement
615{
616 uint8_t type;
617 uint8_t index;
618 int8_t axisScale;
619 int8_t axisOffset;
620};
621
622// Gamepad mapping structure
623//
624struct _GLFWmapping
625{
626 char name[128];
627 char guid[33];
628 _GLFWmapelement buttons[15];
629 _GLFWmapelement axes[6];
630};
631
632// Joystick structure
633//
634struct _GLFWjoystick
635{
636 GLFWbool present;
637 float* axes;
638 int axisCount;
639 unsigned char* buttons;
640 int buttonCount;
641 unsigned char* hats;
642 int hatCount;
643 char name[128];
644 void* userPointer;
645 char guid[33];
646 _GLFWmapping* mapping;
647
648 // This is defined in platform.h
649 GLFW_PLATFORM_JOYSTICK_STATE
650};
651
652// Thread local storage structure
653//
654struct _GLFWtls
655{
656 // This is defined in platform.h
657 GLFW_PLATFORM_TLS_STATE
658};
659
660// Mutex structure
661//
662struct _GLFWmutex
663{
664 // This is defined in platform.h
665 GLFW_PLATFORM_MUTEX_STATE
666};
667
668// Platform API structure
669//
670struct _GLFWplatform
671{
672 int platformID;
673 // init
674 GLFWbool (*init)(void);
675 void (*terminate)(void);
676 // input
677 void (*getCursorPos)(_GLFWwindow*,double*,double*);
678 void (*setCursorPos)(_GLFWwindow*,double,double);
679 void (*setCursorMode)(_GLFWwindow*,int);
680 void (*setRawMouseMotion)(_GLFWwindow*,GLFWbool);
681 GLFWbool (*rawMouseMotionSupported)(void);
682 int (*createCursor)(_GLFWcursor*,const GLFWimage*,int,int);
683 int (*createStandardCursor)(_GLFWcursor*,int);
684 void (*destroyCursor)(_GLFWcursor*);
685 void (*setCursor)(_GLFWwindow*,_GLFWcursor*);
686 const char* (*getScancodeName)(int);
687 int (*getKeyScancode)(int);
688 void (*setClipboardString)(const char*);
689 const char* (*getClipboardString)(void);
690 GLFWbool (*initJoysticks)(void);
691 void (*terminateJoysticks)(void);
692 int (*pollJoystick)(_GLFWjoystick*,int);
693 const char* (*getMappingName)(void);
694 void (*updateGamepadGUID)(char*);
695 // monitor
696 void (*freeMonitor)(_GLFWmonitor*);
697 void (*getMonitorPos)(_GLFWmonitor*,int*,int*);
698 void (*getMonitorContentScale)(_GLFWmonitor*,float*,float*);
699 void (*getMonitorWorkarea)(_GLFWmonitor*,int*,int*,int*,int*);
700 GLFWvidmode* (*getVideoModes)(_GLFWmonitor*,int*);
701 void (*getVideoMode)(_GLFWmonitor*,GLFWvidmode*);
702 GLFWbool (*getGammaRamp)(_GLFWmonitor*,GLFWgammaramp*);
703 void (*setGammaRamp)(_GLFWmonitor*,const GLFWgammaramp*);
704 // window
705 int (*createWindow)(_GLFWwindow*,const _GLFWwndconfig*,const _GLFWctxconfig*,const _GLFWfbconfig*);
706 void (*destroyWindow)(_GLFWwindow*);
707 void (*setWindowTitle)(_GLFWwindow*,const char*);
708 void (*setWindowIcon)(_GLFWwindow*,int,const GLFWimage*);
709 void (*getWindowPos)(_GLFWwindow*,int*,int*);
710 void (*setWindowPos)(_GLFWwindow*,int,int);
711 void (*getWindowSize)(_GLFWwindow*,int*,int*);
712 void (*setWindowSize)(_GLFWwindow*,int,int);
713 void (*setWindowSizeLimits)(_GLFWwindow*,int,int,int,int);
714 void (*setWindowAspectRatio)(_GLFWwindow*,int,int);
715 void (*getFramebufferSize)(_GLFWwindow*,int*,int*);
716 void (*getWindowFrameSize)(_GLFWwindow*,int*,int*,int*,int*);
717 void (*getWindowContentScale)(_GLFWwindow*,float*,float*);
718 void (*iconifyWindow)(_GLFWwindow*);
719 void (*restoreWindow)(_GLFWwindow*);
720 void (*maximizeWindow)(_GLFWwindow*);
721 void (*showWindow)(_GLFWwindow*);
722 void (*hideWindow)(_GLFWwindow*);
723 void (*requestWindowAttention)(_GLFWwindow*);
724 void (*focusWindow)(_GLFWwindow*);
725 void (*setWindowMonitor)(_GLFWwindow*,_GLFWmonitor*,int,int,int,int,int);
726 int (*windowFocused)(_GLFWwindow*);
727 int (*windowIconified)(_GLFWwindow*);
728 int (*windowVisible)(_GLFWwindow*);
729 int (*windowMaximized)(_GLFWwindow*);
730 int (*windowHovered)(_GLFWwindow*);
731 int (*framebufferTransparent)(_GLFWwindow*);
732 float (*getWindowOpacity)(_GLFWwindow*);
733 void (*setWindowResizable)(_GLFWwindow*,GLFWbool);
734 void (*setWindowDecorated)(_GLFWwindow*,GLFWbool);
735 void (*setWindowFloating)(_GLFWwindow*,GLFWbool);
736 void (*setWindowOpacity)(_GLFWwindow*,float);
737 void (*setWindowMousePassthrough)(_GLFWwindow*,GLFWbool);
738 void (*pollEvents)(void);
739 void (*waitEvents)(void);
740 void (*waitEventsTimeout)(double);
741 void (*postEmptyEvent)(void);
742 // EGL
743 EGLenum (*getEGLPlatform)(EGLint**);
744 EGLNativeDisplayType (*getEGLNativeDisplay)(void);
745 EGLNativeWindowType (*getEGLNativeWindow)(_GLFWwindow*);
746 // vulkan
747 void (*getRequiredInstanceExtensions)(char**);
748 int (*getPhysicalDevicePresentationSupport)(VkInstance,VkPhysicalDevice,uint32_t);
749 VkResult (*createWindowSurface)(VkInstance,_GLFWwindow*,const VkAllocationCallbacks*,VkSurfaceKHR*);
750};
751
752// Library global data
753//
754struct _GLFWlibrary
755{
756 GLFWbool initialized;
757 GLFWallocator allocator;
758
759 _GLFWplatform platform;
760
761 struct {
762 _GLFWinitconfig init;
763 _GLFWfbconfig framebuffer;
764 _GLFWwndconfig window;
765 _GLFWctxconfig context;
766 int refreshRate;
767 } hints;
768
769 _GLFWerror* errorListHead;
770 _GLFWcursor* cursorListHead;
771 _GLFWwindow* windowListHead;
772
773 _GLFWmonitor** monitors;
774 int monitorCount;
775
776 GLFWbool joysticksInitialized;
777 _GLFWjoystick joysticks[GLFW_JOYSTICK_LAST + 1];
778 _GLFWmapping* mappings;
779 int mappingCount;
780
781 _GLFWtls errorSlot;
782 _GLFWtls contextSlot;
783 _GLFWmutex errorLock;
784
785 struct {
786 uint64_t offset;
787 // This is defined in platform.h
788 GLFW_PLATFORM_LIBRARY_TIMER_STATE
789 } timer;
790
791 struct {
792 EGLenum platform;
793 EGLDisplay display;
794 EGLint major, minor;
795 GLFWbool prefix;
796
797 GLFWbool KHR_create_context;
798 GLFWbool KHR_create_context_no_error;
799 GLFWbool KHR_gl_colorspace;
800 GLFWbool KHR_get_all_proc_addresses;
801 GLFWbool KHR_context_flush_control;
802 GLFWbool EXT_client_extensions;
803 GLFWbool EXT_platform_base;
804 GLFWbool EXT_platform_x11;
805 GLFWbool EXT_platform_wayland;
806 GLFWbool ANGLE_platform_angle;
807 GLFWbool ANGLE_platform_angle_opengl;
808 GLFWbool ANGLE_platform_angle_d3d;
809 GLFWbool ANGLE_platform_angle_vulkan;
810 GLFWbool ANGLE_platform_angle_metal;
811
812 void* handle;
813
814 PFN_eglGetConfigAttrib GetConfigAttrib;
815 PFN_eglGetConfigs GetConfigs;
816 PFN_eglGetDisplay GetDisplay;
817 PFN_eglGetError GetError;
818 PFN_eglInitialize Initialize;
819 PFN_eglTerminate Terminate;
820 PFN_eglBindAPI BindAPI;
821 PFN_eglCreateContext CreateContext;
822 PFN_eglDestroySurface DestroySurface;
823 PFN_eglDestroyContext DestroyContext;
824 PFN_eglCreateWindowSurface CreateWindowSurface;
825 PFN_eglMakeCurrent MakeCurrent;
826 PFN_eglSwapBuffers SwapBuffers;
827 PFN_eglSwapInterval SwapInterval;
828 PFN_eglQueryString QueryString;
829 PFN_eglGetProcAddress GetProcAddress;
830
831 PFNEGLGETPLATFORMDISPLAYEXTPROC GetPlatformDisplayEXT;
832 PFNEGLCREATEPLATFORMWINDOWSURFACEEXTPROC CreatePlatformWindowSurfaceEXT;
833 } egl;
834
835 struct {
836 void* handle;
837
838 PFN_OSMesaCreateContextExt CreateContextExt;
839 PFN_OSMesaCreateContextAttribs CreateContextAttribs;
840 PFN_OSMesaDestroyContext DestroyContext;
841 PFN_OSMesaMakeCurrent MakeCurrent;
842 PFN_OSMesaGetColorBuffer GetColorBuffer;
843 PFN_OSMesaGetDepthBuffer GetDepthBuffer;
844 PFN_OSMesaGetProcAddress GetProcAddress;
845
846 } osmesa;
847
848 struct {
849 GLFWbool available;
850 void* handle;
851 char* extensions[2];
852 PFN_vkGetInstanceProcAddr GetInstanceProcAddr;
853 GLFWbool KHR_surface;
854 GLFWbool KHR_win32_surface;
855 GLFWbool MVK_macos_surface;
856 GLFWbool EXT_metal_surface;
857 GLFWbool KHR_xlib_surface;
858 GLFWbool KHR_xcb_surface;
859 GLFWbool KHR_wayland_surface;
860 } vk;
861
862 struct {
863 GLFWmonitorfun monitor;
864 GLFWjoystickfun joystick;
865 } callbacks;
866
867 // These are defined in platform.h
868 GLFW_PLATFORM_LIBRARY_WINDOW_STATE
869 GLFW_PLATFORM_LIBRARY_CONTEXT_STATE
870 GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE
871};
872
873// Global state shared between compilation units of GLFW
874//
875extern _GLFWlibrary _glfw;
876
877
878//////////////////////////////////////////////////////////////////////////
879////// GLFW platform API //////
880//////////////////////////////////////////////////////////////////////////
881
882void _glfwPlatformInitTimer(void);
883uint64_t _glfwPlatformGetTimerValue(void);
884uint64_t _glfwPlatformGetTimerFrequency(void);
885
886GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls);
887void _glfwPlatformDestroyTls(_GLFWtls* tls);
888void* _glfwPlatformGetTls(_GLFWtls* tls);
889void _glfwPlatformSetTls(_GLFWtls* tls, void* value);
890
891GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex);
892void _glfwPlatformDestroyMutex(_GLFWmutex* mutex);
893void _glfwPlatformLockMutex(_GLFWmutex* mutex);
894void _glfwPlatformUnlockMutex(_GLFWmutex* mutex);
895
896void* _glfwPlatformLoadModule(const char* path);
897void _glfwPlatformFreeModule(void* module);
898GLFWproc _glfwPlatformGetModuleSymbol(void* module, const char* name);
899
900
901//////////////////////////////////////////////////////////////////////////
902////// GLFW event API //////
903//////////////////////////////////////////////////////////////////////////
904
905void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused);
906void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos);
907void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
908void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height);
909void _glfwInputWindowContentScale(_GLFWwindow* window,
910 float xscale, float yscale);
911void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified);
912void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized);
913void _glfwInputWindowDamage(_GLFWwindow* window);
914void _glfwInputWindowCloseRequest(_GLFWwindow* window);
915void _glfwInputWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor);
916
917void _glfwInputKey(_GLFWwindow* window,
918 int key, int scancode, int action, int mods);
919void _glfwInputChar(_GLFWwindow* window,
920 unsigned int codepoint, int mods, GLFWbool plain);
921void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
922void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods);
923void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
924void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered);
925void _glfwInputDrop(_GLFWwindow* window, int count, const char** names);
926void _glfwInputJoystick(_GLFWjoystick* js, int event);
927void _glfwInputJoystickAxis(_GLFWjoystick* js, int axis, float value);
928void _glfwInputJoystickButton(_GLFWjoystick* js, int button, char value);
929void _glfwInputJoystickHat(_GLFWjoystick* js, int hat, char value);
930
931void _glfwInputMonitor(_GLFWmonitor* monitor, int action, int placement);
932void _glfwInputMonitorWindow(_GLFWmonitor* monitor, _GLFWwindow* window);
933
934#if defined(__GNUC__)
935void _glfwInputError(int code, const char* format, ...)
936 __attribute__((format(printf, 2, 3)));
937#else
938void _glfwInputError(int code, const char* format, ...);
939#endif
940
941
942//////////////////////////////////////////////////////////////////////////
943////// GLFW internal API //////
944//////////////////////////////////////////////////////////////////////////
945
946GLFWbool _glfwSelectPlatform(int platformID, _GLFWplatform* platform);
947
948GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions);
949const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
950 const _GLFWfbconfig* alternatives,
951 unsigned int count);
952GLFWbool _glfwRefreshContextAttribs(_GLFWwindow* window,
953 const _GLFWctxconfig* ctxconfig);
954GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig);
955
956const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor,
957 const GLFWvidmode* desired);
958int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second);
959_GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM);
960void _glfwFreeMonitor(_GLFWmonitor* monitor);
961void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size);
962void _glfwFreeGammaArrays(GLFWgammaramp* ramp);
963void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
964
965void _glfwInitGamepadMappings(void);
966_GLFWjoystick* _glfwAllocJoystick(const char* name,
967 const char* guid,
968 int axisCount,
969 int buttonCount,
970 int hatCount);
971void _glfwFreeJoystick(_GLFWjoystick* js);
972void _glfwCenterCursorInContentArea(_GLFWwindow* window);
973
974GLFWbool _glfwInitEGL(void);
975void _glfwTerminateEGL(void);
976GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
977 const _GLFWctxconfig* ctxconfig,
978 const _GLFWfbconfig* fbconfig);
979#if defined(_GLFW_X11)
980GLFWbool _glfwChooseVisualEGL(const _GLFWwndconfig* wndconfig,
981 const _GLFWctxconfig* ctxconfig,
982 const _GLFWfbconfig* fbconfig,
983 Visual** visual, int* depth);
984#endif /*_GLFW_X11*/
985
986GLFWbool _glfwInitOSMesa(void);
987void _glfwTerminateOSMesa(void);
988GLFWbool _glfwCreateContextOSMesa(_GLFWwindow* window,
989 const _GLFWctxconfig* ctxconfig,
990 const _GLFWfbconfig* fbconfig);
991
992GLFWbool _glfwInitVulkan(int mode);
993void _glfwTerminateVulkan(void);
994const char* _glfwGetVulkanResultString(VkResult result);
995
996char* _glfw_strdup(const char* source);
997float _glfw_fminf(float a, float b);
998float _glfw_fmaxf(float a, float b);
999
1000void* _glfw_calloc(size_t count, size_t size);
1001void* _glfw_realloc(void* pointer, size_t size);
1002void _glfw_free(void* pointer);
1003
1004