1 | //======================================================================== |
2 | // GLFW 3.2 - www.glfw.org |
3 | //------------------------------------------------------------------------ |
4 | // Copyright (c) 2002-2006 Marcus Geelnard |
5 | // Copyright (c) 2006-2016 Camilla Berglund <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 | #ifndef _glfw3_internal_h_ |
29 | #define _glfw3_internal_h_ |
30 | |
31 | |
32 | #if defined(_GLFW_USE_CONFIG_H) |
33 | #include "glfw_config.h" |
34 | #endif |
35 | |
36 | #if defined(GLFW_INCLUDE_GLCOREARB) || \ |
37 | defined(GLFW_INCLUDE_ES1) || \ |
38 | defined(GLFW_INCLUDE_ES2) || \ |
39 | defined(GLFW_INCLUDE_ES3) || \ |
40 | defined(GLFW_INCLUDE_NONE) || \ |
41 | defined(GLFW_INCLUDE_GLEXT) || \ |
42 | defined(GLFW_INCLUDE_GLU) || \ |
43 | defined(GLFW_DLL) |
44 | #error "You must not define any header option macros when compiling GLFW" |
45 | #endif |
46 | |
47 | #define GLFW_INCLUDE_NONE |
48 | #include "../include/GLFW/glfw3.h" |
49 | |
50 | typedef int GLFWbool; |
51 | |
52 | typedef struct _GLFWwndconfig _GLFWwndconfig; |
53 | typedef struct _GLFWctxconfig _GLFWctxconfig; |
54 | typedef struct _GLFWfbconfig _GLFWfbconfig; |
55 | typedef struct _GLFWcontext _GLFWcontext; |
56 | typedef struct _GLFWwindow _GLFWwindow; |
57 | typedef struct _GLFWlibrary _GLFWlibrary; |
58 | typedef struct _GLFWmonitor _GLFWmonitor; |
59 | typedef struct _GLFWcursor _GLFWcursor; |
60 | |
61 | typedef void (* _GLFWmakecontextcurrentfun)(_GLFWwindow*); |
62 | typedef void (* _GLFWswapbuffersfun)(_GLFWwindow*); |
63 | typedef void (* _GLFWswapintervalfun)(int); |
64 | typedef int (* _GLFWextensionsupportedfun)(const char*); |
65 | typedef GLFWglproc (* _GLFWgetprocaddressfun)(const char*); |
66 | typedef void (* _GLFWdestroycontextfun)(_GLFWwindow*); |
67 | |
68 | #define GL_VERSION 0x1f02 |
69 | #define GL_NONE 0 |
70 | #define GL_COLOR_BUFFER_BIT 0x00004000 |
71 | #define GL_EXTENSIONS 0x1f03 |
72 | #define GL_NUM_EXTENSIONS 0x821d |
73 | #define GL_CONTEXT_FLAGS 0x821e |
74 | #define GL_CONTEXT_FLAG_FORWARD_COMPATIBLE_BIT 0x00000001 |
75 | #define GL_CONTEXT_FLAG_DEBUG_BIT 0x00000002 |
76 | #define GL_CONTEXT_PROFILE_MASK 0x9126 |
77 | #define GL_CONTEXT_COMPATIBILITY_PROFILE_BIT 0x00000002 |
78 | #define GL_CONTEXT_CORE_PROFILE_BIT 0x00000001 |
79 | #define GL_RESET_NOTIFICATION_STRATEGY_ARB 0x8256 |
80 | #define GL_LOSE_CONTEXT_ON_RESET_ARB 0x8252 |
81 | #define GL_NO_RESET_NOTIFICATION_ARB 0x8261 |
82 | #define GL_CONTEXT_RELEASE_BEHAVIOR 0x82fb |
83 | #define GL_CONTEXT_RELEASE_BEHAVIOR_FLUSH 0x82fc |
84 | #define GL_CONTEXT_FLAG_NO_ERROR_BIT_KHR 0x00000008 |
85 | |
86 | typedef int GLint; |
87 | typedef unsigned int GLuint; |
88 | typedef unsigned int GLenum; |
89 | typedef unsigned int GLbitfield; |
90 | typedef unsigned char GLubyte; |
91 | |
92 | typedef void (APIENTRY * PFNGLCLEARPROC)(GLbitfield); |
93 | typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGPROC)(GLenum); |
94 | typedef void (APIENTRY * PFNGLGETINTEGERVPROC)(GLenum,GLint*); |
95 | typedef const GLubyte* (APIENTRY * PFNGLGETSTRINGIPROC)(GLenum,GLuint); |
96 | |
97 | #define VK_NULL_HANDLE 0 |
98 | |
99 | typedef void* VkInstance; |
100 | typedef void* VkPhysicalDevice; |
101 | typedef uint64_t VkSurfaceKHR; |
102 | typedef uint32_t VkFlags; |
103 | typedef uint32_t VkBool32; |
104 | |
105 | typedef enum VkStructureType |
106 | { |
107 | VK_STRUCTURE_TYPE_XLIB_SURFACE_CREATE_INFO_KHR = 1000004000, |
108 | VK_STRUCTURE_TYPE_XCB_SURFACE_CREATE_INFO_KHR = 1000005000, |
109 | VK_STRUCTURE_TYPE_WAYLAND_SURFACE_CREATE_INFO_KHR = 1000006000, |
110 | VK_STRUCTURE_TYPE_MIR_SURFACE_CREATE_INFO_KHR = 1000007000, |
111 | VK_STRUCTURE_TYPE_WIN32_SURFACE_CREATE_INFO_KHR = 1000009000, |
112 | VK_STRUCTURE_TYPE_MAX_ENUM = 0x7FFFFFFF |
113 | } VkStructureType; |
114 | |
115 | typedef enum VkResult |
116 | { |
117 | VK_SUCCESS = 0, |
118 | VK_NOT_READY = 1, |
119 | VK_TIMEOUT = 2, |
120 | VK_EVENT_SET = 3, |
121 | VK_EVENT_RESET = 4, |
122 | VK_INCOMPLETE = 5, |
123 | VK_ERROR_OUT_OF_HOST_MEMORY = -1, |
124 | VK_ERROR_OUT_OF_DEVICE_MEMORY = -2, |
125 | VK_ERROR_INITIALIZATION_FAILED = -3, |
126 | VK_ERROR_DEVICE_LOST = -4, |
127 | VK_ERROR_MEMORY_MAP_FAILED = -5, |
128 | VK_ERROR_LAYER_NOT_PRESENT = -6, |
129 | VK_ERROR_EXTENSION_NOT_PRESENT = -7, |
130 | VK_ERROR_FEATURE_NOT_PRESENT = -8, |
131 | VK_ERROR_INCOMPATIBLE_DRIVER = -9, |
132 | VK_ERROR_TOO_MANY_OBJECTS = -10, |
133 | VK_ERROR_FORMAT_NOT_SUPPORTED = -11, |
134 | VK_ERROR_SURFACE_LOST_KHR = -1000000000, |
135 | VK_SUBOPTIMAL_KHR = 1000001003, |
136 | VK_ERROR_OUT_OF_DATE_KHR = -1000001004, |
137 | VK_ERROR_INCOMPATIBLE_DISPLAY_KHR = -1000003001, |
138 | VK_ERROR_NATIVE_WINDOW_IN_USE_KHR = -1000000001, |
139 | VK_ERROR_VALIDATION_FAILED_EXT = -1000011001, |
140 | VK_RESULT_MAX_ENUM = 0x7FFFFFFF |
141 | } VkResult; |
142 | |
143 | typedef struct VkAllocationCallbacks VkAllocationCallbacks; |
144 | |
145 | typedef struct VkExtensionProperties |
146 | { |
147 | char extensionName[256]; |
148 | uint32_t specVersion; |
149 | } VkExtensionProperties; |
150 | |
151 | typedef void (APIENTRY * PFN_vkVoidFunction)(void); |
152 | typedef PFN_vkVoidFunction (APIENTRY * PFN_vkGetInstanceProcAddr)(VkInstance,const char*); |
153 | typedef VkResult (APIENTRY * PFN_vkEnumerateInstanceExtensionProperties)(const char*,uint32_t*,VkExtensionProperties*); |
154 | |
155 | #define vkEnumerateInstanceExtensionProperties _glfw.vk.EnumerateInstanceExtensionProperties |
156 | #define vkGetInstanceProcAddr _glfw.vk.GetInstanceProcAddr |
157 | |
158 | #if defined(_GLFW_COCOA) |
159 | #include "cocoa_platform.h" |
160 | #elif defined(_GLFW_WIN32) |
161 | #include "win32_platform.h" |
162 | #elif defined(_GLFW_X11) |
163 | #include "x11_platform.h" |
164 | #elif defined(_GLFW_WAYLAND) |
165 | #include "wl_platform.h" |
166 | #elif defined(_GLFW_MIR) |
167 | #include "mir_platform.h" |
168 | #else |
169 | #error "No supported window creation API selected" |
170 | #endif |
171 | |
172 | |
173 | //======================================================================== |
174 | // Doxygen group definitions |
175 | //======================================================================== |
176 | |
177 | /*! @defgroup platform Platform interface |
178 | * @brief The interface implemented by the platform-specific code. |
179 | * |
180 | * The platform API is the interface exposed by the platform-specific code for |
181 | * each platform and is called by the shared code of the public API It mirrors |
182 | * the public API except it uses objects instead of handles. |
183 | */ |
184 | /*! @defgroup event Event interface |
185 | * @brief The interface used by the platform-specific code to report events. |
186 | * |
187 | * The event API is used by the platform-specific code to notify the shared |
188 | * code of events that can be translated into state changes and/or callback |
189 | * calls. |
190 | */ |
191 | /*! @defgroup utility Utility functions |
192 | * @brief Various utility functions for internal use. |
193 | * |
194 | * These functions are shared code and may be used by any part of GLFW |
195 | * Each platform may add its own utility functions, but those must only be |
196 | * called by the platform-specific code |
197 | */ |
198 | |
199 | |
200 | //======================================================================== |
201 | // Helper macros |
202 | //======================================================================== |
203 | |
204 | // Constructs a version number string from the public header macros |
205 | #define _GLFW_CONCAT_VERSION(m, n, r) #m "." #n "." #r |
206 | #define _GLFW_MAKE_VERSION(m, n, r) _GLFW_CONCAT_VERSION(m, n, r) |
207 | #define _GLFW_VERSION_NUMBER _GLFW_MAKE_VERSION(GLFW_VERSION_MAJOR, \ |
208 | GLFW_VERSION_MINOR, \ |
209 | GLFW_VERSION_REVISION) |
210 | |
211 | // Checks for whether the library has been initialized |
212 | #define _GLFW_REQUIRE_INIT() \ |
213 | if (!_glfwInitialized) \ |
214 | { \ |
215 | _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ |
216 | return; \ |
217 | } |
218 | #define _GLFW_REQUIRE_INIT_OR_RETURN(x) \ |
219 | if (!_glfwInitialized) \ |
220 | { \ |
221 | _glfwInputError(GLFW_NOT_INITIALIZED, NULL); \ |
222 | return x; \ |
223 | } |
224 | |
225 | // Swaps the provided pointers |
226 | #define _GLFW_SWAP_POINTERS(x, y) \ |
227 | { \ |
228 | void* t; \ |
229 | t = x; \ |
230 | x = y; \ |
231 | y = t; \ |
232 | } |
233 | |
234 | |
235 | //======================================================================== |
236 | // Platform-independent structures |
237 | //======================================================================== |
238 | |
239 | /*! @brief Window configuration. |
240 | * |
241 | * Parameters relating to the creation of the window but not directly related |
242 | * to the framebuffer. This is used to pass window creation parameters from |
243 | * shared code to the platform API. |
244 | */ |
245 | struct _GLFWwndconfig |
246 | { |
247 | int width; |
248 | int height; |
249 | const char* title; |
250 | GLFWbool resizable; |
251 | GLFWbool visible; |
252 | GLFWbool decorated; |
253 | GLFWbool focused; |
254 | GLFWbool autoIconify; |
255 | GLFWbool floating; |
256 | GLFWbool maximized; |
257 | }; |
258 | |
259 | |
260 | /*! @brief Context configuration. |
261 | * |
262 | * Parameters relating to the creation of the context but not directly related |
263 | * to the framebuffer. This is used to pass context creation parameters from |
264 | * shared code to the platform API. |
265 | */ |
266 | struct _GLFWctxconfig |
267 | { |
268 | int client; |
269 | int source; |
270 | int major; |
271 | int minor; |
272 | GLFWbool forward; |
273 | GLFWbool debug; |
274 | GLFWbool noerror; |
275 | int profile; |
276 | int robustness; |
277 | int release; |
278 | _GLFWwindow* share; |
279 | }; |
280 | |
281 | |
282 | /*! @brief Framebuffer configuration. |
283 | * |
284 | * This describes buffers and their sizes. It also contains |
285 | * a platform-specific ID used to map back to the backend API object. |
286 | * |
287 | * It is used to pass framebuffer parameters from shared code to the platform |
288 | * API and also to enumerate and select available framebuffer configs. |
289 | */ |
290 | struct _GLFWfbconfig |
291 | { |
292 | int redBits; |
293 | int greenBits; |
294 | int blueBits; |
295 | int alphaBits; |
296 | int depthBits; |
297 | int stencilBits; |
298 | int accumRedBits; |
299 | int accumGreenBits; |
300 | int accumBlueBits; |
301 | int accumAlphaBits; |
302 | int auxBuffers; |
303 | GLFWbool stereo; |
304 | int samples; |
305 | GLFWbool sRGB; |
306 | GLFWbool doublebuffer; |
307 | uintptr_t handle; |
308 | }; |
309 | |
310 | |
311 | /*! @brief Context structure. |
312 | */ |
313 | struct _GLFWcontext |
314 | { |
315 | int client; |
316 | int source; |
317 | int major, minor, revision; |
318 | GLFWbool forward, debug, noerror; |
319 | int profile; |
320 | int robustness; |
321 | int release; |
322 | |
323 | PFNGLGETSTRINGIPROC GetStringi; |
324 | PFNGLGETINTEGERVPROC GetIntegerv; |
325 | PFNGLGETSTRINGPROC GetString; |
326 | |
327 | _GLFWmakecontextcurrentfun makeCurrent; |
328 | _GLFWswapbuffersfun swapBuffers; |
329 | _GLFWswapintervalfun swapInterval; |
330 | _GLFWextensionsupportedfun extensionSupported; |
331 | _GLFWgetprocaddressfun getProcAddress; |
332 | _GLFWdestroycontextfun destroy; |
333 | |
334 | // This is defined in the context API's context.h |
335 | _GLFW_PLATFORM_CONTEXT_STATE; |
336 | // This is defined in egl_context.h |
337 | _GLFW_EGL_CONTEXT_STATE; |
338 | }; |
339 | |
340 | |
341 | /*! @brief Window and context structure. |
342 | */ |
343 | struct _GLFWwindow |
344 | { |
345 | struct _GLFWwindow* next; |
346 | |
347 | // Window settings and state |
348 | GLFWbool resizable; |
349 | GLFWbool decorated; |
350 | GLFWbool autoIconify; |
351 | GLFWbool floating; |
352 | GLFWbool closed; |
353 | void* userPointer; |
354 | GLFWvidmode videoMode; |
355 | _GLFWmonitor* monitor; |
356 | _GLFWcursor* cursor; |
357 | |
358 | int minwidth, minheight; |
359 | int maxwidth, maxheight; |
360 | int numer, denom; |
361 | |
362 | GLFWbool stickyKeys; |
363 | GLFWbool stickyMouseButtons; |
364 | int cursorMode; |
365 | char mouseButtons[GLFW_MOUSE_BUTTON_LAST + 1]; |
366 | char keys[GLFW_KEY_LAST + 1]; |
367 | // Virtual cursor position when cursor is disabled |
368 | double virtualCursorPosX, virtualCursorPosY; |
369 | |
370 | _GLFWcontext context; |
371 | |
372 | struct { |
373 | GLFWwindowposfun pos; |
374 | GLFWwindowsizefun size; |
375 | GLFWwindowclosefun close; |
376 | GLFWwindowrefreshfun refresh; |
377 | GLFWwindowfocusfun focus; |
378 | GLFWwindowiconifyfun iconify; |
379 | GLFWframebuffersizefun fbsize; |
380 | GLFWmousebuttonfun mouseButton; |
381 | GLFWcursorposfun cursorPos; |
382 | GLFWcursorenterfun cursorEnter; |
383 | GLFWscrollfun scroll; |
384 | GLFWkeyfun key; |
385 | GLFWcharfun character; |
386 | GLFWcharmodsfun charmods; |
387 | GLFWdropfun drop; |
388 | } callbacks; |
389 | |
390 | // This is defined in the window API's platform.h |
391 | _GLFW_PLATFORM_WINDOW_STATE; |
392 | }; |
393 | |
394 | |
395 | /*! @brief Monitor structure. |
396 | */ |
397 | struct _GLFWmonitor |
398 | { |
399 | char* name; |
400 | |
401 | // Physical dimensions in millimeters. |
402 | int widthMM, heightMM; |
403 | |
404 | // The window whose video mode is current on this monitor |
405 | _GLFWwindow* window; |
406 | |
407 | GLFWvidmode* modes; |
408 | int modeCount; |
409 | GLFWvidmode currentMode; |
410 | |
411 | GLFWgammaramp originalRamp; |
412 | GLFWgammaramp currentRamp; |
413 | |
414 | // This is defined in the window API's platform.h |
415 | _GLFW_PLATFORM_MONITOR_STATE; |
416 | }; |
417 | |
418 | |
419 | /*! @brief Cursor structure |
420 | */ |
421 | struct _GLFWcursor |
422 | { |
423 | _GLFWcursor* next; |
424 | |
425 | // This is defined in the window API's platform.h |
426 | _GLFW_PLATFORM_CURSOR_STATE; |
427 | }; |
428 | |
429 | /*! @brief Library global data. |
430 | */ |
431 | struct _GLFWlibrary |
432 | { |
433 | struct { |
434 | _GLFWfbconfig framebuffer; |
435 | _GLFWwndconfig window; |
436 | _GLFWctxconfig context; |
437 | int refreshRate; |
438 | } hints; |
439 | |
440 | _GLFWcursor* cursorListHead; |
441 | |
442 | _GLFWwindow* windowListHead; |
443 | |
444 | _GLFWmonitor** monitors; |
445 | int monitorCount; |
446 | |
447 | uint64_t timerOffset; |
448 | |
449 | struct { |
450 | GLFWbool available; |
451 | void* handle; |
452 | char** extensions; |
453 | uint32_t extensionCount; |
454 | PFN_vkEnumerateInstanceExtensionProperties EnumerateInstanceExtensionProperties; |
455 | PFN_vkGetInstanceProcAddr GetInstanceProcAddr; |
456 | GLFWbool KHR_surface; |
457 | GLFWbool KHR_win32_surface; |
458 | GLFWbool KHR_xlib_surface; |
459 | GLFWbool KHR_xcb_surface; |
460 | GLFWbool KHR_wayland_surface; |
461 | GLFWbool KHR_mir_surface; |
462 | } vk; |
463 | |
464 | struct { |
465 | GLFWmonitorfun monitor; |
466 | GLFWjoystickfun joystick; |
467 | } callbacks; |
468 | |
469 | // This is defined in the window API's platform.h |
470 | _GLFW_PLATFORM_LIBRARY_WINDOW_STATE; |
471 | // This is defined in the context API's context.h |
472 | _GLFW_PLATFORM_LIBRARY_CONTEXT_STATE; |
473 | // This is defined in the platform's time.h |
474 | _GLFW_PLATFORM_LIBRARY_TIME_STATE; |
475 | // This is defined in the platform's joystick.h |
476 | _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE; |
477 | // This is defined in the platform's tls.h |
478 | _GLFW_PLATFORM_LIBRARY_TLS_STATE; |
479 | // This is defined in egl_context.h |
480 | _GLFW_EGL_LIBRARY_CONTEXT_STATE; |
481 | }; |
482 | |
483 | |
484 | //======================================================================== |
485 | // Global state shared between compilation units of GLFW |
486 | //======================================================================== |
487 | |
488 | /*! @brief Flag indicating whether GLFW has been successfully initialized. |
489 | */ |
490 | extern GLFWbool _glfwInitialized; |
491 | |
492 | /*! @brief All global data protected by @ref _glfwInitialized. |
493 | * This should only be touched after a call to @ref glfwInit that has not been |
494 | * followed by a call to @ref glfwTerminate. |
495 | */ |
496 | extern _GLFWlibrary _glfw; |
497 | |
498 | |
499 | //======================================================================== |
500 | // Platform API functions |
501 | //======================================================================== |
502 | |
503 | /*! @brief Initializes the platform-specific part of the library. |
504 | * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if an error occurred. |
505 | * @ingroup platform |
506 | */ |
507 | int _glfwPlatformInit(void); |
508 | |
509 | /*! @brief Terminates the platform-specific part of the library. |
510 | * @ingroup platform |
511 | */ |
512 | void _glfwPlatformTerminate(void); |
513 | |
514 | /*! @copydoc glfwGetVersionString |
515 | * @ingroup platform |
516 | * |
517 | * @note The returned string must be available for the duration of the program. |
518 | * |
519 | * @note The returned string must not change for the duration of the program. |
520 | */ |
521 | const char* _glfwPlatformGetVersionString(void); |
522 | |
523 | /*! @copydoc glfwGetCursorPos |
524 | * @ingroup platform |
525 | */ |
526 | void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos); |
527 | |
528 | /*! @copydoc glfwSetCursorPos |
529 | * @ingroup platform |
530 | */ |
531 | void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos); |
532 | |
533 | /*! @brief Sets the specified cursor mode of the specified window. |
534 | * @param[in] window The window whose cursor mode to set. |
535 | * @ingroup platform |
536 | */ |
537 | void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode); |
538 | |
539 | /*! @copydoc glfwGetKeyName |
540 | * @ingroup platform |
541 | */ |
542 | const char* _glfwPlatformGetKeyName(int key, int scancode); |
543 | |
544 | /*! @copydoc glfwGetMonitors |
545 | * @ingroup platform |
546 | */ |
547 | _GLFWmonitor** _glfwPlatformGetMonitors(int* count); |
548 | |
549 | /*! @brief Checks whether two monitor objects represent the same monitor. |
550 | * |
551 | * @param[in] first The first monitor. |
552 | * @param[in] second The second monitor. |
553 | * @return @c GLFW_TRUE if the monitor objects represent the same monitor, or |
554 | * @c GLFW_FALSE otherwise. |
555 | * @ingroup platform |
556 | */ |
557 | GLFWbool _glfwPlatformIsSameMonitor(_GLFWmonitor* first, _GLFWmonitor* second); |
558 | |
559 | /*! @copydoc glfwGetMonitorPos |
560 | * @ingroup platform |
561 | */ |
562 | void _glfwPlatformGetMonitorPos(_GLFWmonitor* monitor, int* xpos, int* ypos); |
563 | |
564 | /*! @copydoc glfwGetVideoModes |
565 | * @ingroup platform |
566 | */ |
567 | GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* count); |
568 | |
569 | /*! @ingroup platform |
570 | */ |
571 | void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode); |
572 | |
573 | /*! @copydoc glfwGetGammaRamp |
574 | * @ingroup platform |
575 | */ |
576 | void _glfwPlatformGetGammaRamp(_GLFWmonitor* monitor, GLFWgammaramp* ramp); |
577 | |
578 | /*! @copydoc glfwSetGammaRamp |
579 | * @ingroup platform |
580 | */ |
581 | void _glfwPlatformSetGammaRamp(_GLFWmonitor* monitor, const GLFWgammaramp* ramp); |
582 | |
583 | /*! @copydoc glfwSetClipboardString |
584 | * @ingroup platform |
585 | */ |
586 | void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string); |
587 | |
588 | /*! @copydoc glfwGetClipboardString |
589 | * @ingroup platform |
590 | * |
591 | * @note The returned string must be valid until the next call to @ref |
592 | * _glfwPlatformGetClipboardString or @ref _glfwPlatformSetClipboardString. |
593 | */ |
594 | const char* _glfwPlatformGetClipboardString(_GLFWwindow* window); |
595 | |
596 | /*! @copydoc glfwJoystickPresent |
597 | * @ingroup platform |
598 | */ |
599 | int _glfwPlatformJoystickPresent(int joy); |
600 | |
601 | /*! @copydoc glfwGetJoystickAxes |
602 | * @ingroup platform |
603 | */ |
604 | const float* _glfwPlatformGetJoystickAxes(int joy, int* count); |
605 | |
606 | /*! @copydoc glfwGetJoystickButtons |
607 | * @ingroup platform |
608 | */ |
609 | const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count); |
610 | |
611 | /*! @copydoc glfwGetJoystickName |
612 | * @ingroup platform |
613 | */ |
614 | const char* _glfwPlatformGetJoystickName(int joy); |
615 | |
616 | /*! @copydoc glfwGetTimerValue |
617 | * @ingroup platform |
618 | */ |
619 | uint64_t _glfwPlatformGetTimerValue(void); |
620 | |
621 | /*! @copydoc glfwGetTimerFrequency |
622 | * @ingroup platform |
623 | */ |
624 | uint64_t _glfwPlatformGetTimerFrequency(void); |
625 | |
626 | /*! @ingroup platform |
627 | */ |
628 | int _glfwPlatformCreateWindow(_GLFWwindow* window, |
629 | const _GLFWwndconfig* wndconfig, |
630 | const _GLFWctxconfig* ctxconfig, |
631 | const _GLFWfbconfig* fbconfig); |
632 | |
633 | /*! @ingroup platform |
634 | */ |
635 | void _glfwPlatformDestroyWindow(_GLFWwindow* window); |
636 | |
637 | /*! @copydoc glfwSetWindowTitle |
638 | * @ingroup platform |
639 | */ |
640 | void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title); |
641 | |
642 | /*! @copydoc glfwSetWindowIcon |
643 | * @ingroup platform |
644 | */ |
645 | void _glfwPlatformSetWindowIcon(_GLFWwindow* window, int count, const GLFWimage* images); |
646 | |
647 | /*! @copydoc glfwGetWindowPos |
648 | * @ingroup platform |
649 | */ |
650 | void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos); |
651 | |
652 | /*! @copydoc glfwSetWindowPos |
653 | * @ingroup platform |
654 | */ |
655 | void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos); |
656 | |
657 | /*! @copydoc glfwGetWindowSize |
658 | * @ingroup platform |
659 | */ |
660 | void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height); |
661 | |
662 | /*! @copydoc glfwSetWindowSize |
663 | * @ingroup platform |
664 | */ |
665 | void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height); |
666 | |
667 | /*! @copydoc glfwSetWindowSizeLimits |
668 | * @ingroup platform |
669 | */ |
670 | void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window, int minwidth, int minheight, int maxwidth, int maxheight); |
671 | |
672 | /*! @copydoc glfwSetWindowAspectRatio |
673 | * @ingroup platform |
674 | */ |
675 | void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom); |
676 | |
677 | /*! @copydoc glfwGetFramebufferSize |
678 | * @ingroup platform |
679 | */ |
680 | void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height); |
681 | |
682 | /*! @copydoc glfwGetWindowFrameSize |
683 | * @ingroup platform |
684 | */ |
685 | void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window, int* left, int* top, int* right, int* bottom); |
686 | |
687 | /*! @copydoc glfwIconifyWindow |
688 | * @ingroup platform |
689 | */ |
690 | void _glfwPlatformIconifyWindow(_GLFWwindow* window); |
691 | |
692 | /*! @copydoc glfwRestoreWindow |
693 | * @ingroup platform |
694 | */ |
695 | void _glfwPlatformRestoreWindow(_GLFWwindow* window); |
696 | |
697 | /*! @copydoc glfwMaximizeWindow |
698 | * @ingroup platform |
699 | */ |
700 | void _glfwPlatformMaximizeWindow(_GLFWwindow* window); |
701 | |
702 | /*! @copydoc glfwShowWindow |
703 | * @ingroup platform |
704 | */ |
705 | void _glfwPlatformShowWindow(_GLFWwindow* window); |
706 | |
707 | /*! @copydoc glfwHideWindow |
708 | * @ingroup platform |
709 | */ |
710 | void _glfwPlatformHideWindow(_GLFWwindow* window); |
711 | |
712 | /*! @copydoc glfwFocusWindow |
713 | * @ingroup platform |
714 | */ |
715 | void _glfwPlatformFocusWindow(_GLFWwindow* window); |
716 | |
717 | /*! @copydoc glfwSetWindowMonitor |
718 | * @ingroup platform |
719 | */ |
720 | void _glfwPlatformSetWindowMonitor(_GLFWwindow* window, _GLFWmonitor* monitor, int xpos, int ypos, int width, int height, int refreshRate); |
721 | |
722 | /*! @brief Returns whether the window is focused. |
723 | * @ingroup platform |
724 | */ |
725 | int _glfwPlatformWindowFocused(_GLFWwindow* window); |
726 | |
727 | /*! @brief Returns whether the window is iconified. |
728 | * @ingroup platform |
729 | */ |
730 | int _glfwPlatformWindowIconified(_GLFWwindow* window); |
731 | |
732 | /*! @brief Returns whether the window is visible. |
733 | * @ingroup platform |
734 | */ |
735 | int _glfwPlatformWindowVisible(_GLFWwindow* window); |
736 | |
737 | /*! @brief Returns whether the window is maximized. |
738 | * @ingroup platform |
739 | */ |
740 | int _glfwPlatformWindowMaximized(_GLFWwindow* window); |
741 | |
742 | /*! @copydoc glfwPollEvents |
743 | * @ingroup platform |
744 | */ |
745 | void _glfwPlatformPollEvents(void); |
746 | |
747 | /*! @copydoc glfwWaitEvents |
748 | * @ingroup platform |
749 | */ |
750 | void _glfwPlatformWaitEvents(void); |
751 | |
752 | /*! @copydoc glfwWaitEventsTimeout |
753 | * @ingroup platform |
754 | */ |
755 | void _glfwPlatformWaitEventsTimeout(double timeout); |
756 | |
757 | /*! @copydoc glfwPostEmptyEvent |
758 | * @ingroup platform |
759 | */ |
760 | void _glfwPlatformPostEmptyEvent(void); |
761 | |
762 | /*! @ingroup platform |
763 | */ |
764 | void _glfwPlatformSetCurrentContext(_GLFWwindow* context); |
765 | |
766 | /*! @copydoc glfwGetCurrentContext |
767 | * @ingroup platform |
768 | */ |
769 | _GLFWwindow* _glfwPlatformGetCurrentContext(void); |
770 | |
771 | /*! @copydoc glfwCreateCursor |
772 | * @ingroup platform |
773 | */ |
774 | int _glfwPlatformCreateCursor(_GLFWcursor* cursor, const GLFWimage* image, int xhot, int yhot); |
775 | |
776 | /*! @copydoc glfwCreateStandardCursor |
777 | * @ingroup platform |
778 | */ |
779 | int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape); |
780 | |
781 | /*! @copydoc glfwDestroyCursor |
782 | * @ingroup platform |
783 | */ |
784 | void _glfwPlatformDestroyCursor(_GLFWcursor* cursor); |
785 | |
786 | /*! @copydoc glfwSetCursor |
787 | * @ingroup platform |
788 | */ |
789 | void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor); |
790 | |
791 | /*! @ingroup platform |
792 | */ |
793 | char** _glfwPlatformGetRequiredInstanceExtensions(uint32_t* count); |
794 | |
795 | /*! @ingroup platform |
796 | */ |
797 | int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance, VkPhysicalDevice device, uint32_t queuefamily); |
798 | |
799 | /*! @ingroup platform |
800 | */ |
801 | VkResult _glfwPlatformCreateWindowSurface(VkInstance instance, _GLFWwindow* window, const VkAllocationCallbacks* allocator, VkSurfaceKHR* surface); |
802 | |
803 | |
804 | //======================================================================== |
805 | // Event API functions |
806 | //======================================================================== |
807 | |
808 | /*! @brief Notifies shared code of a window focus event. |
809 | * @param[in] window The window that received the event. |
810 | * @param[in] focused `GLFW_TRUE` if the window received focus, or `GLFW_FALSE` |
811 | * if it lost focus. |
812 | * @ingroup event |
813 | */ |
814 | void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused); |
815 | |
816 | /*! @brief Notifies shared code of a window movement event. |
817 | * @param[in] window The window that received the event. |
818 | * @param[in] xpos The new x-coordinate of the client area of the window. |
819 | * @param[in] ypos The new y-coordinate of the client area of the window. |
820 | * @ingroup event |
821 | */ |
822 | void _glfwInputWindowPos(_GLFWwindow* window, int xpos, int ypos); |
823 | |
824 | /*! @brief Notifies shared code of a window resize event. |
825 | * @param[in] window The window that received the event. |
826 | * @param[in] width The new width of the client area of the window. |
827 | * @param[in] height The new height of the client area of the window. |
828 | * @ingroup event |
829 | */ |
830 | void _glfwInputWindowSize(_GLFWwindow* window, int width, int height); |
831 | |
832 | /*! @brief Notifies shared code of a framebuffer resize event. |
833 | * @param[in] window The window that received the event. |
834 | * @param[in] width The new width, in pixels, of the framebuffer. |
835 | * @param[in] height The new height, in pixels, of the framebuffer. |
836 | * @ingroup event |
837 | */ |
838 | void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height); |
839 | |
840 | /*! @brief Notifies shared code of a window iconification event. |
841 | * @param[in] window The window that received the event. |
842 | * @param[in] iconified `GLFW_TRUE` if the window was iconified, or |
843 | * `GLFW_FALSE` if it was restored. |
844 | * @ingroup event |
845 | */ |
846 | void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified); |
847 | |
848 | /*! @brief Notifies shared code of a window damage event. |
849 | * @param[in] window The window that received the event. |
850 | */ |
851 | void _glfwInputWindowDamage(_GLFWwindow* window); |
852 | |
853 | /*! @brief Notifies shared code of a window close request event |
854 | * @param[in] window The window that received the event. |
855 | * @ingroup event |
856 | */ |
857 | void _glfwInputWindowCloseRequest(_GLFWwindow* window); |
858 | |
859 | void _glfwInputWindowMonitorChange(_GLFWwindow* window, _GLFWmonitor* monitor); |
860 | |
861 | /*! @brief Notifies shared code of a physical key event. |
862 | * @param[in] window The window that received the event. |
863 | * @param[in] key The key that was pressed or released. |
864 | * @param[in] scancode The system-specific scan code of the key. |
865 | * @param[in] action @ref GLFW_PRESS or @ref GLFW_RELEASE. |
866 | * @param[in] mods The modifiers pressed when the event was generated. |
867 | * @ingroup event |
868 | */ |
869 | void _glfwInputKey(_GLFWwindow* window, int key, int scancode, int action, int mods); |
870 | |
871 | /*! @brief Notifies shared code of a Unicode character input event. |
872 | * @param[in] window The window that received the event. |
873 | * @param[in] codepoint The Unicode code point of the input character. |
874 | * @param[in] mods Bit field describing which modifier keys were held down. |
875 | * @param[in] plain `GLFW_TRUE` if the character is regular text input, or |
876 | * `GLFW_FALSE` otherwise. |
877 | * @ingroup event |
878 | */ |
879 | void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, GLFWbool plain); |
880 | |
881 | /*! @brief Notifies shared code of a scroll event. |
882 | * @param[in] window The window that received the event. |
883 | * @param[in] xoffset The scroll offset along the x-axis. |
884 | * @param[in] yoffset The scroll offset along the y-axis. |
885 | * @ingroup event |
886 | */ |
887 | void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset); |
888 | |
889 | /*! @brief Notifies shared code of a mouse button click event. |
890 | * @param[in] window The window that received the event. |
891 | * @param[in] button The button that was pressed or released. |
892 | * @param[in] action @ref GLFW_PRESS or @ref GLFW_RELEASE. |
893 | * @ingroup event |
894 | */ |
895 | void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods); |
896 | |
897 | /*! @brief Notifies shared code of a cursor motion event. |
898 | * @param[in] window The window that received the event. |
899 | * @param[in] xpos The new x-coordinate of the cursor, relative to the left |
900 | * edge of the client area of the window. |
901 | * @param[in] ypos The new y-coordinate of the cursor, relative to the top edge |
902 | * of the client area of the window. |
903 | * @ingroup event |
904 | */ |
905 | void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos); |
906 | |
907 | /*! @brief Notifies shared code of a cursor enter/leave event. |
908 | * @param[in] window The window that received the event. |
909 | * @param[in] entered `GLFW_TRUE` if the cursor entered the client area of the |
910 | * window, or `GLFW_FALSE` if it left it. |
911 | * @ingroup event |
912 | */ |
913 | void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered); |
914 | |
915 | /*! @ingroup event |
916 | */ |
917 | void _glfwInputMonitorChange(void); |
918 | |
919 | /*! @ingroup event |
920 | */ |
921 | void _glfwInputMonitorWindowChange(_GLFWmonitor* monitor, _GLFWwindow* window); |
922 | |
923 | /*! @brief Notifies shared code of an error. |
924 | * @param[in] error The error code most suitable for the error. |
925 | * @param[in] format The `printf` style format string of the error |
926 | * description. |
927 | * @ingroup event |
928 | */ |
929 | #if defined(__GNUC__) |
930 | void _glfwInputError(int error, const char* format, ...) __attribute__((format(printf, 2, 3))); |
931 | #else |
932 | void _glfwInputError(int error, const char* format, ...); |
933 | #endif |
934 | |
935 | /*! @brief Notifies dropped object over window. |
936 | * @param[in] window The window that received the event. |
937 | * @param[in] count The number of dropped objects. |
938 | * @param[in] names The names of the dropped objects. |
939 | * @ingroup event |
940 | */ |
941 | void _glfwInputDrop(_GLFWwindow* window, int count, const char** names); |
942 | |
943 | /*! @brief Notifies shared code of a joystick connection/disconnection event. |
944 | * @param[in] joy The joystick that was connected or disconnected. |
945 | * @param[in] event One of `GLFW_CONNECTED` or `GLFW_DISCONNECTED`. |
946 | * @ingroup event |
947 | */ |
948 | void _glfwInputJoystickChange(int joy, int event); |
949 | |
950 | |
951 | //======================================================================== |
952 | // Utility functions |
953 | //======================================================================== |
954 | |
955 | /*! @ingroup utility |
956 | */ |
957 | const GLFWvidmode* _glfwChooseVideoMode(_GLFWmonitor* monitor, |
958 | const GLFWvidmode* desired); |
959 | |
960 | /*! @brief Performs lexical comparison between two @ref GLFWvidmode structures. |
961 | * @ingroup utility |
962 | */ |
963 | int _glfwCompareVideoModes(const GLFWvidmode* first, const GLFWvidmode* second); |
964 | |
965 | /*! @brief Splits a color depth into red, green and blue bit depths. |
966 | * @ingroup utility |
967 | */ |
968 | void _glfwSplitBPP(int bpp, int* red, int* green, int* blue); |
969 | |
970 | /*! @brief Searches an extension string for the specified extension. |
971 | * @param[in] string The extension string to search. |
972 | * @param[in] extensions The extension to search for. |
973 | * @return `GLFW_TRUE` if the extension was found, or `GLFW_FALSE` otherwise. |
974 | * @ingroup utility |
975 | */ |
976 | GLFWbool _glfwStringInExtensionString(const char* string, const char* extensions); |
977 | |
978 | /*! @brief Chooses the framebuffer config that best matches the desired one. |
979 | * @param[in] desired The desired framebuffer config. |
980 | * @param[in] alternatives The framebuffer configs supported by the system. |
981 | * @param[in] count The number of entries in the alternatives array. |
982 | * @return The framebuffer config most closely matching the desired one, or @c |
983 | * NULL if none fulfilled the hard constraints of the desired values. |
984 | * @ingroup utility |
985 | */ |
986 | const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired, |
987 | const _GLFWfbconfig* alternatives, |
988 | unsigned int count); |
989 | |
990 | /*! @brief Retrieves the attributes of the current context. |
991 | * @param[in] ctxconfig The desired context attributes. |
992 | * @return `GLFW_TRUE` if successful, or `GLFW_FALSE` if the context is |
993 | * unusable. |
994 | * @ingroup utility |
995 | */ |
996 | GLFWbool _glfwRefreshContextAttribs(const _GLFWctxconfig* ctxconfig); |
997 | |
998 | /*! @brief Checks whether the desired context attributes are valid. |
999 | * @param[in] ctxconfig The context attributes to check. |
1000 | * @return `GLFW_TRUE` if the context attributes are valid, or `GLFW_FALSE` |
1001 | * otherwise. |
1002 | * @ingroup utility |
1003 | * |
1004 | * This function checks things like whether the specified client API version |
1005 | * exists and whether all relevant options have supported and non-conflicting |
1006 | * values. |
1007 | */ |
1008 | GLFWbool _glfwIsValidContextConfig(const _GLFWctxconfig* ctxconfig); |
1009 | |
1010 | /*! @ingroup utility |
1011 | */ |
1012 | void _glfwAllocGammaArrays(GLFWgammaramp* ramp, unsigned int size); |
1013 | |
1014 | /*! @ingroup utility |
1015 | */ |
1016 | void _glfwFreeGammaArrays(GLFWgammaramp* ramp); |
1017 | |
1018 | /*! @brief Allocates and returns a monitor object with the specified name |
1019 | * and dimensions. |
1020 | * @param[in] name The name of the monitor. |
1021 | * @param[in] widthMM The width, in mm, of the monitor's display area. |
1022 | * @param[in] heightMM The height, in mm, of the monitor's display area. |
1023 | * @return The newly created object. |
1024 | * @ingroup utility |
1025 | */ |
1026 | _GLFWmonitor* _glfwAllocMonitor(const char* name, int widthMM, int heightMM); |
1027 | |
1028 | /*! @brief Frees a monitor object and any data associated with it. |
1029 | * @ingroup utility |
1030 | */ |
1031 | void _glfwFreeMonitor(_GLFWmonitor* monitor); |
1032 | |
1033 | /*! @ingroup utility |
1034 | */ |
1035 | void _glfwFreeMonitors(_GLFWmonitor** monitors, int count); |
1036 | |
1037 | /*! @ingroup utility |
1038 | */ |
1039 | GLFWbool _glfwIsPrintable(int key); |
1040 | |
1041 | /*! @ingroup utility |
1042 | */ |
1043 | void _glfwInitVulkan(void); |
1044 | |
1045 | /*! @ingroup utility |
1046 | */ |
1047 | void _glfwTerminateVulkan(void); |
1048 | |
1049 | /*! @ingroup utility |
1050 | */ |
1051 | const char* _glfwGetVulkanResultString(VkResult result); |
1052 | |
1053 | #endif // _glfw3_internal_h_ |
1054 | |