From 262062027371e71d95ffdaebd3f0c996c1e1f74c Mon Sep 17 00:00:00 2001 From: Michael Pollind Date: Sat, 18 Mar 2023 10:30:36 -0700 Subject: [PATCH] bugfix: resolve build for windows xcb for 01.HelloWorld Signed-off-by: Michael Pollind --- 01.HelloWorld/main.cpp | 47 ++++++++++++++++++++++++++++++++++-------- common/CommonAPI.h | 2 +- 2 files changed, 39 insertions(+), 10 deletions(-) diff --git a/01.HelloWorld/main.cpp b/01.HelloWorld/main.cpp index 418df99e6..5ed25c9bd 100644 --- a/01.HelloWorld/main.cpp +++ b/01.HelloWorld/main.cpp @@ -10,9 +10,12 @@ nothing fancy, just to show that Nabla links fine #include #include +#include "nbl/system/CColoredStdoutLoggerANSI.h" #include "nbl/system/IApplicationFramework.h" #include "nbl/ui/IGraphicalApplicationFramework.h" +#include "nbl/ui/CWindowManagerXCB.h" + using namespace nbl; #define LOG(...) printf(__VA_ARGS__); printf("\n"); @@ -196,10 +199,15 @@ class HelloWorldSampleApp : public system::IApplicationFramework, public ui::IGr // create basic system objects system = createSystem(); auto logLevelMask = core::bitflag(system::ILogger::ELL_DEBUG) | system::ILogger::ELL_PERFORMANCE | system::ILogger::ELL_WARNING | system::ILogger::ELL_ERROR; + + #ifdef _NBL_PLATFORM_WINDOWS_ logger = core::make_smart_refctd_ptr(logLevelMask); + #else + logger = core::make_smart_refctd_ptr(logLevelMask); + #endif // set windo event callback -#ifndef _NBL_PLATFORM_ANDROID_ +#ifdef _NBL_PLATFORM_WINDOWS_ auto windowManager = core::make_smart_refctd_ptr(); windowCb = core::make_smart_refctd_ptr(); @@ -214,9 +222,22 @@ class HelloWorldSampleApp : public system::IApplicationFramework, public ui::IGr params.callback = windowCb; // TODO (deprilula): Win32 window seems to be resizable despite the lack of resizability flag in the creation parameters! window = windowManager->createWindow(std::move(params)); +#elif defined(_NBL_PLATFORM_LINUX_) + auto windowManager = core::make_smart_refctd_ptr(); + windowCb = core::make_smart_refctd_ptr(); + + ui::IWindow::SCreationParams params; + params.width = WIN_W; + params.height = WIN_H; + params.x = 64; + params.y = 64; + params.system = core::smart_refctd_ptr(system); + params.flags = ui::IWindow::ECF_NONE; + params.windowCaption = APP_NAME; + params.callback = windowCb; + window = windowManager->createWindow(std::move(params)); #else - assert(window); - window->setEventCallback(core::smart_refctd_ptr(windowCb)); + #error "Unsupported platform" #endif // create API connection @@ -234,12 +255,20 @@ class HelloWorldSampleApp : public system::IApplicationFramework, public ui::IGr assert(apiConnection); } - { - surface = video::CSurfaceVulkanWin32::create( - core::smart_refctd_ptr(static_cast(apiConnection.get())), - core::smart_refctd_ptr(static_cast(window.get()))); - assert(surface); - } +#ifdef _NBL_PLATFORM_WINDOWS_ + surface = video::CSurfaceVulkanWin32::create( + core::smart_refctd_ptr(static_cast(apiConnection.get())), + core::smart_refctd_ptr(static_cast(window.get()))); + assert(surface); +#elif defined(_NBL_PLATFORM_LINUX_) + surface = video::CSurfaceVulkanXcb::create( + core::smart_refctd_ptr(static_cast(apiConnection.get())), + core::smart_refctd_ptr(static_cast(window.get()))); + assert(surface); +#else + #error "Unsupported platform" +#endif + // Find a suitable gpu auto gpus = apiConnection->getPhysicalDevices(); diff --git a/common/CommonAPI.h b/common/CommonAPI.h index 4361386f5..8aae963a5 100644 --- a/common/CommonAPI.h +++ b/common/CommonAPI.h @@ -500,7 +500,7 @@ class CommonAPI #ifdef _NBL_PLATFORM_WINDOWS_ result.windowManager = nbl::core::make_smart_refctd_ptr(); // on the Android path #elif defined(_NBL_PLATFORM_LINUX_) - result.windowManager = nbl::core::make_smart_refctd_ptr(); // on the Android path + result.windowManager = nbl::core::make_smart_refctd_ptr(); // on the Android path #else #error "Unsupported platform" #endif