Platform/WindowManager: Rename to WindowBackend

This commit is contained in:
SirLynix 2022-04-23 16:26:59 +02:00
parent e7274b24e9
commit 2389a2fe53
8 changed files with 19 additions and 22 deletions

View File

@ -12,7 +12,7 @@
namespace Nz namespace Nz
{ {
enum class WindowManager enum class WindowBackend
{ {
Invalid, Invalid,
@ -24,7 +24,7 @@ namespace Nz
struct WindowHandle struct WindowHandle
{ {
WindowManager type = WindowManager::Invalid; WindowBackend type = WindowBackend::Invalid;
union union
{ {

View File

@ -30,10 +30,7 @@ namespace Nz::GL
template<typename FuncType, typename Func> template<typename FuncType, typename Func>
bool Load(Func& func, const char* funcName, bool mandatory, bool implementFallback = true) bool Load(Func& func, const char* funcName, bool mandatory, bool implementFallback = true)
{ {
FuncType funcPtr = LoadRaw<FuncType>(funcName); func = LoadRaw<FuncType>(funcName);
if (funcPtr)
func = funcPtr;
if (!func) if (!func)
{ {
if (!implementFallback || (!loader.ImplementFallback(funcName) && !func)) //< double-check if (!implementFallback || (!loader.ImplementFallback(funcName) && !func)) //< double-check
@ -151,22 +148,22 @@ namespace Nz::GL
std::unique_ptr<EGLContextBase> context; std::unique_ptr<EGLContextBase> context;
switch (handle.type) switch (handle.type)
{ {
case WindowManager::Invalid: case WindowBackend::Invalid:
break; break;
case WindowManager::X11: case WindowBackend::X11:
#ifdef NAZARA_PLATFORM_LINUX #ifdef NAZARA_PLATFORM_LINUX
context = std::make_unique<EGLContextX11>(device, *this); context = std::make_unique<EGLContextX11>(device, *this);
#endif #endif
break; break;
case WindowManager::Windows: case WindowBackend::Windows:
#ifdef NAZARA_PLATFORM_WINDOWS #ifdef NAZARA_PLATFORM_WINDOWS
context = std::make_unique<EGLContextWin32>(device, *this); context = std::make_unique<EGLContextWin32>(device, *this);
#endif #endif
break; break;
case WindowManager::Wayland: case WindowBackend::Wayland:
#ifdef NAZARA_PLATFORM_LINUX #ifdef NAZARA_PLATFORM_LINUX
context = std::make_unique<EGLContextWayland>(device, *this); context = std::make_unique<EGLContextWayland>(device, *this);
#endif #endif

View File

@ -10,7 +10,7 @@ namespace Nz::GL
{ {
bool EGLContextWayland::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext) bool EGLContextWayland::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext)
{ {
assert(window.type == WindowManager::Wayland); assert(window.type == WindowBackend::Wayland);
NazaraError("Wayland is not yet supported"); NazaraError("Wayland is not yet supported");
return false; return false;

View File

@ -10,7 +10,7 @@ namespace Nz::GL
{ {
bool EGLContextX11::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext) bool EGLContextX11::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext)
{ {
assert(window.type == WindowManager::X11); assert(window.type == WindowBackend::X11);
Destroy(); //< In case a previous display or surface hasn't been released Destroy(); //< In case a previous display or surface hasn't been released

View File

@ -47,7 +47,7 @@ namespace Nz::GL
bool WGLContext::Create(const WGLContext* baseContext, const ContextParams& params, WindowHandle window, const WGLContext* shareContext) bool WGLContext::Create(const WGLContext* baseContext, const ContextParams& params, WindowHandle window, const WGLContext* shareContext)
{ {
NazaraAssert(window.type == WindowManager::Windows, "expected Windows window"); NazaraAssert(window.type == WindowBackend::Windows, "expected Windows window");
Destroy(); Destroy();

View File

@ -21,7 +21,7 @@ namespace Nz::GL
::ShowWindow(window.get(), FALSE); ::ShowWindow(window.get(), FALSE);
WindowHandle windowHandle; WindowHandle windowHandle;
windowHandle.type = WindowManager::Windows; windowHandle.type = WindowBackend::Windows;
windowHandle.windows.window = window.get(); windowHandle.windows.window = window.get();
if (!Create(params, windowHandle, shareContext)) if (!Create(params, windowHandle, shareContext))
@ -34,7 +34,7 @@ namespace Nz::GL
bool EGLContextWin32::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext) bool EGLContextWin32::Create(const ContextParams& params, WindowHandle window, const EGLContextBase* shareContext)
{ {
assert(window.type == WindowManager::Windows); assert(window.type == WindowBackend::Windows);
Destroy(); //< In case a previous display or surface hasn't been released Destroy(); //< In case a previous display or surface hasn't been released

View File

@ -204,7 +204,7 @@ namespace Nz
#if defined(SDL_VIDEO_DRIVER_COCOA) #if defined(SDL_VIDEO_DRIVER_COCOA)
case SDL_SYSWM_COCOA: case SDL_SYSWM_COCOA:
{ {
handle.type = WindowManager::Cocoa; handle.type = WindowBackend::Cocoa;
handle.cocoa.window = wmInfo.info.cocoa.window; handle.cocoa.window = wmInfo.info.cocoa.window;
break; break;
} }
@ -212,7 +212,7 @@ namespace Nz
#if defined(SDL_VIDEO_DRIVER_X11) #if defined(SDL_VIDEO_DRIVER_X11)
case SDL_SYSWM_X11: case SDL_SYSWM_X11:
{ {
handle.type = WindowManager::X11; handle.type = WindowBackend::X11;
handle.x11.display = wmInfo.info.x11.display; handle.x11.display = wmInfo.info.x11.display;
handle.x11.window = wmInfo.info.x11.window; handle.x11.window = wmInfo.info.x11.window;
break; break;
@ -221,7 +221,7 @@ namespace Nz
#if defined(SDL_VIDEO_DRIVER_WAYLAND) #if defined(SDL_VIDEO_DRIVER_WAYLAND)
case SDL_SYSWM_WAYLAND: case SDL_SYSWM_WAYLAND:
{ {
handle.type = WindowManager::Wayland; handle.type = WindowBackend::Wayland;
handle.wayland.display = wmInfo.info.wl.display; handle.wayland.display = wmInfo.info.wl.display;
handle.wayland.surface = wmInfo.info.wl.surface; handle.wayland.surface = wmInfo.info.wl.surface;
handle.wayland.shellSurface = wmInfo.info.wl.shell_surface; handle.wayland.shellSurface = wmInfo.info.wl.shell_surface;
@ -231,7 +231,7 @@ namespace Nz
#if defined(SDL_VIDEO_DRIVER_WINDOWS) #if defined(SDL_VIDEO_DRIVER_WINDOWS)
case SDL_SYSWM_WINDOWS: case SDL_SYSWM_WINDOWS:
{ {
handle.type = WindowManager::Windows; handle.type = WindowBackend::Windows;
handle.windows.window = wmInfo.info.win.window; handle.windows.window = wmInfo.info.win.window;
break; break;
} }

View File

@ -19,7 +19,7 @@ namespace Nz
bool success = false; bool success = false;
#if defined(NAZARA_PLATFORM_WINDOWS) #if defined(NAZARA_PLATFORM_WINDOWS)
{ {
NazaraAssert(handle.type == WindowManager::Windows, "expected Windows window"); NazaraAssert(handle.type == WindowBackend::Windows, "expected Windows window");
HWND winHandle = reinterpret_cast<HWND>(handle.windows.window); HWND winHandle = reinterpret_cast<HWND>(handle.windows.window);
HINSTANCE instance = reinterpret_cast<HINSTANCE>(GetWindowLongPtrW(winHandle, GWLP_HINSTANCE)); HINSTANCE instance = reinterpret_cast<HINSTANCE>(GetWindowLongPtrW(winHandle, GWLP_HINSTANCE));
@ -31,7 +31,7 @@ namespace Nz
switch (handle.type) switch (handle.type)
{ {
#ifdef VK_USE_PLATFORM_WAYLAND_KHR #ifdef VK_USE_PLATFORM_WAYLAND_KHR
case WindowManager::Wayland: case WindowBackend::Wayland:
{ {
wl_display* display = static_cast<wl_display*>(handle.wayland.display); wl_display* display = static_cast<wl_display*>(handle.wayland.display);
wl_surface* surface = static_cast<wl_surface*>(handle.wayland.surface); wl_surface* surface = static_cast<wl_surface*>(handle.wayland.surface);
@ -42,7 +42,7 @@ namespace Nz
#endif #endif
#ifdef VK_USE_PLATFORM_XLIB_KHR #ifdef VK_USE_PLATFORM_XLIB_KHR
case WindowManager::X11: case WindowBackend::X11:
{ {
Display* display = static_cast<Display*>(handle.x11.display); Display* display = static_cast<Display*>(handle.x11.display);
::Window window = static_cast<::Window>(handle.x11.window); ::Window window = static_cast<::Window>(handle.x11.window);