• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //========================================================================
2 // GLFW 3.5 - www.glfw.org
3 //------------------------------------------------------------------------
4 // Copyright (c) 2016 Google Inc.
5 // Copyright (c) 2016-2019 Camilla Löwy <elmindreda@glfw.org>
6 //
7 // This software is provided 'as-is', without any express or implied
8 // warranty. In no event will the authors be held liable for any damages
9 // arising from the use of this software.
10 //
11 // Permission is granted to anyone to use this software for any purpose,
12 // including commercial applications, and to alter it and redistribute it
13 // freely, subject to the following restrictions:
14 //
15 // 1. The origin of this software must not be misrepresented; you must not
16 //    claim that you wrote the original software. If you use this software
17 //    in a product, an acknowledgment in the product documentation would
18 //    be appreciated but is not required.
19 //
20 // 2. Altered source versions must be plainly marked as such, and must not
21 //    be misrepresented as being the original software.
22 //
23 // 3. This notice may not be removed or altered from any source
24 //    distribution.
25 //
26 //========================================================================
27 
28 #include "internal.h"
29 
30 #include <stdlib.h>
31 #include <string.h>
32 
applySizeLimits(_GLFWwindow * window,int * width,int * height)33 static void applySizeLimits(_GLFWwindow* window, int* width, int* height)
34 {
35     if (window->numer != GLFW_DONT_CARE && window->denom != GLFW_DONT_CARE)
36     {
37         const float ratio = (float) window->numer / (float) window->denom;
38         *height = (int) (*width / ratio);
39     }
40 
41     if (window->minwidth != GLFW_DONT_CARE)
42         *width = _glfw_max(*width, window->minwidth);
43     else if (window->maxwidth != GLFW_DONT_CARE)
44         *width = _glfw_min(*width, window->maxwidth);
45 
46     if (window->minheight != GLFW_DONT_CARE)
47         *height = _glfw_min(*height, window->minheight);
48     else if (window->maxheight != GLFW_DONT_CARE)
49         *height = _glfw_max(*height, window->maxheight);
50 }
51 
fitToMonitor(_GLFWwindow * window)52 static void fitToMonitor(_GLFWwindow* window)
53 {
54     GLFWvidmode mode;
55     _glfwGetVideoModeNull(window->monitor, &mode);
56     _glfwGetMonitorPosNull(window->monitor,
57                            &window->null.xpos,
58                            &window->null.ypos);
59     window->null.width = mode.width;
60     window->null.height = mode.height;
61 }
62 
acquireMonitor(_GLFWwindow * window)63 static void acquireMonitor(_GLFWwindow* window)
64 {
65     _glfwInputMonitorWindow(window->monitor, window);
66 }
67 
releaseMonitor(_GLFWwindow * window)68 static void releaseMonitor(_GLFWwindow* window)
69 {
70     if (window->monitor->window != window)
71         return;
72 
73     _glfwInputMonitorWindow(window->monitor, NULL);
74 }
75 
createNativeWindow(_GLFWwindow * window,const _GLFWwndconfig * wndconfig,const _GLFWfbconfig * fbconfig)76 static int createNativeWindow(_GLFWwindow* window,
77                               const _GLFWwndconfig* wndconfig,
78                               const _GLFWfbconfig* fbconfig)
79 {
80     if (window->monitor)
81         fitToMonitor(window);
82     else
83     {
84         if (wndconfig->xpos == GLFW_ANY_POSITION && wndconfig->ypos == GLFW_ANY_POSITION)
85         {
86             window->null.xpos = 17;
87             window->null.ypos = 17;
88         }
89         else
90         {
91             window->null.xpos = wndconfig->xpos;
92             window->null.ypos = wndconfig->ypos;
93         }
94 
95         window->null.width = wndconfig->width;
96         window->null.height = wndconfig->height;
97     }
98 
99     window->null.visible = wndconfig->visible;
100     window->null.decorated = wndconfig->decorated;
101     window->null.maximized = wndconfig->maximized;
102     window->null.floating = wndconfig->floating;
103     window->null.transparent = fbconfig->transparent;
104     window->null.opacity = 1.f;
105 
106     return GLFW_TRUE;
107 }
108 
109 
110 //////////////////////////////////////////////////////////////////////////
111 //////                       GLFW platform API                      //////
112 //////////////////////////////////////////////////////////////////////////
113 
_glfwCreateWindowNull(_GLFWwindow * window,const _GLFWwndconfig * wndconfig,const _GLFWctxconfig * ctxconfig,const _GLFWfbconfig * fbconfig)114 GLFWbool _glfwCreateWindowNull(_GLFWwindow* window,
115                                const _GLFWwndconfig* wndconfig,
116                                const _GLFWctxconfig* ctxconfig,
117                                const _GLFWfbconfig* fbconfig)
118 {
119     if (!createNativeWindow(window, wndconfig, fbconfig))
120         return GLFW_FALSE;
121 
122     if (ctxconfig->client != GLFW_NO_API)
123     {
124         if (ctxconfig->source == GLFW_NATIVE_CONTEXT_API ||
125             ctxconfig->source == GLFW_OSMESA_CONTEXT_API)
126         {
127             if (!_glfwInitOSMesa())
128                 return GLFW_FALSE;
129             if (!_glfwCreateContextOSMesa(window, ctxconfig, fbconfig))
130                 return GLFW_FALSE;
131         }
132         else if (ctxconfig->source == GLFW_EGL_CONTEXT_API)
133         {
134             if (!_glfwInitEGL())
135                 return GLFW_FALSE;
136             if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
137                 return GLFW_FALSE;
138         }
139 
140         if (!_glfwRefreshContextAttribs(window, ctxconfig))
141             return GLFW_FALSE;
142     }
143 
144     if (wndconfig->mousePassthrough)
145         _glfwSetWindowMousePassthroughNull(window, GLFW_TRUE);
146 
147     if (window->monitor)
148     {
149         _glfwShowWindowNull(window);
150         _glfwFocusWindowNull(window);
151         acquireMonitor(window);
152 
153         if (wndconfig->centerCursor)
154             _glfwCenterCursorInContentArea(window);
155     }
156     else
157     {
158         if (wndconfig->visible)
159         {
160             _glfwShowWindowNull(window);
161             if (wndconfig->focused)
162                 _glfwFocusWindowNull(window);
163         }
164     }
165 
166     return GLFW_TRUE;
167 }
168 
_glfwDestroyWindowNull(_GLFWwindow * window)169 void _glfwDestroyWindowNull(_GLFWwindow* window)
170 {
171     if (window->monitor)
172         releaseMonitor(window);
173 
174     if (_glfw.null.focusedWindow == window)
175         _glfw.null.focusedWindow = NULL;
176 
177     if (window->context.destroy)
178         window->context.destroy(window);
179 }
180 
_glfwSetWindowTitleNull(_GLFWwindow * window,const char * title)181 void _glfwSetWindowTitleNull(_GLFWwindow* window, const char* title)
182 {
183 }
184 
_glfwSetWindowIconNull(_GLFWwindow * window,int count,const GLFWimage * images)185 void _glfwSetWindowIconNull(_GLFWwindow* window, int count, const GLFWimage* images)
186 {
187 }
188 
_glfwSetWindowMonitorNull(_GLFWwindow * window,_GLFWmonitor * monitor,int xpos,int ypos,int width,int height,int refreshRate)189 void _glfwSetWindowMonitorNull(_GLFWwindow* window,
190                                _GLFWmonitor* monitor,
191                                int xpos, int ypos,
192                                int width, int height,
193                                int refreshRate)
194 {
195     if (window->monitor == monitor)
196     {
197         if (!monitor)
198         {
199             _glfwSetWindowPosNull(window, xpos, ypos);
200             _glfwSetWindowSizeNull(window, width, height);
201         }
202 
203         return;
204     }
205 
206     if (window->monitor)
207         releaseMonitor(window);
208 
209     _glfwInputWindowMonitor(window, monitor);
210 
211     if (window->monitor)
212     {
213         window->null.visible = GLFW_TRUE;
214         acquireMonitor(window);
215         fitToMonitor(window);
216     }
217     else
218     {
219         _glfwSetWindowPosNull(window, xpos, ypos);
220         _glfwSetWindowSizeNull(window, width, height);
221     }
222 }
223 
_glfwGetWindowPosNull(_GLFWwindow * window,int * xpos,int * ypos)224 void _glfwGetWindowPosNull(_GLFWwindow* window, int* xpos, int* ypos)
225 {
226     if (xpos)
227         *xpos = window->null.xpos;
228     if (ypos)
229         *ypos = window->null.ypos;
230 }
231 
_glfwSetWindowPosNull(_GLFWwindow * window,int xpos,int ypos)232 void _glfwSetWindowPosNull(_GLFWwindow* window, int xpos, int ypos)
233 {
234     if (window->monitor)
235         return;
236 
237     if (window->null.xpos != xpos || window->null.ypos != ypos)
238     {
239         window->null.xpos = xpos;
240         window->null.ypos = ypos;
241         _glfwInputWindowPos(window, xpos, ypos);
242     }
243 }
244 
_glfwGetWindowSizeNull(_GLFWwindow * window,int * width,int * height)245 void _glfwGetWindowSizeNull(_GLFWwindow* window, int* width, int* height)
246 {
247     if (width)
248         *width = window->null.width;
249     if (height)
250         *height = window->null.height;
251 }
252 
_glfwSetWindowSizeNull(_GLFWwindow * window,int width,int height)253 void _glfwSetWindowSizeNull(_GLFWwindow* window, int width, int height)
254 {
255     if (window->monitor)
256         return;
257 
258     if (window->null.width != width || window->null.height != height)
259     {
260         window->null.width = width;
261         window->null.height = height;
262         _glfwInputFramebufferSize(window, width, height);
263         _glfwInputWindowDamage(window);
264         _glfwInputWindowSize(window, width, height);
265     }
266 }
267 
_glfwSetWindowSizeLimitsNull(_GLFWwindow * window,int minwidth,int minheight,int maxwidth,int maxheight)268 void _glfwSetWindowSizeLimitsNull(_GLFWwindow* window,
269                                   int minwidth, int minheight,
270                                   int maxwidth, int maxheight)
271 {
272     int width = window->null.width;
273     int height = window->null.height;
274     applySizeLimits(window, &width, &height);
275     _glfwSetWindowSizeNull(window, width, height);
276 }
277 
_glfwSetWindowAspectRatioNull(_GLFWwindow * window,int n,int d)278 void _glfwSetWindowAspectRatioNull(_GLFWwindow* window, int n, int d)
279 {
280     int width = window->null.width;
281     int height = window->null.height;
282     applySizeLimits(window, &width, &height);
283     _glfwSetWindowSizeNull(window, width, height);
284 }
285 
_glfwGetFramebufferSizeNull(_GLFWwindow * window,int * width,int * height)286 void _glfwGetFramebufferSizeNull(_GLFWwindow* window, int* width, int* height)
287 {
288     if (width)
289         *width = window->null.width;
290     if (height)
291         *height = window->null.height;
292 }
293 
_glfwGetWindowFrameSizeNull(_GLFWwindow * window,int * left,int * top,int * right,int * bottom)294 void _glfwGetWindowFrameSizeNull(_GLFWwindow* window,
295                                  int* left, int* top,
296                                  int* right, int* bottom)
297 {
298     if (window->null.decorated && !window->monitor)
299     {
300         if (left)
301             *left = 1;
302         if (top)
303             *top = 10;
304         if (right)
305             *right = 1;
306         if (bottom)
307             *bottom = 1;
308     }
309     else
310     {
311         if (left)
312             *left = 0;
313         if (top)
314             *top = 0;
315         if (right)
316             *right = 0;
317         if (bottom)
318             *bottom = 0;
319     }
320 }
321 
_glfwGetWindowContentScaleNull(_GLFWwindow * window,float * xscale,float * yscale)322 void _glfwGetWindowContentScaleNull(_GLFWwindow* window, float* xscale, float* yscale)
323 {
324     if (xscale)
325         *xscale = 1.f;
326     if (yscale)
327         *yscale = 1.f;
328 }
329 
_glfwIconifyWindowNull(_GLFWwindow * window)330 void _glfwIconifyWindowNull(_GLFWwindow* window)
331 {
332     if (_glfw.null.focusedWindow == window)
333     {
334         _glfw.null.focusedWindow = NULL;
335         _glfwInputWindowFocus(window, GLFW_FALSE);
336     }
337 
338     if (!window->null.iconified)
339     {
340         window->null.iconified = GLFW_TRUE;
341         _glfwInputWindowIconify(window, GLFW_TRUE);
342 
343         if (window->monitor)
344             releaseMonitor(window);
345     }
346 }
347 
_glfwRestoreWindowNull(_GLFWwindow * window)348 void _glfwRestoreWindowNull(_GLFWwindow* window)
349 {
350     if (window->null.iconified)
351     {
352         window->null.iconified = GLFW_FALSE;
353         _glfwInputWindowIconify(window, GLFW_FALSE);
354 
355         if (window->monitor)
356             acquireMonitor(window);
357     }
358     else if (window->null.maximized)
359     {
360         window->null.maximized = GLFW_FALSE;
361         _glfwInputWindowMaximize(window, GLFW_FALSE);
362     }
363 }
364 
_glfwMaximizeWindowNull(_GLFWwindow * window)365 void _glfwMaximizeWindowNull(_GLFWwindow* window)
366 {
367     if (!window->null.maximized)
368     {
369         window->null.maximized = GLFW_TRUE;
370         _glfwInputWindowMaximize(window, GLFW_TRUE);
371     }
372 }
373 
_glfwWindowMaximizedNull(_GLFWwindow * window)374 GLFWbool _glfwWindowMaximizedNull(_GLFWwindow* window)
375 {
376     return window->null.maximized;
377 }
378 
_glfwWindowHoveredNull(_GLFWwindow * window)379 GLFWbool _glfwWindowHoveredNull(_GLFWwindow* window)
380 {
381     return _glfw.null.xcursor >= window->null.xpos &&
382            _glfw.null.ycursor >= window->null.ypos &&
383            _glfw.null.xcursor <= window->null.xpos + window->null.width - 1 &&
384            _glfw.null.ycursor <= window->null.ypos + window->null.height - 1;
385 }
386 
_glfwFramebufferTransparentNull(_GLFWwindow * window)387 GLFWbool _glfwFramebufferTransparentNull(_GLFWwindow* window)
388 {
389     return window->null.transparent;
390 }
391 
_glfwSetWindowResizableNull(_GLFWwindow * window,GLFWbool enabled)392 void _glfwSetWindowResizableNull(_GLFWwindow* window, GLFWbool enabled)
393 {
394     window->null.resizable = enabled;
395 }
396 
_glfwSetWindowDecoratedNull(_GLFWwindow * window,GLFWbool enabled)397 void _glfwSetWindowDecoratedNull(_GLFWwindow* window, GLFWbool enabled)
398 {
399     window->null.decorated = enabled;
400 }
401 
_glfwSetWindowFloatingNull(_GLFWwindow * window,GLFWbool enabled)402 void _glfwSetWindowFloatingNull(_GLFWwindow* window, GLFWbool enabled)
403 {
404     window->null.floating = enabled;
405 }
406 
_glfwSetWindowMousePassthroughNull(_GLFWwindow * window,GLFWbool enabled)407 void _glfwSetWindowMousePassthroughNull(_GLFWwindow* window, GLFWbool enabled)
408 {
409 }
410 
_glfwGetWindowOpacityNull(_GLFWwindow * window)411 float _glfwGetWindowOpacityNull(_GLFWwindow* window)
412 {
413     return window->null.opacity;
414 }
415 
_glfwSetWindowOpacityNull(_GLFWwindow * window,float opacity)416 void _glfwSetWindowOpacityNull(_GLFWwindow* window, float opacity)
417 {
418     window->null.opacity = opacity;
419 }
420 
_glfwSetRawMouseMotionNull(_GLFWwindow * window,GLFWbool enabled)421 void _glfwSetRawMouseMotionNull(_GLFWwindow *window, GLFWbool enabled)
422 {
423 }
424 
_glfwRawMouseMotionSupportedNull(void)425 GLFWbool _glfwRawMouseMotionSupportedNull(void)
426 {
427     return GLFW_TRUE;
428 }
429 
_glfwShowWindowNull(_GLFWwindow * window)430 void _glfwShowWindowNull(_GLFWwindow* window)
431 {
432     window->null.visible = GLFW_TRUE;
433 }
434 
_glfwRequestWindowAttentionNull(_GLFWwindow * window)435 void _glfwRequestWindowAttentionNull(_GLFWwindow* window)
436 {
437 }
438 
_glfwHideWindowNull(_GLFWwindow * window)439 void _glfwHideWindowNull(_GLFWwindow* window)
440 {
441     if (_glfw.null.focusedWindow == window)
442     {
443         _glfw.null.focusedWindow = NULL;
444         _glfwInputWindowFocus(window, GLFW_FALSE);
445     }
446 
447     window->null.visible = GLFW_FALSE;
448 }
449 
_glfwFocusWindowNull(_GLFWwindow * window)450 void _glfwFocusWindowNull(_GLFWwindow* window)
451 {
452     _GLFWwindow* previous;
453 
454     if (_glfw.null.focusedWindow == window)
455         return;
456 
457     if (!window->null.visible)
458         return;
459 
460     previous = _glfw.null.focusedWindow;
461     _glfw.null.focusedWindow = window;
462 
463     if (previous)
464     {
465         _glfwInputWindowFocus(previous, GLFW_FALSE);
466         if (previous->monitor && previous->autoIconify)
467             _glfwIconifyWindowNull(previous);
468     }
469 
470     _glfwInputWindowFocus(window, GLFW_TRUE);
471 }
472 
_glfwWindowFocusedNull(_GLFWwindow * window)473 GLFWbool _glfwWindowFocusedNull(_GLFWwindow* window)
474 {
475     return _glfw.null.focusedWindow == window;
476 }
477 
_glfwWindowIconifiedNull(_GLFWwindow * window)478 GLFWbool _glfwWindowIconifiedNull(_GLFWwindow* window)
479 {
480     return window->null.iconified;
481 }
482 
_glfwWindowVisibleNull(_GLFWwindow * window)483 GLFWbool _glfwWindowVisibleNull(_GLFWwindow* window)
484 {
485     return window->null.visible;
486 }
487 
_glfwPollEventsNull(void)488 void _glfwPollEventsNull(void)
489 {
490 }
491 
_glfwWaitEventsNull(void)492 void _glfwWaitEventsNull(void)
493 {
494 }
495 
_glfwWaitEventsTimeoutNull(double timeout)496 void _glfwWaitEventsTimeoutNull(double timeout)
497 {
498 }
499 
_glfwPostEmptyEventNull(void)500 void _glfwPostEmptyEventNull(void)
501 {
502 }
503 
_glfwGetCursorPosNull(_GLFWwindow * window,double * xpos,double * ypos)504 void _glfwGetCursorPosNull(_GLFWwindow* window, double* xpos, double* ypos)
505 {
506     if (xpos)
507         *xpos = _glfw.null.xcursor - window->null.xpos;
508     if (ypos)
509         *ypos = _glfw.null.ycursor - window->null.ypos;
510 }
511 
_glfwSetCursorPosNull(_GLFWwindow * window,double x,double y)512 void _glfwSetCursorPosNull(_GLFWwindow* window, double x, double y)
513 {
514     _glfw.null.xcursor = window->null.xpos + (int) x;
515     _glfw.null.ycursor = window->null.ypos + (int) y;
516 }
517 
_glfwSetCursorModeNull(_GLFWwindow * window,int mode)518 void _glfwSetCursorModeNull(_GLFWwindow* window, int mode)
519 {
520 }
521 
_glfwCreateCursorNull(_GLFWcursor * cursor,const GLFWimage * image,int xhot,int yhot)522 GLFWbool _glfwCreateCursorNull(_GLFWcursor* cursor,
523                                const GLFWimage* image,
524                                int xhot, int yhot)
525 {
526     return GLFW_TRUE;
527 }
528 
_glfwCreateStandardCursorNull(_GLFWcursor * cursor,int shape)529 GLFWbool _glfwCreateStandardCursorNull(_GLFWcursor* cursor, int shape)
530 {
531     return GLFW_TRUE;
532 }
533 
_glfwDestroyCursorNull(_GLFWcursor * cursor)534 void _glfwDestroyCursorNull(_GLFWcursor* cursor)
535 {
536 }
537 
_glfwSetCursorNull(_GLFWwindow * window,_GLFWcursor * cursor)538 void _glfwSetCursorNull(_GLFWwindow* window, _GLFWcursor* cursor)
539 {
540 }
541 
_glfwSetClipboardStringNull(const char * string)542 void _glfwSetClipboardStringNull(const char* string)
543 {
544     char* copy = _glfw_strdup(string);
545     _glfw_free(_glfw.null.clipboardString);
546     _glfw.null.clipboardString = copy;
547 }
548 
_glfwGetClipboardStringNull(void)549 const char* _glfwGetClipboardStringNull(void)
550 {
551     return _glfw.null.clipboardString;
552 }
553 
_glfwGetEGLPlatformNull(EGLint ** attribs)554 EGLenum _glfwGetEGLPlatformNull(EGLint** attribs)
555 {
556     if (_glfw.egl.EXT_platform_base && _glfw.egl.MESA_platform_surfaceless)
557         return EGL_PLATFORM_SURFACELESS_MESA;
558     else
559         return 0;
560 }
561 
_glfwGetEGLNativeDisplayNull(void)562 EGLNativeDisplayType _glfwGetEGLNativeDisplayNull(void)
563 {
564     return EGL_DEFAULT_DISPLAY;
565 }
566 
_glfwGetEGLNativeWindowNull(_GLFWwindow * window)567 EGLNativeWindowType _glfwGetEGLNativeWindowNull(_GLFWwindow* window)
568 {
569     return 0;
570 }
571 
_glfwGetScancodeNameNull(int scancode)572 const char* _glfwGetScancodeNameNull(int scancode)
573 {
574     if (scancode < GLFW_NULL_SC_FIRST || scancode > GLFW_NULL_SC_LAST)
575     {
576         _glfwInputError(GLFW_INVALID_VALUE, "Invalid scancode %i", scancode);
577         return NULL;
578     }
579 
580     switch (scancode)
581     {
582         case GLFW_NULL_SC_APOSTROPHE:
583             return "'";
584         case GLFW_NULL_SC_COMMA:
585             return ",";
586         case GLFW_NULL_SC_MINUS:
587         case GLFW_NULL_SC_KP_SUBTRACT:
588             return "-";
589         case GLFW_NULL_SC_PERIOD:
590         case GLFW_NULL_SC_KP_DECIMAL:
591             return ".";
592         case GLFW_NULL_SC_SLASH:
593         case GLFW_NULL_SC_KP_DIVIDE:
594             return "/";
595         case GLFW_NULL_SC_SEMICOLON:
596             return ";";
597         case GLFW_NULL_SC_EQUAL:
598         case GLFW_NULL_SC_KP_EQUAL:
599             return "=";
600         case GLFW_NULL_SC_LEFT_BRACKET:
601             return "[";
602         case GLFW_NULL_SC_RIGHT_BRACKET:
603             return "]";
604         case GLFW_NULL_SC_KP_MULTIPLY:
605             return "*";
606         case GLFW_NULL_SC_KP_ADD:
607             return "+";
608         case GLFW_NULL_SC_BACKSLASH:
609         case GLFW_NULL_SC_WORLD_1:
610         case GLFW_NULL_SC_WORLD_2:
611             return "\\";
612         case GLFW_NULL_SC_0:
613         case GLFW_NULL_SC_KP_0:
614             return "0";
615         case GLFW_NULL_SC_1:
616         case GLFW_NULL_SC_KP_1:
617             return "1";
618         case GLFW_NULL_SC_2:
619         case GLFW_NULL_SC_KP_2:
620             return "2";
621         case GLFW_NULL_SC_3:
622         case GLFW_NULL_SC_KP_3:
623             return "3";
624         case GLFW_NULL_SC_4:
625         case GLFW_NULL_SC_KP_4:
626             return "4";
627         case GLFW_NULL_SC_5:
628         case GLFW_NULL_SC_KP_5:
629             return "5";
630         case GLFW_NULL_SC_6:
631         case GLFW_NULL_SC_KP_6:
632             return "6";
633         case GLFW_NULL_SC_7:
634         case GLFW_NULL_SC_KP_7:
635             return "7";
636         case GLFW_NULL_SC_8:
637         case GLFW_NULL_SC_KP_8:
638             return "8";
639         case GLFW_NULL_SC_9:
640         case GLFW_NULL_SC_KP_9:
641             return "9";
642         case GLFW_NULL_SC_A:
643             return "a";
644         case GLFW_NULL_SC_B:
645             return "b";
646         case GLFW_NULL_SC_C:
647             return "c";
648         case GLFW_NULL_SC_D:
649             return "d";
650         case GLFW_NULL_SC_E:
651             return "e";
652         case GLFW_NULL_SC_F:
653             return "f";
654         case GLFW_NULL_SC_G:
655             return "g";
656         case GLFW_NULL_SC_H:
657             return "h";
658         case GLFW_NULL_SC_I:
659             return "i";
660         case GLFW_NULL_SC_J:
661             return "j";
662         case GLFW_NULL_SC_K:
663             return "k";
664         case GLFW_NULL_SC_L:
665             return "l";
666         case GLFW_NULL_SC_M:
667             return "m";
668         case GLFW_NULL_SC_N:
669             return "n";
670         case GLFW_NULL_SC_O:
671             return "o";
672         case GLFW_NULL_SC_P:
673             return "p";
674         case GLFW_NULL_SC_Q:
675             return "q";
676         case GLFW_NULL_SC_R:
677             return "r";
678         case GLFW_NULL_SC_S:
679             return "s";
680         case GLFW_NULL_SC_T:
681             return "t";
682         case GLFW_NULL_SC_U:
683             return "u";
684         case GLFW_NULL_SC_V:
685             return "v";
686         case GLFW_NULL_SC_W:
687             return "w";
688         case GLFW_NULL_SC_X:
689             return "x";
690         case GLFW_NULL_SC_Y:
691             return "y";
692         case GLFW_NULL_SC_Z:
693             return "z";
694     }
695 
696     return NULL;
697 }
698 
_glfwGetKeyScancodeNull(int key)699 int _glfwGetKeyScancodeNull(int key)
700 {
701     return _glfw.null.scancodes[key];
702 }
703 
_glfwGetRequiredInstanceExtensionsNull(char ** extensions)704 void _glfwGetRequiredInstanceExtensionsNull(char** extensions)
705 {
706     if (!_glfw.vk.KHR_surface || !_glfw.vk.EXT_headless_surface)
707         return;
708 
709     extensions[0] = "VK_KHR_surface";
710     extensions[1] = "VK_EXT_headless_surface";
711 }
712 
_glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,VkPhysicalDevice device,uint32_t queuefamily)713 GLFWbool _glfwGetPhysicalDevicePresentationSupportNull(VkInstance instance,
714                                                        VkPhysicalDevice device,
715                                                        uint32_t queuefamily)
716 {
717     return GLFW_TRUE;
718 }
719 
_glfwCreateWindowSurfaceNull(VkInstance instance,_GLFWwindow * window,const VkAllocationCallbacks * allocator,VkSurfaceKHR * surface)720 VkResult _glfwCreateWindowSurfaceNull(VkInstance instance,
721                                       _GLFWwindow* window,
722                                       const VkAllocationCallbacks* allocator,
723                                       VkSurfaceKHR* surface)
724 {
725     PFN_vkCreateHeadlessSurfaceEXT vkCreateHeadlessSurfaceEXT =
726         (PFN_vkCreateHeadlessSurfaceEXT)
727         vkGetInstanceProcAddr(instance, "vkCreateHeadlessSurfaceEXT");
728     if (!vkCreateHeadlessSurfaceEXT)
729     {
730         _glfwInputError(GLFW_API_UNAVAILABLE,
731                         "Null: Vulkan instance missing VK_EXT_headless_surface extension");
732         return VK_ERROR_EXTENSION_NOT_PRESENT;
733     }
734 
735     VkHeadlessSurfaceCreateInfoEXT sci;
736     memset(&sci, 0, sizeof(sci));
737     sci.sType = VK_STRUCTURE_TYPE_HEADLESS_SURFACE_CREATE_INFO_EXT;
738 
739     const VkResult err = vkCreateHeadlessSurfaceEXT(instance, &sci, allocator, surface);
740     if (err)
741     {
742         _glfwInputError(GLFW_PLATFORM_ERROR,
743                         "Null: Failed to create Vulkan surface: %s",
744                         _glfwGetVulkanResultString(err));
745     }
746 
747     return err;
748 }
749 
750