Skip to content

Commit

Permalink
Separate rendering and windowing
Browse files Browse the repository at this point in the history
  • Loading branch information
tim37021 committed Sep 23, 2017
1 parent 0d4b47d commit 3f9844d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 32 deletions.
14 changes: 2 additions & 12 deletions DEMOS.sln
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2013
VisualStudioVersion = 12.0.40629.0
# Visual Studio 14
VisualStudioVersion = 14.0.25420.1
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cube", "cube.vcxproj", "{B84A5FC9-9C30-4485-A650-4913C5700215}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "cubepp", "cubepp.vcxproj", "{157661F1-12B5-471E-AE1F-FE80D5466618}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "vulkaninfo", "vulkaninfo.vcxproj", "{7D88DD3E-2DC0-4F96-AACB-63A1478627D6}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand All @@ -33,14 +31,6 @@ Global
{157661F1-12B5-471E-AE1F-FE80D5466618}.Release|Win32.Build.0 = Release|Win32
{157661F1-12B5-471E-AE1F-FE80D5466618}.Release|x64.ActiveCfg = Release|x64
{157661F1-12B5-471E-AE1F-FE80D5466618}.Release|x64.Build.0 = Release|x64
{7D88DD3E-2DC0-4F96-AACB-63A1478627D6}.Debug|Win32.ActiveCfg = Debug|Win32
{7D88DD3E-2DC0-4F96-AACB-63A1478627D6}.Debug|Win32.Build.0 = Debug|Win32
{7D88DD3E-2DC0-4F96-AACB-63A1478627D6}.Debug|x64.ActiveCfg = Debug|x64
{7D88DD3E-2DC0-4F96-AACB-63A1478627D6}.Debug|x64.Build.0 = Debug|x64
{7D88DD3E-2DC0-4F96-AACB-63A1478627D6}.Release|Win32.ActiveCfg = Release|Win32
{7D88DD3E-2DC0-4F96-AACB-63A1478627D6}.Release|Win32.Build.0 = Release|Win32
{7D88DD3E-2DC0-4F96-AACB-63A1478627D6}.Release|x64.ActiveCfg = Release|x64
{7D88DD3E-2DC0-4F96-AACB-63A1478627D6}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
35 changes: 15 additions & 20 deletions cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,10 +247,11 @@ struct Demo {
bool loadTexture(const char *, uint8_t *, vk::SubresourceLayout *, int32_t *, int32_t *);
bool memory_type_from_properties(uint32_t, vk::MemoryPropertyFlags, uint32_t *);


#if defined(VK_USE_PLATFORM_WIN32_KHR)
void run();
void create_window();
// MODIFIED BY TIM: We want to completely separate rendering and GUI
//void create_window();
void attach_window(HWND hwnd);
#elif defined(VK_USE_PLATFORM_XLIB_KHR)
void create_xlib_window();
void handle_xlib_event(const XEvent *);
Expand Down Expand Up @@ -386,8 +387,6 @@ struct Demo {

uint32_t current_buffer;
uint32_t queue_family_count;

nana::form_loader<nana::form> ldr;
};

#ifdef _WIN32
Expand Down Expand Up @@ -2418,22 +2417,13 @@ Demo::Demo()
PostQuitMessage(validation_error);
}
}
void Demo::attach_window(HWND hwnd)
{

void Demo::create_window() {
// MODIFIED BY TIM

ldr = nana::form_loader<nana::form>();
nana::form &fm = ldr(nana::API::make_center(width, height));
fm.caption(name);

window = reinterpret_cast<HWND>(fm.native_handle());
///////////////////////////////////////////////////////////

// Window client area size must be at least 1 pixel high, to prevent
// crash.
minsize.x = GetSystemMetrics(SM_CXMINTRACK);
minsize.y = GetSystemMetrics(SM_CYMINTRACK) + 1;
}
window = hwnd;
minsize.x = GetSystemMetrics(SM_CXMINTRACK);
minsize.y = GetSystemMetrics(SM_CYMINTRACK) + 1;
}
#elif defined(VK_USE_PLATFORM_XLIB_KHR)

void Demo::create_xlib_window() {
Expand Down Expand Up @@ -2821,6 +2811,8 @@ void render_thread(Demo &demo, std::atomic<bool> &should_stop)
}
}

#include <nana/gui/timer.hpp>

int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine, int nCmdShow) {
// TODO: Gah.. refactor. This isn't 1989.
MSG msg; // message
Expand Down Expand Up @@ -2874,7 +2866,10 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR pCmdLine,

demo.connection = hInstance;
memcpy((char *)demo.name, (const char *)L"cube", APP_NAME_STR_LEN);
demo.create_window();

nana::form fm(nana::rectangle{0, 0, demo.width, demo.height});
fm.show();
demo.attach_window(reinterpret_cast<HWND>(fm.native_handle()));
demo.init_vk_swapchain();

demo.prepare();
Expand Down

0 comments on commit 3f9844d

Please sign in to comment.