Wise&mystical  1.0
Project about Europe
Loading...
Searching...
No Matches
win32_platform.h
Go to the documentation of this file.
1//========================================================================
2// GLFW 3.4 Win32 - www.glfw.org
3//------------------------------------------------------------------------
4// Copyright (c) 2002-2006 Marcus Geelnard
5// Copyright (c) 2006-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// We don't need all the fancy stuff
29#ifndef NOMINMAX
30 #define NOMINMAX
31#endif
32
33#ifndef VC_EXTRALEAN
34 #define VC_EXTRALEAN
35#endif
36
37#ifndef WIN32_LEAN_AND_MEAN
38 #define WIN32_LEAN_AND_MEAN
39#endif
40
41// This is a workaround for the fact that glfw3.h needs to export APIENTRY (for
42// example to allow applications to correctly declare a GL_KHR_debug callback)
43// but windows.h assumes no one will define APIENTRY before it does
44#undef APIENTRY
45
46// GLFW on Windows is Unicode only and does not work in MBCS mode
47#ifndef UNICODE
48 #define UNICODE
49#endif
50
51// GLFW requires Windows XP or later
52#if WINVER < 0x0501
53 #undef WINVER
54 #define WINVER 0x0501
55#endif
56#if _WIN32_WINNT < 0x0501
57 #undef _WIN32_WINNT
58 #define _WIN32_WINNT 0x0501
59#endif
60
61// GLFW uses DirectInput8 interfaces
62#define DIRECTINPUT_VERSION 0x0800
63
64// GLFW uses OEM cursor resources
65#define OEMRESOURCE
66
67#include <wctype.h>
68#include <windows.h>
69#include <dinput.h>
70#include <xinput.h>
71#include <dbt.h>
72
73// HACK: Define macros that some windows.h variants don't
74#ifndef WM_MOUSEHWHEEL
75 #define WM_MOUSEHWHEEL 0x020E
76#endif
77#ifndef WM_DWMCOMPOSITIONCHANGED
78 #define WM_DWMCOMPOSITIONCHANGED 0x031E
79#endif
80#ifndef WM_DWMCOLORIZATIONCOLORCHANGED
81 #define WM_DWMCOLORIZATIONCOLORCHANGED 0x0320
82#endif
83#ifndef WM_COPYGLOBALDATA
84 #define WM_COPYGLOBALDATA 0x0049
85#endif
86#ifndef WM_UNICHAR
87 #define WM_UNICHAR 0x0109
88#endif
89#ifndef UNICODE_NOCHAR
90 #define UNICODE_NOCHAR 0xFFFF
91#endif
92#ifndef WM_DPICHANGED
93 #define WM_DPICHANGED 0x02E0
94#endif
95#ifndef GET_XBUTTON_WPARAM
96 #define GET_XBUTTON_WPARAM(w) (HIWORD(w))
97#endif
98#ifndef EDS_ROTATEDMODE
99 #define EDS_ROTATEDMODE 0x00000004
100#endif
101#ifndef DISPLAY_DEVICE_ACTIVE
102 #define DISPLAY_DEVICE_ACTIVE 0x00000001
103#endif
104#ifndef _WIN32_WINNT_WINBLUE
105 #define _WIN32_WINNT_WINBLUE 0x0603
106#endif
107#ifndef _WIN32_WINNT_WIN8
108 #define _WIN32_WINNT_WIN8 0x0602
109#endif
110#ifndef WM_GETDPISCALEDSIZE
111 #define WM_GETDPISCALEDSIZE 0x02e4
112#endif
113#ifndef USER_DEFAULT_SCREEN_DPI
114 #define USER_DEFAULT_SCREEN_DPI 96
115#endif
116#ifndef OCR_HAND
117 #define OCR_HAND 32649
118#endif
119
120#if WINVER < 0x0601
121typedef struct
122{
123 DWORD cbSize;
126#ifndef MSGFLT_ALLOW
127 #define MSGFLT_ALLOW 1
128#endif
129#endif /*Windows 7*/
130
131#if WINVER < 0x0600
132#define DWM_BB_ENABLE 0x00000001
133#define DWM_BB_BLURREGION 0x00000002
134typedef struct
135{
136 DWORD dwFlags;
141#else
142 #include <dwmapi.h>
143#endif /*Windows Vista*/
144
145#ifndef DPI_ENUMS_DECLARED
146typedef enum
147{
152typedef enum
153{
159#endif /*DPI_ENUMS_DECLARED*/
160
161#ifndef DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2
162#define DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2 ((HANDLE) -4)
163#endif /*DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2*/
164
165// HACK: Define versionhelpers.h functions manually as MinGW lacks the header
166#define IsWindowsVistaOrGreater() \
167 _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_VISTA), \
168 LOBYTE(_WIN32_WINNT_VISTA), 0)
169#define IsWindows7OrGreater() \
170 _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN7), \
171 LOBYTE(_WIN32_WINNT_WIN7), 0)
172#define IsWindows8OrGreater() \
173 _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WIN8), \
174 LOBYTE(_WIN32_WINNT_WIN8), 0)
175#define IsWindows8Point1OrGreater() \
176 _glfwIsWindowsVersionOrGreaterWin32(HIBYTE(_WIN32_WINNT_WINBLUE), \
177 LOBYTE(_WIN32_WINNT_WINBLUE), 0)
178
179#define _glfwIsWindows10AnniversaryUpdateOrGreaterWin32() \
180 _glfwIsWindows10BuildOrGreaterWin32(14393)
181#define _glfwIsWindows10CreatorsUpdateOrGreaterWin32() \
182 _glfwIsWindows10BuildOrGreaterWin32(15063)
183
184// HACK: Define macros that some xinput.h variants don't
185#ifndef XINPUT_CAPS_WIRELESS
186 #define XINPUT_CAPS_WIRELESS 0x0002
187#endif
188#ifndef XINPUT_DEVSUBTYPE_WHEEL
189 #define XINPUT_DEVSUBTYPE_WHEEL 0x02
190#endif
191#ifndef XINPUT_DEVSUBTYPE_ARCADE_STICK
192 #define XINPUT_DEVSUBTYPE_ARCADE_STICK 0x03
193#endif
194#ifndef XINPUT_DEVSUBTYPE_FLIGHT_STICK
195 #define XINPUT_DEVSUBTYPE_FLIGHT_STICK 0x04
196#endif
197#ifndef XINPUT_DEVSUBTYPE_DANCE_PAD
198 #define XINPUT_DEVSUBTYPE_DANCE_PAD 0x05
199#endif
200#ifndef XINPUT_DEVSUBTYPE_GUITAR
201 #define XINPUT_DEVSUBTYPE_GUITAR 0x06
202#endif
203#ifndef XINPUT_DEVSUBTYPE_DRUM_KIT
204 #define XINPUT_DEVSUBTYPE_DRUM_KIT 0x08
205#endif
206#ifndef XINPUT_DEVSUBTYPE_ARCADE_PAD
207 #define XINPUT_DEVSUBTYPE_ARCADE_PAD 0x13
208#endif
209#ifndef XUSER_MAX_COUNT
210 #define XUSER_MAX_COUNT 4
211#endif
212
213// HACK: Define macros that some dinput.h variants don't
214#ifndef DIDFT_OPTIONAL
215 #define DIDFT_OPTIONAL 0x80000000
216#endif
217
218// winmm.dll function pointer typedefs
219typedef DWORD (WINAPI * PFN_timeGetTime)(void);
220#define timeGetTime _glfw.win32.winmm.GetTime
221
222// xinput.dll function pointer typedefs
223typedef DWORD (WINAPI * PFN_XInputGetCapabilities)(DWORD,DWORD,XINPUT_CAPABILITIES*);
224typedef DWORD (WINAPI * PFN_XInputGetState)(DWORD,XINPUT_STATE*);
225#define XInputGetCapabilities _glfw.win32.xinput.GetCapabilities
226#define XInputGetState _glfw.win32.xinput.GetState
227
228// dinput8.dll function pointer typedefs
229typedef HRESULT (WINAPI * PFN_DirectInput8Create)(HINSTANCE,DWORD,REFIID,LPVOID*,LPUNKNOWN);
230#define DirectInput8Create _glfw.win32.dinput8.Create
231
232// user32.dll function pointer typedefs
233typedef BOOL (WINAPI * PFN_SetProcessDPIAware)(void);
234typedef BOOL (WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND,UINT,DWORD,CHANGEFILTERSTRUCT*);
235typedef BOOL (WINAPI * PFN_EnableNonClientDpiScaling)(HWND);
236typedef BOOL (WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE);
237typedef UINT (WINAPI * PFN_GetDpiForWindow)(HWND);
238typedef BOOL (WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT,DWORD,BOOL,DWORD,UINT);
239#define SetProcessDPIAware _glfw.win32.user32.SetProcessDPIAware_
240#define ChangeWindowMessageFilterEx _glfw.win32.user32.ChangeWindowMessageFilterEx_
241#define EnableNonClientDpiScaling _glfw.win32.user32.EnableNonClientDpiScaling_
242#define SetProcessDpiAwarenessContext _glfw.win32.user32.SetProcessDpiAwarenessContext_
243#define GetDpiForWindow _glfw.win32.user32.GetDpiForWindow_
244#define AdjustWindowRectExForDpi _glfw.win32.user32.AdjustWindowRectExForDpi_
245
246// dwmapi.dll function pointer typedefs
247typedef HRESULT (WINAPI * PFN_DwmIsCompositionEnabled)(BOOL*);
248typedef HRESULT (WINAPI * PFN_DwmFlush)(VOID);
249typedef HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND,const DWM_BLURBEHIND*);
250typedef HRESULT (WINAPI * PFN_DwmGetColorizationColor)(DWORD*,BOOL*);
251#define DwmIsCompositionEnabled _glfw.win32.dwmapi.IsCompositionEnabled
252#define DwmFlush _glfw.win32.dwmapi.Flush
253#define DwmEnableBlurBehindWindow _glfw.win32.dwmapi.EnableBlurBehindWindow
254#define DwmGetColorizationColor _glfw.win32.dwmapi.GetColorizationColor
255
256// shcore.dll function pointer typedefs
258typedef HRESULT (WINAPI * PFN_GetDpiForMonitor)(HMONITOR,MONITOR_DPI_TYPE,UINT*,UINT*);
259#define SetProcessDpiAwareness _glfw.win32.shcore.SetProcessDpiAwareness_
260#define GetDpiForMonitor _glfw.win32.shcore.GetDpiForMonitor_
261
262// ntdll.dll function pointer typedefs
263typedef LONG (WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW*,ULONG,ULONGLONG);
264#define RtlVerifyVersionInfo _glfw.win32.ntdll.RtlVerifyVersionInfo_
265
267
269{
271 const void* pNext;
273 HINSTANCE hinstance;
274 HWND hwnd;
276
279
280#include "win32_joystick.h"
281#include "wgl_context.h"
282
283#if !defined(_GLFW_WNDCLASSNAME)
284 #define _GLFW_WNDCLASSNAME L"GLFW30"
285#endif
286
287#define _glfw_dlopen(name) LoadLibraryA(name)
288#define _glfw_dlclose(handle) FreeLibrary((HMODULE) handle)
289#define _glfw_dlsym(handle, name) GetProcAddress((HMODULE) handle, name)
290
291#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32
292#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
293#define _GLFW_PLATFORM_LIBRARY_TIMER_STATE _GLFWtimerWin32 win32
294#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32
295#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32
296#define _GLFW_PLATFORM_TLS_STATE _GLFWtlsWin32 win32
297#define _GLFW_PLATFORM_MUTEX_STATE _GLFWmutexWin32 win32
298
299
300// Win32-specific per-window data
301//
302typedef struct _GLFWwindowWin32
303{
304 HWND handle;
305 HICON bigIcon;
307
312 // Whether to enable framebuffer transparency on DWM
316
317 // Cached size used to filter out duplicate events
319
320 // The last received cursor position, regardless of source
322 // The last recevied high surrogate when decoding pairs of UTF-16 messages
324
326
327// Win32-specific global data
328//
329typedef struct _GLFWlibraryWin32
330{
336 short int keycodes[512];
337 short int scancodes[GLFW_KEY_LAST + 1];
339 // Where to place the cursor when re-enabled
341 // The window whose disabled cursor mode is active
343 RAWINPUT* rawInput;
346
347 struct {
348 HINSTANCE instance;
351
352 struct {
353 HINSTANCE instance;
355 IDirectInput8W* api;
357
358 struct {
359 HINSTANCE instance;
363
364 struct {
365 HINSTANCE instance;
373
374 struct {
375 HINSTANCE instance;
381
382 struct {
383 HINSTANCE instance;
387
388 struct {
389 HINSTANCE instance;
392
394
395// Win32-specific per-monitor data
396//
397typedef struct _GLFWmonitorWin32
398{
399 HMONITOR handle;
400 // This size matches the static size of DISPLAY_DEVICE.DeviceName
401 WCHAR adapterName[32];
402 WCHAR displayName[32];
407
409
410// Win32-specific per-cursor data
411//
412typedef struct _GLFWcursorWin32
413{
414 HCURSOR handle;
415
417
418// Win32-specific global timer data
419//
420typedef struct _GLFWtimerWin32
421{
424
426
427// Win32-specific thread local storage data
428//
429typedef struct _GLFWtlsWin32
430{
432 DWORD index;
433
435
436// Win32-specific mutex data
437//
438typedef struct _GLFWmutexWin32
439{
441 CRITICAL_SECTION section;
442
444
445
448
449WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source);
450char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source);
451BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp);
453void _glfwInputErrorWin32(int error, const char* description);
454void _glfwUpdateKeyNamesWin32(void);
455
456void _glfwInitTimerWin32(void);
457
458void _glfwPollMonitorsWin32(void);
459void _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
461void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float* xscale, float* yscale);
462
#define APIENTRY
Compiler- and platform-specific preprocessor work.
Definition: glfw3.h:125
#define GLFW_KEY_LAST
Definition: glfw3.h:515
uint64_t VkSurfaceKHR
Definition: internal.h:120
void * VkInstance
Definition: internal.h:118
void * VkPhysicalDevice
Definition: internal.h:119
int GLFWbool
Definition: internal.h:61
unsigned int uint32_t
Definition: stdint.h:80
unsigned __int64 uint64_t
Definition: stdint.h:90
char keynames[GLFW_KEY_LAST+1][5]
IDirectInput8W * api
_GLFWwindow * disabledCursorWindow
PFN_DwmEnableBlurBehindWindow EnableBlurBehindWindow
PFN_EnableNonClientDpiScaling EnableNonClientDpiScaling_
PFN_ChangeWindowMessageFilterEx ChangeWindowMessageFilterEx_
short int scancodes[GLFW_KEY_LAST+1]
PFN_SetProcessDpiAwareness SetProcessDpiAwareness_
PFN_XInputGetState GetState
PFN_XInputGetCapabilities GetCapabilities
PFN_GetDpiForMonitor GetDpiForMonitor_
PFN_GetDpiForWindow GetDpiForWindow_
PFN_SetProcessDPIAware SetProcessDPIAware_
struct _GLFWlibraryWin32::@29 xinput
PFN_DwmIsCompositionEnabled IsCompositionEnabled
PFN_DwmFlush Flush
struct _GLFWlibraryWin32::@28 dinput8
PFN_timeGetTime GetTime
PFN_RtlVerifyVersionInfo RtlVerifyVersionInfo_
PFN_SetProcessDpiAwarenessContext SetProcessDpiAwarenessContext_
struct _GLFWlibraryWin32::@30 user32
struct _GLFWlibraryWin32::@32 shcore
struct _GLFWlibraryWin32::@33 ntdll
struct _GLFWlibraryWin32::@27 winmm
HDEVNOTIFY deviceNotificationHandle
struct _GLFWlibraryWin32::@31 dwmapi
PFN_AdjustWindowRectExForDpi AdjustWindowRectExForDpi_
PFN_DwmGetColorizationColor GetColorizationColor
PFN_DirectInput8Create Create
short int keycodes[512]
char publicAdapterName[32]
char publicDisplayName[32]
CRITICAL_SECTION section
GLFWbool allocated
GLFWbool cursorTracked
GLFWbool scaleToMonitor
BOOL fTransitionOnMaximized
Video mode type.
Definition: glfw3.h:1792
VkWin32SurfaceCreateFlagsKHR flags
uint32_t VkFlags
Definition: vulkan.h:1688
VkResult
Definition: vulkan.h:842
uint32_t VkBool32
Definition: vulkan.h:1687
VkStructureType
Definition: vulkan.h:897
DWORD(WINAPI * PFN_XInputGetState)(DWORD, XINPUT_STATE *)
PROCESS_DPI_AWARENESS
@ PROCESS_SYSTEM_DPI_AWARE
@ PROCESS_PER_MONITOR_DPI_AWARE
@ PROCESS_DPI_UNAWARE
BOOL(WINAPI * PFN_AdjustWindowRectExForDpi)(LPRECT, DWORD, BOOL, DWORD, UINT)
HRESULT(WINAPI * PFN_DirectInput8Create)(HINSTANCE, DWORD, REFIID, LPVOID *, LPUNKNOWN)
BOOL(WINAPI * PFN_SetProcessDpiAwarenessContext)(HANDLE)
HRESULT(WINAPI * PFN_DwmEnableBlurBehindWindow)(HWND, const DWM_BLURBEHIND *)
void _glfwPollMonitorsWin32(void)
HRESULT(WINAPI * PFN_SetProcessDpiAwareness)(PROCESS_DPI_AWARENESS)
HRESULT(WINAPI * PFN_DwmFlush)(VOID)
BOOL(WINAPI * PFN_SetProcessDPIAware)(void)
HRESULT(WINAPI * PFN_GetDpiForMonitor)(HMONITOR, MONITOR_DPI_TYPE, UINT *, UINT *)
GLFWbool _glfwRegisterWindowClassWin32(void)
void _glfwSetVideoModeWin32(_GLFWmonitor *monitor, const GLFWvidmode *desired)
HRESULT(WINAPI * PFN_DwmIsCompositionEnabled)(BOOL *)
DWORD(WINAPI * PFN_timeGetTime)(void)
void _glfwInputErrorWin32(int error, const char *description)
Definition: win32_init.c:451
BOOL _glfwIsWindows10BuildOrGreaterWin32(WORD build)
Definition: win32_init.c:541
MONITOR_DPI_TYPE
@ MDT_RAW_DPI
@ MDT_EFFECTIVE_DPI
@ MDT_ANGULAR_DPI
@ MDT_DEFAULT
BOOL _glfwIsWindowsVersionOrGreaterWin32(WORD major, WORD minor, WORD sp)
Definition: win32_init.c:526
void _glfwGetMonitorContentScaleWin32(HMONITOR handle, float *xscale, float *yscale)
void _glfwUnregisterWindowClassWin32(void)
BOOL(WINAPI * PFN_EnableNonClientDpiScaling)(HWND)
HRESULT(WINAPI * PFN_DwmGetColorizationColor)(DWORD *, BOOL *)
VkBool32(APIENTRY * PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR)(VkPhysicalDevice, uint32_t)
WCHAR * _glfwCreateWideStringFromUTF8Win32(const char *source)
Definition: win32_init.c:395
VkResult(APIENTRY * PFN_vkCreateWin32SurfaceKHR)(VkInstance, const VkWin32SurfaceCreateInfoKHR *, const VkAllocationCallbacks *, VkSurfaceKHR *)
DWORD(WINAPI * PFN_XInputGetCapabilities)(DWORD, DWORD, XINPUT_CAPABILITIES *)
VkFlags VkWin32SurfaceCreateFlagsKHR
void _glfwInitTimerWin32(void)
Definition: win32_time.c:39
char * _glfwCreateUTF8FromWideStringWin32(const WCHAR *source)
Definition: win32_init.c:423
BOOL(WINAPI * PFN_ChangeWindowMessageFilterEx)(HWND, UINT, DWORD, CHANGEFILTERSTRUCT *)
LONG(WINAPI * PFN_RtlVerifyVersionInfo)(OSVERSIONINFOEXW *, ULONG, ULONGLONG)
UINT(WINAPI * PFN_GetDpiForWindow)(HWND)
void _glfwRestoreVideoModeWin32(_GLFWmonitor *monitor)
void _glfwUpdateKeyNamesWin32(void)
Definition: win32_init.c:472