glfw3.c 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/GLFW/CMakeLists.txt +368 -0
  2. package/GLFW/cocoa_init.m +694 -0
  3. package/GLFW/cocoa_joystick.h +49 -0
  4. package/GLFW/cocoa_joystick.m +485 -0
  5. package/GLFW/cocoa_monitor.m +643 -0
  6. package/GLFW/cocoa_platform.h +302 -0
  7. package/GLFW/cocoa_time.c +57 -0
  8. package/GLFW/cocoa_time.h +35 -0
  9. package/GLFW/cocoa_window.m +2072 -0
  10. package/GLFW/context.c +765 -0
  11. package/GLFW/egl_context.c +911 -0
  12. package/GLFW/glfw.rc.in +30 -0
  13. package/GLFW/glfw3.c +109 -0
  14. package/GLFW/glfw3.h +6564 -0
  15. package/GLFW/glfw3native.h +663 -0
  16. package/GLFW/glx_context.c +719 -0
  17. package/GLFW/init.c +528 -0
  18. package/GLFW/input.c +1505 -0
  19. package/GLFW/internal.h +1022 -0
  20. package/GLFW/linux_joystick.c +436 -0
  21. package/GLFW/linux_joystick.h +64 -0
  22. package/GLFW/mappings.h +1001 -0
  23. package/GLFW/mappings.h.in +82 -0
  24. package/GLFW/monitor.c +548 -0
  25. package/GLFW/nsgl_context.m +384 -0
  26. package/GLFW/null_init.c +264 -0
  27. package/GLFW/null_joystick.c +56 -0
  28. package/GLFW/null_joystick.h +32 -0
  29. package/GLFW/null_monitor.c +160 -0
  30. package/GLFW/null_platform.h +271 -0
  31. package/GLFW/null_window.c +719 -0
  32. package/GLFW/osmesa_context.c +383 -0
  33. package/GLFW/platform.c +214 -0
  34. package/GLFW/platform.h +212 -0
  35. package/GLFW/posix_module.c +53 -0
  36. package/GLFW/posix_poll.c +83 -0
  37. package/GLFW/posix_poll.h +30 -0
  38. package/GLFW/posix_thread.c +107 -0
  39. package/GLFW/posix_thread.h +49 -0
  40. package/GLFW/posix_time.c +65 -0
  41. package/GLFW/posix_time.h +41 -0
  42. package/GLFW/vulkan.c +328 -0
  43. package/GLFW/wgl_context.c +798 -0
  44. package/GLFW/win32_init.c +731 -0
  45. package/GLFW/win32_joystick.c +767 -0
  46. package/GLFW/win32_joystick.h +51 -0
  47. package/GLFW/win32_module.c +51 -0
  48. package/GLFW/win32_monitor.c +569 -0
  49. package/GLFW/win32_platform.h +631 -0
  50. package/GLFW/win32_thread.c +100 -0
  51. package/GLFW/win32_thread.h +53 -0
  52. package/GLFW/win32_time.c +54 -0
  53. package/GLFW/win32_time.h +43 -0
  54. package/GLFW/win32_window.c +2592 -0
  55. package/GLFW/window.c +1172 -0
  56. package/GLFW/wl_init.c +1003 -0
  57. package/GLFW/wl_monitor.c +274 -0
  58. package/GLFW/wl_platform.h +691 -0
  59. package/GLFW/wl_window.c +3308 -0
  60. package/GLFW/x11_init.c +1656 -0
  61. package/GLFW/x11_monitor.c +641 -0
  62. package/GLFW/x11_platform.h +1004 -0
  63. package/GLFW/x11_window.c +3357 -0
  64. package/GLFW/xkb_unicode.c +943 -0
  65. package/GLFW/xkb_unicode.h +30 -0
  66. package/LICENSE +22 -0
  67. package/README.md +236 -0
  68. package/package.json +32 -0
@@ -0,0 +1,100 @@
1
+ //========================================================================
2
+ // GLFW 3.4 Win32 - www.glfw.org
3
+ //------------------------------------------------------------------------
4
+ // Copyright (c) 2002-2006 Marcus Geelnard
5
+ // Copyright (c) 2006-2017 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
+ #if defined(GLFW_BUILD_WIN32_THREAD)
31
+
32
+ #include <assert.h>
33
+
34
+
35
+ //////////////////////////////////////////////////////////////////////////
36
+ ////// GLFW platform API //////
37
+ //////////////////////////////////////////////////////////////////////////
38
+
39
+ GLFWbool _glfwPlatformCreateTls(_GLFWtls* tls)
40
+ {
41
+ assert(tls->win32.allocated == GLFW_FALSE);
42
+
43
+ tls->win32.index = TlsAlloc();
44
+ if (tls->win32.index == TLS_OUT_OF_INDEXES)
45
+ {
46
+ _glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to allocate TLS index");
47
+ return GLFW_FALSE;
48
+ }
49
+
50
+ tls->win32.allocated = GLFW_TRUE;
51
+ return GLFW_TRUE;
52
+ }
53
+
54
+ void _glfwPlatformDestroyTls(_GLFWtls* tls)
55
+ {
56
+ if (tls->win32.allocated)
57
+ TlsFree(tls->win32.index);
58
+ memset(tls, 0, sizeof(_GLFWtls));
59
+ }
60
+
61
+ void* _glfwPlatformGetTls(_GLFWtls* tls)
62
+ {
63
+ assert(tls->win32.allocated == GLFW_TRUE);
64
+ return TlsGetValue(tls->win32.index);
65
+ }
66
+
67
+ void _glfwPlatformSetTls(_GLFWtls* tls, void* value)
68
+ {
69
+ assert(tls->win32.allocated == GLFW_TRUE);
70
+ TlsSetValue(tls->win32.index, value);
71
+ }
72
+
73
+ GLFWbool _glfwPlatformCreateMutex(_GLFWmutex* mutex)
74
+ {
75
+ assert(mutex->win32.allocated == GLFW_FALSE);
76
+ InitializeCriticalSection(&mutex->win32.section);
77
+ return mutex->win32.allocated = GLFW_TRUE;
78
+ }
79
+
80
+ void _glfwPlatformDestroyMutex(_GLFWmutex* mutex)
81
+ {
82
+ if (mutex->win32.allocated)
83
+ DeleteCriticalSection(&mutex->win32.section);
84
+ memset(mutex, 0, sizeof(_GLFWmutex));
85
+ }
86
+
87
+ void _glfwPlatformLockMutex(_GLFWmutex* mutex)
88
+ {
89
+ assert(mutex->win32.allocated == GLFW_TRUE);
90
+ EnterCriticalSection(&mutex->win32.section);
91
+ }
92
+
93
+ void _glfwPlatformUnlockMutex(_GLFWmutex* mutex)
94
+ {
95
+ assert(mutex->win32.allocated == GLFW_TRUE);
96
+ LeaveCriticalSection(&mutex->win32.section);
97
+ }
98
+
99
+ #endif // GLFW_BUILD_WIN32_THREAD
100
+
@@ -0,0 +1,53 @@
1
+ //========================================================================
2
+ // GLFW 3.4 Win32 - www.glfw.org
3
+ //------------------------------------------------------------------------
4
+ // Copyright (c) 2002-2006 Marcus Geelnard
5
+ // Copyright (c) 2006-2017 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
+ #pragma once
28
+
29
+ // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
30
+ // example to allow applications to correctly declare a GL_KHR_debug callback)
31
+ // but windows.h assumes no one will define APIENTRY before it does
32
+ #undef APIENTRY
33
+
34
+ #include <windows.h>
35
+
36
+ #define GLFW_WIN32_TLS_STATE _GLFWtlsWin32 win32;
37
+ #define GLFW_WIN32_MUTEX_STATE _GLFWmutexWin32 win32;
38
+
39
+ // Win32-specific thread local storage data
40
+ //
41
+ typedef struct _GLFWtlsWin32
42
+ {
43
+ GLFWbool allocated;
44
+ DWORD index;
45
+ } _GLFWtlsWin32;
46
+
47
+ // Win32-specific mutex data
48
+ //
49
+ typedef struct _GLFWmutexWin32
50
+ {
51
+ GLFWbool allocated;
52
+ CRITICAL_SECTION section;
53
+ } _GLFWmutexWin32;
@@ -0,0 +1,54 @@
1
+ //========================================================================
2
+ // GLFW 3.4 Win32 - www.glfw.org
3
+ //------------------------------------------------------------------------
4
+ // Copyright (c) 2002-2006 Marcus Geelnard
5
+ // Copyright (c) 2006-2017 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
+ #if defined(GLFW_BUILD_WIN32_TIMER)
31
+
32
+ //////////////////////////////////////////////////////////////////////////
33
+ ////// GLFW platform API //////
34
+ //////////////////////////////////////////////////////////////////////////
35
+
36
+ void _glfwPlatformInitTimer(void)
37
+ {
38
+ QueryPerformanceFrequency((LARGE_INTEGER*) &_glfw.timer.win32.frequency);
39
+ }
40
+
41
+ uint64_t _glfwPlatformGetTimerValue(void)
42
+ {
43
+ uint64_t value;
44
+ QueryPerformanceCounter((LARGE_INTEGER*) &value);
45
+ return value;
46
+ }
47
+
48
+ uint64_t _glfwPlatformGetTimerFrequency(void)
49
+ {
50
+ return _glfw.timer.win32.frequency;
51
+ }
52
+
53
+ #endif // GLFW_BUILD_WIN32_TIMER
54
+
@@ -0,0 +1,43 @@
1
+ //========================================================================
2
+ // GLFW 3.4 Win32 - www.glfw.org
3
+ //------------------------------------------------------------------------
4
+ // Copyright (c) 2002-2006 Marcus Geelnard
5
+ // Copyright (c) 2006-2017 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
+ #pragma once
28
+
29
+ // This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
30
+ // example to allow applications to correctly declare a GL_KHR_debug callback)
31
+ // but windows.h assumes no one will define APIENTRY before it does
32
+ #undef APIENTRY
33
+
34
+ #include <windows.h>
35
+
36
+ #define GLFW_WIN32_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32;
37
+
38
+ // Win32-specific global timer data
39
+ //
40
+ typedef struct _GLFWtimerWin32
41
+ {
42
+ uint64_t frequency;
43
+ } _GLFWtimerWin32;