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