Add runtime platform selection

This adds compile-time support for multiple platforms and runtime
detection of them.  Window system related platform functions are now
called from shared code via the function pointer struct _GLFWplatform.

The timer, thread and module loading platform functions are still called
directly by name and the implementation chosen at link-time.  These
functions are the same for any backend on a given OS, including the Null
backend.

The platforms are now enabled via CMake dependent options following the
GLFW_BUILD_<platform> pattern instead of a mix of automagic and ad-hoc
option names.  There is no longer any option for the Null backend as it
is now always enabled.

Much of the struct stitching work in platform.h was based on an earlier
experimental branch for runtime platform selection by @ronchaine.

Every platform function related to windows, contexts, monitors, input,
event processing and Vulkan have been renamed so that multiple sets of
them can exist without colliding.  Calls to these are now routed through
the _glfw.platform struct member.  These changes makes up most of this
commit.

For Wayland and X11 the client library loading and display creation is
used to detect a running compositor/server.  The XDG_SESSION_TYPE
environment variable is ignored for now, as X11 is still by far the more
complete implementation.

Closes #1655
Closes #1958
This commit is contained in:
Camilla Löwy
2021-07-13 21:50:09 +02:00
parent ff9d9515f6
commit 56a4cb0a3a
56 changed files with 2698 additions and 1235 deletions
+106 -113
View File
@@ -297,9 +297,9 @@ static void disableRawMouseMotion(_GLFWwindow* window)
static void disableCursor(_GLFWwindow* window)
{
_glfw.win32.disabledCursorWindow = window;
_glfwPlatformGetCursorPos(window,
&_glfw.win32.restoreCursorPosX,
&_glfw.win32.restoreCursorPosY);
_glfwGetCursorPosWin32(window,
&_glfw.win32.restoreCursorPosX,
&_glfw.win32.restoreCursorPosY);
updateCursorImage(window);
_glfwCenterCursorInContentArea(window);
updateClipRect(window);
@@ -317,9 +317,9 @@ static void enableCursor(_GLFWwindow* window)
_glfw.win32.disabledCursorWindow = NULL;
updateClipRect(NULL);
_glfwPlatformSetCursorPos(window,
_glfw.win32.restoreCursorPosX,
_glfw.win32.restoreCursorPosY);
_glfwSetCursorPosWin32(window,
_glfw.win32.restoreCursorPosX,
_glfw.win32.restoreCursorPosY);
updateCursorImage(window);
}
@@ -595,7 +595,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
enableCursor(window);
if (window->monitor && window->autoIconify)
_glfwPlatformIconifyWindow(window);
_glfwIconifyWindowWin32(window);
_glfwInputWindowFocus(window, GLFW_FALSE);
return 0;
@@ -755,7 +755,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
{
// HACK: Release both Shift keys on Shift up event, as when both
// are pressed the first release does not emit any event
// NOTE: The other half of this is in _glfwPlatformPollEvents
// NOTE: The other half of this is in _glfwPollEventsWin32
_glfwInputKey(window, GLFW_KEY_LEFT_SHIFT, scancode, action, mods);
_glfwInputKey(window, GLFW_KEY_RIGHT_SHIFT, scancode, action, mods);
}
@@ -1233,8 +1233,8 @@ static int createNativeWindow(_GLFWwindow* window,
// NOTE: This window placement is temporary and approximate, as the
// correct position and size cannot be known until the monitor
// video mode has been picked in _glfwSetVideoModeWin32
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
_glfwPlatformGetVideoMode(window->monitor, &mode);
_glfwGetMonitorPosWin32(window->monitor, &xpos, &ypos);
_glfwGetVideoModeWin32(window->monitor, &mode);
fullWidth = mode.width;
fullHeight = mode.height;
}
@@ -1303,7 +1303,7 @@ static int createNativeWindow(_GLFWwindow* window,
if (wndconfig->scaleToMonitor)
{
float xscale, yscale;
_glfwPlatformGetWindowContentScale(window, &xscale, &yscale);
_glfwGetWindowContentScaleWin32(window, &xscale, &yscale);
rect.right = (int) (rect.right * xscale);
rect.bottom = (int) (rect.bottom * yscale);
}
@@ -1334,16 +1334,11 @@ static int createNativeWindow(_GLFWwindow* window,
window->win32.transparent = GLFW_TRUE;
}
_glfwPlatformGetWindowSize(window, &window->win32.width, &window->win32.height);
_glfwGetWindowSizeWin32(window, &window->win32.width, &window->win32.height);
return GLFW_TRUE;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW internal API //////
//////////////////////////////////////////////////////////////////////////
// Registers the GLFW window class
//
GLFWbool _glfwRegisterWindowClassWin32(void)
@@ -1387,15 +1382,10 @@ void _glfwUnregisterWindowClassWin32(void)
UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL));
}
//////////////////////////////////////////////////////////////////////////
////// GLFW platform API //////
//////////////////////////////////////////////////////////////////////////
int _glfwPlatformCreateWindow(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
int _glfwCreateWindowWin32(_GLFWwindow* window,
const _GLFWwndconfig* wndconfig,
const _GLFWctxconfig* ctxconfig,
const _GLFWfbconfig* fbconfig)
{
if (!createNativeWindow(window, wndconfig, fbconfig))
return GLFW_FALSE;
@@ -1427,8 +1417,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (window->monitor)
{
_glfwPlatformShowWindow(window);
_glfwPlatformFocusWindow(window);
_glfwShowWindowWin32(window);
_glfwFocusWindowWin32(window);
acquireMonitor(window);
fitToMonitor(window);
}
@@ -1436,7 +1426,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
return GLFW_TRUE;
}
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
void _glfwDestroyWindowWin32(_GLFWwindow* window)
{
if (window->monitor)
releaseMonitor(window);
@@ -1461,7 +1451,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
DestroyIcon(window->win32.smallIcon);
}
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
void _glfwSetWindowTitleWin32(_GLFWwindow* window, const char* title)
{
WCHAR* wideTitle = _glfwCreateWideStringFromUTF8Win32(title);
if (!wideTitle)
@@ -1471,8 +1461,8 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
_glfw_free(wideTitle);
}
void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
int count, const GLFWimage* images)
void _glfwSetWindowIconWin32(_GLFWwindow* window,
int count, const GLFWimage* images)
{
HICON bigIcon = NULL, smallIcon = NULL;
@@ -1510,7 +1500,7 @@ void _glfwPlatformSetWindowIcon(_GLFWwindow* window,
}
}
void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
void _glfwGetWindowPosWin32(_GLFWwindow* window, int* xpos, int* ypos)
{
POINT pos = { 0, 0 };
ClientToScreen(window->win32.handle, &pos);
@@ -1521,7 +1511,7 @@ void _glfwPlatformGetWindowPos(_GLFWwindow* window, int* xpos, int* ypos)
*ypos = pos.y;
}
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
void _glfwSetWindowPosWin32(_GLFWwindow* window, int xpos, int ypos)
{
RECT rect = { xpos, ypos, xpos, ypos };
@@ -1541,7 +1531,7 @@ void _glfwPlatformSetWindowPos(_GLFWwindow* window, int xpos, int ypos)
SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOSIZE);
}
void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
void _glfwGetWindowSizeWin32(_GLFWwindow* window, int* width, int* height)
{
RECT area;
GetClientRect(window->win32.handle, &area);
@@ -1552,7 +1542,7 @@ void _glfwPlatformGetWindowSize(_GLFWwindow* window, int* width, int* height)
*height = area.bottom;
}
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
void _glfwSetWindowSizeWin32(_GLFWwindow* window, int width, int height)
{
if (window->monitor)
{
@@ -1584,9 +1574,9 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
}
}
void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
int minwidth, int minheight,
int maxwidth, int maxheight)
void _glfwSetWindowSizeLimitsWin32(_GLFWwindow* window,
int minwidth, int minheight,
int maxwidth, int maxheight)
{
RECT area;
@@ -1603,7 +1593,7 @@ void _glfwPlatformSetWindowSizeLimits(_GLFWwindow* window,
area.bottom - area.top, TRUE);
}
void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom)
void _glfwSetWindowAspectRatioWin32(_GLFWwindow* window, int numer, int denom)
{
RECT area;
@@ -1618,19 +1608,19 @@ void _glfwPlatformSetWindowAspectRatio(_GLFWwindow* window, int numer, int denom
area.bottom - area.top, TRUE);
}
void _glfwPlatformGetFramebufferSize(_GLFWwindow* window, int* width, int* height)
void _glfwGetFramebufferSizeWin32(_GLFWwindow* window, int* width, int* height)
{
_glfwPlatformGetWindowSize(window, width, height);
_glfwGetWindowSizeWin32(window, width, height);
}
void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
int* left, int* top,
int* right, int* bottom)
void _glfwGetWindowFrameSizeWin32(_GLFWwindow* window,
int* left, int* top,
int* right, int* bottom)
{
RECT rect;
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwGetWindowSizeWin32(window, &width, &height);
SetRect(&rect, 0, 0, width, height);
if (_glfwIsWindows10AnniversaryUpdateOrGreaterWin32())
@@ -1655,56 +1645,56 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
*bottom = rect.bottom - height;
}
void _glfwPlatformGetWindowContentScale(_GLFWwindow* window,
float* xscale, float* yscale)
void _glfwGetWindowContentScaleWin32(_GLFWwindow* window,
float* xscale, float* yscale)
{
const HANDLE handle = MonitorFromWindow(window->win32.handle,
MONITOR_DEFAULTTONEAREST);
_glfwGetMonitorContentScaleWin32(handle, xscale, yscale);
_glfwGetHMONITORContentScaleWin32(handle, xscale, yscale);
}
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
void _glfwIconifyWindowWin32(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_MINIMIZE);
}
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
void _glfwRestoreWindowWin32(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_RESTORE);
}
void _glfwPlatformMaximizeWindow(_GLFWwindow* window)
void _glfwMaximizeWindowWin32(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_MAXIMIZE);
}
void _glfwPlatformShowWindow(_GLFWwindow* window)
void _glfwShowWindowWin32(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_SHOWNA);
}
void _glfwPlatformHideWindow(_GLFWwindow* window)
void _glfwHideWindowWin32(_GLFWwindow* window)
{
ShowWindow(window->win32.handle, SW_HIDE);
}
void _glfwPlatformRequestWindowAttention(_GLFWwindow* window)
void _glfwRequestWindowAttentionWin32(_GLFWwindow* window)
{
FlashWindow(window->win32.handle, TRUE);
}
void _glfwPlatformFocusWindow(_GLFWwindow* window)
void _glfwFocusWindowWin32(_GLFWwindow* window)
{
BringWindowToTop(window->win32.handle);
SetForegroundWindow(window->win32.handle);
SetFocus(window->win32.handle);
}
void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
_GLFWmonitor* monitor,
int xpos, int ypos,
int width, int height,
int refreshRate)
void _glfwSetWindowMonitorWin32(_GLFWwindow* window,
_GLFWmonitor* monitor,
int xpos, int ypos,
int width, int height,
int refreshRate)
{
if (window->monitor == monitor)
{
@@ -1810,32 +1800,32 @@ void _glfwPlatformSetWindowMonitor(_GLFWwindow* window,
}
}
int _glfwPlatformWindowFocused(_GLFWwindow* window)
int _glfwWindowFocusedWin32(_GLFWwindow* window)
{
return window->win32.handle == GetActiveWindow();
}
int _glfwPlatformWindowIconified(_GLFWwindow* window)
int _glfwWindowIconifiedWin32(_GLFWwindow* window)
{
return IsIconic(window->win32.handle);
}
int _glfwPlatformWindowVisible(_GLFWwindow* window)
int _glfwWindowVisibleWin32(_GLFWwindow* window)
{
return IsWindowVisible(window->win32.handle);
}
int _glfwPlatformWindowMaximized(_GLFWwindow* window)
int _glfwWindowMaximizedWin32(_GLFWwindow* window)
{
return IsZoomed(window->win32.handle);
}
int _glfwPlatformWindowHovered(_GLFWwindow* window)
int _glfwWindowHoveredWin32(_GLFWwindow* window)
{
return cursorInContentArea(window);
}
int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
int _glfwFramebufferTransparentWin32(_GLFWwindow* window)
{
BOOL composition, opaque;
DWORD color;
@@ -1862,24 +1852,24 @@ int _glfwPlatformFramebufferTransparent(_GLFWwindow* window)
return GLFW_TRUE;
}
void _glfwPlatformSetWindowResizable(_GLFWwindow* window, GLFWbool enabled)
void _glfwSetWindowResizableWin32(_GLFWwindow* window, GLFWbool enabled)
{
updateWindowStyles(window);
}
void _glfwPlatformSetWindowDecorated(_GLFWwindow* window, GLFWbool enabled)
void _glfwSetWindowDecoratedWin32(_GLFWwindow* window, GLFWbool enabled)
{
updateWindowStyles(window);
}
void _glfwPlatformSetWindowFloating(_GLFWwindow* window, GLFWbool enabled)
void _glfwSetWindowFloatingWin32(_GLFWwindow* window, GLFWbool enabled)
{
const HWND after = enabled ? HWND_TOPMOST : HWND_NOTOPMOST;
SetWindowPos(window->win32.handle, after, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
}
void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enabled)
void _glfwSetWindowMousePassthroughWin32(_GLFWwindow* window, GLFWbool enabled)
{
COLORREF key = 0;
BYTE alpha = 0;
@@ -1909,7 +1899,7 @@ void _glfwPlatformSetWindowMousePassthrough(_GLFWwindow* window, GLFWbool enable
SetLayeredWindowAttributes(window->win32.handle, key, alpha, flags);
}
float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
float _glfwGetWindowOpacityWin32(_GLFWwindow* window)
{
BYTE alpha;
DWORD flags;
@@ -1924,7 +1914,7 @@ float _glfwPlatformGetWindowOpacity(_GLFWwindow* window)
return 1.f;
}
void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
void _glfwSetWindowOpacityWin32(_GLFWwindow* window, float opacity)
{
LONG exStyle = GetWindowLongW(window->win32.handle, GWL_EXSTYLE);
if (opacity < 1.f || (exStyle & WS_EX_TRANSPARENT))
@@ -1945,7 +1935,7 @@ void _glfwPlatformSetWindowOpacity(_GLFWwindow* window, float opacity)
}
}
void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
void _glfwSetRawMouseMotionWin32(_GLFWwindow *window, GLFWbool enabled)
{
if (_glfw.win32.disabledCursorWindow != window)
return;
@@ -1956,12 +1946,12 @@ void _glfwPlatformSetRawMouseMotion(_GLFWwindow *window, GLFWbool enabled)
disableRawMouseMotion(window);
}
GLFWbool _glfwPlatformRawMouseMotionSupported(void)
GLFWbool _glfwRawMouseMotionSupportedWin32(void)
{
return GLFW_TRUE;
}
void _glfwPlatformPollEvents(void)
void _glfwPollEventsWin32(void)
{
MSG msg;
HWND handle;
@@ -2031,38 +2021,38 @@ void _glfwPlatformPollEvents(void)
if (window)
{
int width, height;
_glfwPlatformGetWindowSize(window, &width, &height);
_glfwGetWindowSizeWin32(window, &width, &height);
// NOTE: Re-center the cursor only if it has moved since the last call,
// to avoid breaking glfwWaitEvents with WM_MOUSEMOVE
if (window->win32.lastCursorPosX != width / 2 ||
window->win32.lastCursorPosY != height / 2)
{
_glfwPlatformSetCursorPos(window, width / 2, height / 2);
_glfwSetCursorPosWin32(window, width / 2, height / 2);
}
}
}
void _glfwPlatformWaitEvents(void)
void _glfwWaitEventsWin32(void)
{
WaitMessage();
_glfwPlatformPollEvents();
_glfwPollEventsWin32();
}
void _glfwPlatformWaitEventsTimeout(double timeout)
void _glfwWaitEventsTimeoutWin32(double timeout)
{
MsgWaitForMultipleObjects(0, NULL, FALSE, (DWORD) (timeout * 1e3), QS_ALLEVENTS);
_glfwPlatformPollEvents();
_glfwPollEventsWin32();
}
void _glfwPlatformPostEmptyEvent(void)
void _glfwPostEmptyEventWin32(void)
{
PostMessage(_glfw.win32.helperWindowHandle, WM_NULL, 0, 0);
}
void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
void _glfwGetCursorPosWin32(_GLFWwindow* window, double* xpos, double* ypos)
{
POINT pos;
@@ -2077,7 +2067,7 @@ void _glfwPlatformGetCursorPos(_GLFWwindow* window, double* xpos, double* ypos)
}
}
void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
void _glfwSetCursorPosWin32(_GLFWwindow* window, double xpos, double ypos)
{
POINT pos = { (int) xpos, (int) ypos };
@@ -2089,11 +2079,11 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, double xpos, double ypos)
SetCursorPos(pos.x, pos.y);
}
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
void _glfwSetCursorModeWin32(_GLFWwindow* window, int mode)
{
if (mode == GLFW_CURSOR_DISABLED)
{
if (_glfwPlatformWindowFocused(window))
if (_glfwWindowFocusedWin32(window))
disableCursor(window);
}
else if (_glfw.win32.disabledCursorWindow == window)
@@ -2102,7 +2092,7 @@ void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode)
updateCursorImage(window);
}
const char* _glfwPlatformGetScancodeName(int scancode)
const char* _glfwGetScancodeNameWin32(int scancode)
{
if (scancode < 0 || scancode > (KF_EXTENDED | 0xff) ||
_glfw.win32.keycodes[scancode] == GLFW_KEY_UNKNOWN)
@@ -2114,14 +2104,14 @@ const char* _glfwPlatformGetScancodeName(int scancode)
return _glfw.win32.keynames[_glfw.win32.keycodes[scancode]];
}
int _glfwPlatformGetKeyScancode(int key)
int _glfwGetKeyScancodeWin32(int key)
{
return _glfw.win32.scancodes[key];
}
int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
const GLFWimage* image,
int xhot, int yhot)
int _glfwCreateCursorWin32(_GLFWcursor* cursor,
const GLFWimage* image,
int xhot, int yhot)
{
cursor->win32.handle = (HCURSOR) createIcon(image, xhot, yhot, GLFW_FALSE);
if (!cursor->win32.handle)
@@ -2130,7 +2120,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
return GLFW_TRUE;
}
int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
int _glfwCreateStandardCursorWin32(_GLFWcursor* cursor, int shape)
{
int id = 0;
@@ -2184,19 +2174,19 @@ int _glfwPlatformCreateStandardCursor(_GLFWcursor* cursor, int shape)
return GLFW_TRUE;
}
void _glfwPlatformDestroyCursor(_GLFWcursor* cursor)
void _glfwDestroyCursorWin32(_GLFWcursor* cursor)
{
if (cursor->win32.handle)
DestroyIcon((HICON) cursor->win32.handle);
}
void _glfwPlatformSetCursor(_GLFWwindow* window, _GLFWcursor* cursor)
void _glfwSetCursorWin32(_GLFWwindow* window, _GLFWcursor* cursor)
{
if (cursorInContentArea(window))
updateCursorImage(window);
}
void _glfwPlatformSetClipboardString(const char* string)
void _glfwSetClipboardStringWin32(const char* string)
{
int characterCount;
HANDLE object;
@@ -2239,7 +2229,7 @@ void _glfwPlatformSetClipboardString(const char* string)
CloseClipboard();
}
const char* _glfwPlatformGetClipboardString(void)
const char* _glfwGetClipboardStringWin32(void)
{
HANDLE object;
WCHAR* buffer;
@@ -2278,7 +2268,7 @@ const char* _glfwPlatformGetClipboardString(void)
return _glfw.win32.clipboardString;
}
EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
EGLenum _glfwGetEGLPlatformWin32(EGLint** attribs)
{
if (_glfw.egl.ANGLE_platform_angle)
{
@@ -2319,17 +2309,17 @@ EGLenum _glfwPlatformGetEGLPlatform(EGLint** attribs)
return 0;
}
EGLNativeDisplayType _glfwPlatformGetEGLNativeDisplay(void)
EGLNativeDisplayType _glfwGetEGLNativeDisplayWin32(void)
{
return GetDC(_glfw.win32.helperWindowHandle);
}
EGLNativeWindowType _glfwPlatformGetEGLNativeWindow(_GLFWwindow* window)
EGLNativeWindowType _glfwGetEGLNativeWindowWin32(_GLFWwindow* window)
{
return window->win32.handle;
}
void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
void _glfwGetRequiredInstanceExtensionsWin32(char** extensions)
{
if (!_glfw.vk.KHR_surface || !_glfw.vk.KHR_win32_surface)
return;
@@ -2338,9 +2328,9 @@ void _glfwPlatformGetRequiredInstanceExtensions(char** extensions)
extensions[1] = "VK_KHR_win32_surface";
}
int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
VkPhysicalDevice device,
uint32_t queuefamily)
int _glfwGetPhysicalDevicePresentationSupportWin32(VkInstance instance,
VkPhysicalDevice device,
uint32_t queuefamily)
{
PFN_vkGetPhysicalDeviceWin32PresentationSupportKHR
vkGetPhysicalDeviceWin32PresentationSupportKHR =
@@ -2356,10 +2346,10 @@ int _glfwPlatformGetPhysicalDevicePresentationSupport(VkInstance instance,
return vkGetPhysicalDeviceWin32PresentationSupportKHR(device, queuefamily);
}
VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
_GLFWwindow* window,
const VkAllocationCallbacks* allocator,
VkSurfaceKHR* surface)
VkResult _glfwCreateWindowSurfaceWin32(VkInstance instance,
_GLFWwindow* window,
const VkAllocationCallbacks* allocator,
VkSurfaceKHR* surface)
{
VkResult err;
VkWin32SurfaceCreateInfoKHR sci;
@@ -2390,15 +2380,18 @@ VkResult _glfwPlatformCreateWindowSurface(VkInstance instance,
return err;
}
//////////////////////////////////////////////////////////////////////////
////// GLFW native API //////
//////////////////////////////////////////////////////////////////////////
GLFWAPI HWND glfwGetWin32Window(GLFWwindow* handle)
{
_GLFWwindow* window = (_GLFWwindow*) handle;
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
if (_glfw.platform.platformID != GLFW_PLATFORM_WIN32)
{
_glfwInputError(GLFW_PLATFORM_UNAVAILABLE,
"Win32: Platform not initialized");
return NULL;
}
return window->win32.handle;
}