Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bugfix: resolve build for windows xcb for 01.HelloWorld #32

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 38 additions & 9 deletions 01.HelloWorld/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ nothing fancy, just to show that Nabla links fine
#include <iostream>
#include <cstdio>

#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");
Expand Down Expand Up @@ -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<system::CColoredStdoutLoggerWin32>(logLevelMask);
#else
logger = core::make_smart_refctd_ptr<system::CColoredStdoutLoggerANSI>(logLevelMask);
#endif

// set windo event callback
#ifndef _NBL_PLATFORM_ANDROID_
#ifdef _NBL_PLATFORM_WINDOWS_
auto windowManager = core::make_smart_refctd_ptr<nbl::ui::CWindowManagerWin32>();
windowCb = core::make_smart_refctd_ptr<DemoEventCallback>();

Expand All @@ -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<nbl::ui::CWindowManagerXCB>();
windowCb = core::make_smart_refctd_ptr<DemoEventCallback>();

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
Expand All @@ -234,12 +255,20 @@ class HelloWorldSampleApp : public system::IApplicationFramework, public ui::IGr
assert(apiConnection);
}

{
surface = video::CSurfaceVulkanWin32::create(
core::smart_refctd_ptr<video::CVulkanConnection>(static_cast<video::CVulkanConnection*>(apiConnection.get())),
core::smart_refctd_ptr<ui::IWindowWin32>(static_cast<ui::IWindowWin32*>(window.get())));
assert(surface);
}
#ifdef _NBL_PLATFORM_WINDOWS_
surface = video::CSurfaceVulkanWin32::create(
core::smart_refctd_ptr<video::CVulkanConnection>(static_cast<video::CVulkanConnection*>(apiConnection.get())),
core::smart_refctd_ptr<ui::IWindowWin32>(static_cast<ui::IWindowWin32*>(window.get())));
assert(surface);
#elif defined(_NBL_PLATFORM_LINUX_)
surface = video::CSurfaceVulkanXcb::create(
core::smart_refctd_ptr<video::CVulkanConnection>(static_cast<video::CVulkanConnection*>(apiConnection.get())),
core::smart_refctd_ptr<ui::IWindowXCB>(static_cast<ui::IWindowXCB*>(window.get())));
assert(surface);
#else
#error "Unsupported platform"
#endif


// Find a suitable gpu
auto gpus = apiConnection->getPhysicalDevices();
Expand Down
2 changes: 1 addition & 1 deletion common/CommonAPI.h
Original file line number Diff line number Diff line change
Expand Up @@ -500,7 +500,7 @@ class CommonAPI
#ifdef _NBL_PLATFORM_WINDOWS_
result.windowManager = nbl::core::make_smart_refctd_ptr<nbl::ui::CWindowManagerWin32>(); // on the Android path
#elif defined(_NBL_PLATFORM_LINUX_)
result.windowManager = nbl::core::make_smart_refctd_ptr<nbl::ui::CWindowManagerX11>(); // on the Android path
result.windowManager = nbl::core::make_smart_refctd_ptr<nbl::ui::CWindowManagerXCB>(); // on the Android path
#else
#error "Unsupported platform"
#endif
Expand Down