allocate application on heap instead of stack and delete it
This prevents problems with Vulkan debug layers that don't like Vulkan calls to happen during C++ app shutdown.
This commit is contained in:
+27
-21
@@ -27,34 +27,34 @@ public:
|
||||
{
|
||||
return graphicsDevice == nullptr ? "(no device)" : graphicsDevice->GetDriverDescription().c_str();
|
||||
}
|
||||
} editor;
|
||||
}* editor;
|
||||
|
||||
int sdl_loop()
|
||||
{
|
||||
while (editor.KeepRunning())
|
||||
while (editor->KeepRunning())
|
||||
{
|
||||
editor.Run();
|
||||
editor->Run();
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event)){
|
||||
bool textinput_action_delete = false;
|
||||
wi::input::sdlinput::ProcessEvent(event);
|
||||
switch(event.type){
|
||||
case SDL_QUIT:
|
||||
editor.Exit();
|
||||
editor->Exit();
|
||||
break;
|
||||
case SDL_WINDOWEVENT:
|
||||
switch (event.window.event) {
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
// Tells the engine to reload window configuration (size and dpi)
|
||||
editor.SetWindow(editor.window);
|
||||
editor.SaveWindowSize();
|
||||
editor->SetWindow(editor->window);
|
||||
editor->SaveWindowSize();
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST:
|
||||
editor.is_window_active = false;
|
||||
editor->is_window_active = false;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
editor.is_window_active = true;
|
||||
editor.HotReload();
|
||||
editor->is_window_active = true;
|
||||
editor->HotReload();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -71,7 +71,7 @@ int sdl_loop()
|
||||
// wi::input::Update was run, which will happen next
|
||||
// frame, which is too late for us. So we just call it
|
||||
// now and then call AddInput
|
||||
wi::input::Update(editor.window, editor.canvas);
|
||||
wi::input::Update(editor->window, editor->canvas);
|
||||
wi::gui::TextInputField::AddInput('?'); // AddInput actually ignores the argument when Ctrl is pressed
|
||||
}
|
||||
break;
|
||||
@@ -83,8 +83,8 @@ int sdl_loop()
|
||||
}
|
||||
break;
|
||||
case SDL_DROPFILE:
|
||||
editor.renderComponent.Open(event.drop.file);
|
||||
editor.is_window_active = true;
|
||||
editor->renderComponent.Open(event.drop.file);
|
||||
editor->is_window_active = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -164,8 +164,8 @@ void crash_handler(int sig)
|
||||
"Stacktrace:\n",
|
||||
sig, sigdescr_np(sig),
|
||||
wi::version::GetVersionString(),
|
||||
editor.GetAdapterName(),
|
||||
editor.GetDriverDescription()
|
||||
editor->GetAdapterName(),
|
||||
editor->GetDriverDescription()
|
||||
);
|
||||
|
||||
fprintf(
|
||||
@@ -222,6 +222,8 @@ int main(int argc, char *argv[])
|
||||
|
||||
wi::arguments::Parse(argc, argv);
|
||||
|
||||
editor = new EditorWithDevInfo();
|
||||
|
||||
sdl2::sdlsystem_ptr_t system = sdl2::make_sdlsystem(SDL_INIT_EVERYTHING | SDL_INIT_EVENTS);
|
||||
if (*system) {
|
||||
wilog_error("Error creating SDL2 system");
|
||||
@@ -232,15 +234,15 @@ int main(int argc, char *argv[])
|
||||
bool fullscreen = false;
|
||||
|
||||
wi::Timer timer;
|
||||
if (editor.config.Open("config.ini"))
|
||||
if (editor->config.Open("config.ini"))
|
||||
{
|
||||
if (editor.config.Has("width"))
|
||||
if (editor->config.Has("width"))
|
||||
{
|
||||
width = editor.config.GetInt("width");
|
||||
height = editor.config.GetInt("height");
|
||||
width = editor->config.GetInt("width");
|
||||
height = editor->config.GetInt("height");
|
||||
}
|
||||
fullscreen = editor.config.GetBool("fullscreen");
|
||||
editor.allow_hdr = editor.config.GetBool("allow_hdr");
|
||||
fullscreen = editor->config.GetBool("fullscreen");
|
||||
editor->allow_hdr = editor->config.GetBool("allow_hdr");
|
||||
|
||||
wilog("config.ini loaded in %.2f milliseconds\n", (float)timer.elapsed_milliseconds());
|
||||
}
|
||||
@@ -266,11 +268,15 @@ int main(int argc, char *argv[])
|
||||
SDL_SetWindowFullscreen(window.get(), SDL_WINDOW_FULLSCREEN_DESKTOP);
|
||||
}
|
||||
|
||||
editor.SetWindow(window.get());
|
||||
editor->SetWindow(window.get());
|
||||
|
||||
int ret = sdl_loop();
|
||||
|
||||
wi::jobsystem::ShutDown();
|
||||
|
||||
// explicitly deleting prevents issues with Vulkan debug layers (debugdevice)
|
||||
// which don't like vulkan calls happening during C++ application shutdown
|
||||
delete editor;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
+30
-25
@@ -6,14 +6,15 @@
|
||||
|
||||
#pragma comment(lib, "dwmapi.lib")
|
||||
|
||||
Editor editor;
|
||||
Editor* editor;
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
wi::arguments::Parse(lpCmdLine);
|
||||
editor = new Editor();
|
||||
|
||||
SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
|
||||
@@ -22,10 +23,10 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
{
|
||||
case WM_SIZE:
|
||||
case WM_DPICHANGED:
|
||||
if (editor.is_window_active && LOWORD(lParam) > 0 && HIWORD(lParam) > 0)
|
||||
if (editor->is_window_active && LOWORD(lParam) > 0 && HIWORD(lParam) > 0)
|
||||
{
|
||||
editor.SetWindow(hWnd);
|
||||
editor.SaveWindowSize();
|
||||
editor->SetWindow(hWnd);
|
||||
editor->SaveWindowSize();
|
||||
}
|
||||
break;
|
||||
case WM_CHAR:
|
||||
@@ -43,7 +44,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
break;
|
||||
case WM_INPUT:
|
||||
if (editor.is_window_active)
|
||||
if (editor->is_window_active)
|
||||
{
|
||||
wi::input::rawinput::ParseMessage((void*)lParam);
|
||||
}
|
||||
@@ -63,11 +64,11 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
break;
|
||||
case WM_KILLFOCUS:
|
||||
editor.is_window_active = false;
|
||||
editor->is_window_active = false;
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
editor.is_window_active = true;
|
||||
editor.HotReload();
|
||||
editor->is_window_active = true;
|
||||
editor->HotReload();
|
||||
break;
|
||||
case WM_DROPFILES:
|
||||
{
|
||||
@@ -85,13 +86,13 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
std::string filename;
|
||||
wi::helper::StringConvert(wfilename, filename);
|
||||
editor.renderComponent.Open(filename);
|
||||
editor->renderComponent.Open(filename);
|
||||
}
|
||||
SetForegroundWindow(hWnd);
|
||||
}
|
||||
break;
|
||||
case WM_CLOSE:
|
||||
editor.Exit();
|
||||
editor->Exit();
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
@@ -118,7 +119,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
case WM_SYSCHAR:
|
||||
case WM_SYSKEYDOWN:
|
||||
case WM_SYSKEYUP:
|
||||
if (editor.config.GetBool("bypass_system_key") && wParam != VK_F4)
|
||||
if (editor->config.GetBool("bypass_system_key") && wParam != VK_F4)
|
||||
{
|
||||
// Handle system key messages (like Alt key) to prevent menu bar activation freeze
|
||||
// Return 0 to indicate we processed the message and prevent default behavior
|
||||
@@ -171,16 +172,16 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
bool borderless = false;
|
||||
|
||||
wi::Timer timer;
|
||||
if (editor.config.Open("config.ini"))
|
||||
if (editor->config.Open("config.ini"))
|
||||
{
|
||||
if (editor.config.Has("width"))
|
||||
if (editor->config.Has("width"))
|
||||
{
|
||||
width = editor.config.GetInt("width");
|
||||
height = editor.config.GetInt("height");
|
||||
width = editor->config.GetInt("width");
|
||||
height = editor->config.GetInt("height");
|
||||
}
|
||||
fullscreen = editor.config.GetBool("fullscreen");
|
||||
borderless = editor.config.GetBool("borderless");
|
||||
editor.allow_hdr = editor.config.GetBool("allow_hdr");
|
||||
fullscreen = editor->config.GetBool("fullscreen");
|
||||
borderless = editor->config.GetBool("borderless");
|
||||
editor->allow_hdr = editor->config.GetBool("allow_hdr");
|
||||
|
||||
wilog("config.ini loaded in %.2f milliseconds\n", (float)timer.elapsed_milliseconds());
|
||||
}
|
||||
@@ -237,11 +238,11 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
UpdateWindow(hWnd);
|
||||
DragAcceptFiles(hWnd, TRUE);
|
||||
|
||||
editor.SetWindow(hWnd);
|
||||
editor->SetWindow(hWnd);
|
||||
|
||||
MSG msg = { 0 };
|
||||
|
||||
while (editor.KeepRunning())
|
||||
while (editor->KeepRunning())
|
||||
{
|
||||
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) {
|
||||
TranslateMessage(&msg);
|
||||
@@ -249,12 +250,16 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
else {
|
||||
|
||||
editor.Run();
|
||||
editor->Run();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
wi::jobsystem::ShutDown();
|
||||
|
||||
return (int)msg.wParam;
|
||||
// explicitly deleting prevents issues with Vulkan debug layers (debugdevice)
|
||||
// which don't like vulkan calls happening during C++ application shutdown
|
||||
delete editor;
|
||||
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
#include "sdl2.h"
|
||||
#include "ImGui/imgui_impl_sdl.h"
|
||||
|
||||
Example_ImGui exampleImGui;
|
||||
Example_ImGui* exampleImGui;
|
||||
|
||||
int sdl_loop()
|
||||
{
|
||||
bool quit = false;
|
||||
while (!quit)
|
||||
{
|
||||
exampleImGui.Run();
|
||||
exampleImGui->Run();
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event)){
|
||||
switch(event.type){
|
||||
@@ -26,13 +26,13 @@ int sdl_loop()
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
// Tells the engine to reload window configuration (size and dpi)
|
||||
exampleImGui.SetWindow(exampleImGui.window);
|
||||
exampleImGui->SetWindow(exampleImGui->window);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST: //TODO
|
||||
exampleImGui.is_window_active = false;
|
||||
exampleImGui->is_window_active = false;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
exampleImGui.is_window_active = true;
|
||||
exampleImGui->is_window_active = true;
|
||||
if (wi::shadercompiler::GetRegisteredShaderCount() > 0)
|
||||
{
|
||||
std::thread([] {
|
||||
@@ -70,7 +70,7 @@ int main(int argc, char *argv[])
|
||||
// TODO: Place code here.
|
||||
|
||||
wi::arguments::Parse(argc, argv);
|
||||
|
||||
exampleImGui = new Example_ImGui();
|
||||
sdl2::sdlsystem_ptr_t system = sdl2::make_sdlsystem(SDL_INIT_EVERYTHING | SDL_INIT_EVENTS);
|
||||
if (*system) {
|
||||
wilog_error("Error creating SDL2 system");
|
||||
@@ -85,10 +85,10 @@ int main(int argc, char *argv[])
|
||||
wilog_error("Error creating window");
|
||||
}
|
||||
|
||||
exampleImGui.SetWindow(window.get());
|
||||
exampleImGui->SetWindow(window.get());
|
||||
|
||||
int ret = sdl_loop();
|
||||
|
||||
delete exampleImGui;
|
||||
SDL_Quit();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
HINSTANCE hInst; // current instance
|
||||
WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
|
||||
WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
|
||||
Example_ImGui example_imgui;
|
||||
Example_ImGui* example_imgui;
|
||||
|
||||
// Forward declarations of functions included in this code module:
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
||||
@@ -28,6 +28,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
example_imgui = new Example_ImGui();
|
||||
// TODO: Place code here.
|
||||
|
||||
BOOL dpi_success = SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
@@ -59,7 +60,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
else {
|
||||
|
||||
example_imgui.Run();
|
||||
example_imgui->Run();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -115,8 +116,8 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
example_imgui.allow_hdr = false; // Imgui doesn't support HDR
|
||||
example_imgui.SetWindow(hWnd);
|
||||
example_imgui->allow_hdr = false; // Imgui doesn't support HDR
|
||||
example_imgui->SetWindow(hWnd);
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
UpdateWindow(hWnd);
|
||||
@@ -163,8 +164,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
case WM_SIZE:
|
||||
case WM_DPICHANGED:
|
||||
if (example_imgui.is_window_active)
|
||||
example_imgui.SetWindow(hWnd);
|
||||
if (example_imgui->is_window_active)
|
||||
example_imgui->SetWindow(hWnd);
|
||||
break;
|
||||
case WM_CHAR:
|
||||
switch (wParam)
|
||||
@@ -186,10 +187,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
wi::input::rawinput::ParseMessage((void*)lParam);
|
||||
break;
|
||||
case WM_KILLFOCUS:
|
||||
example_imgui.is_window_active = false;
|
||||
example_imgui->is_window_active = false;
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
example_imgui.is_window_active = true;
|
||||
example_imgui->is_window_active = true;
|
||||
break;
|
||||
case WM_PAINT:
|
||||
{
|
||||
@@ -205,6 +206,7 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
default:
|
||||
return DefWindowProc(hWnd, message, wParam, lParam);
|
||||
}
|
||||
delete example_imgui;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
@@ -2,14 +2,14 @@
|
||||
#include "sdl2.h"
|
||||
#include "ImGui/imgui_impl_sdl.h"
|
||||
|
||||
Example_ImGui exampleImGui;
|
||||
Example_ImGui* exampleImGui;
|
||||
|
||||
int sdl_loop()
|
||||
{
|
||||
bool quit = false;
|
||||
while (!quit)
|
||||
{
|
||||
exampleImGui.Run();
|
||||
exampleImGui->Run();
|
||||
SDL_Event event;
|
||||
while(SDL_PollEvent(&event)){
|
||||
switch(event.type){
|
||||
@@ -23,13 +23,13 @@ int sdl_loop()
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
// Tells the engine to reload window configuration (size and dpi)
|
||||
exampleImGui.SetWindow(exampleImGui.window);
|
||||
exampleImGui->SetWindow(exampleImGui->window);
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_LOST: //TODO
|
||||
exampleImGui.is_window_active = false;
|
||||
exampleImGui->is_window_active = false;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_FOCUS_GAINED:
|
||||
exampleImGui.is_window_active = true;
|
||||
exampleImGui->is_window_active = true;
|
||||
if (wi::shadercompiler::GetRegisteredShaderCount() > 0)
|
||||
{
|
||||
std::thread([] {
|
||||
@@ -66,6 +66,7 @@ int main(int argc, char *argv[])
|
||||
{
|
||||
// TODO: Place code here.
|
||||
|
||||
exampleImGui = new Example_ImGui();
|
||||
wi::arguments::Parse(argc, argv);
|
||||
|
||||
sdl2::sdlsystem_ptr_t system = sdl2::make_sdlsystem(SDL_INIT_EVERYTHING | SDL_INIT_EVENTS);
|
||||
@@ -82,10 +83,11 @@ int main(int argc, char *argv[])
|
||||
wilog_error("Error creating window");
|
||||
}
|
||||
|
||||
exampleImGui.SetWindow(window.get());
|
||||
exampleImGui->SetWindow(window.get());
|
||||
|
||||
int ret = sdl_loop();
|
||||
|
||||
delete exampleImGui;
|
||||
SDL_Quit();
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
HINSTANCE hInst; // current instance
|
||||
WCHAR szTitle[MAX_LOADSTRING]; // The title bar text
|
||||
WCHAR szWindowClass[MAX_LOADSTRING]; // the main window class name
|
||||
Example_ImGui example_imgui;
|
||||
Example_ImGui* example_imgui;
|
||||
|
||||
// Forward declarations of functions included in this code module:
|
||||
ATOM MyRegisterClass(HINSTANCE hInstance);
|
||||
@@ -28,6 +28,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
UNREFERENCED_PARAMETER(hPrevInstance);
|
||||
UNREFERENCED_PARAMETER(lpCmdLine);
|
||||
|
||||
example_imgui = new Example_ImGui();
|
||||
// TODO: Place code here.
|
||||
|
||||
BOOL dpi_success = SetProcessDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
|
||||
@@ -59,11 +60,11 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
else {
|
||||
|
||||
example_imgui.Run();
|
||||
example_imgui->Run();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
delete example_imgui;
|
||||
return (int) msg.wParam;
|
||||
}
|
||||
|
||||
@@ -117,14 +118,14 @@ BOOL InitInstance(HINSTANCE hInstance, int nCmdShow)
|
||||
HWND hWnd = CreateWindowW(szWindowClass, szTitle, WS_OVERLAPPEDWINDOW,
|
||||
rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, nullptr, nullptr, hInstance, nullptr);
|
||||
|
||||
|
||||
|
||||
if (!hWnd)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
example_imgui.allow_hdr = false; // Imgui doesn't support HDR
|
||||
example_imgui.SetWindow(hWnd);
|
||||
example_imgui->allow_hdr = false; // Imgui doesn't support HDR
|
||||
example_imgui->SetWindow(hWnd);
|
||||
|
||||
ShowWindow(hWnd, nCmdShow);
|
||||
UpdateWindow(hWnd);
|
||||
@@ -171,8 +172,8 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
break;
|
||||
case WM_SIZE:
|
||||
case WM_DPICHANGED:
|
||||
if (example_imgui.is_window_active)
|
||||
example_imgui.SetWindow(hWnd);
|
||||
if (example_imgui->is_window_active)
|
||||
example_imgui->SetWindow(hWnd);
|
||||
break;
|
||||
case WM_CHAR:
|
||||
switch (wParam)
|
||||
@@ -194,10 +195,10 @@ LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
|
||||
wi::input::rawinput::ParseMessage((void*)lParam);
|
||||
break;
|
||||
case WM_KILLFOCUS:
|
||||
example_imgui.is_window_active = false;
|
||||
example_imgui->is_window_active = false;
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
example_imgui.is_window_active = true;
|
||||
example_imgui->is_window_active = true;
|
||||
break;
|
||||
case WM_PAINT:
|
||||
{
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
#include "WickedEngine.h"
|
||||
#include <SDL2/SDL.h>
|
||||
|
||||
wi::Application application;
|
||||
wi::Application* application;
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
application = new wi::Application();
|
||||
// SDL window setup:
|
||||
sdl2::sdlsystem_ptr_t system = sdl2::make_sdlsystem(SDL_INIT_EVERYTHING | SDL_INIT_EVENTS);
|
||||
sdl2::window_ptr_t window = sdl2::make_window(
|
||||
@@ -16,22 +17,22 @@ int main(int argc, char *argv[])
|
||||
SDL_Event event;
|
||||
|
||||
// set SDL window to engine:
|
||||
application.SetWindow(window.get());
|
||||
application->SetWindow(window.get());
|
||||
|
||||
// process command line string:
|
||||
wi::arguments::Parse(argc, argv);
|
||||
|
||||
// just show some basic info:
|
||||
application.infoDisplay.active = true;
|
||||
application.infoDisplay.watermark = true;
|
||||
application.infoDisplay.resolution = true;
|
||||
application.infoDisplay.fpsinfo = true;
|
||||
application->infoDisplay.active = true;
|
||||
application->infoDisplay.watermark = true;
|
||||
application->infoDisplay.resolution = true;
|
||||
application->infoDisplay.fpsinfo = true;
|
||||
|
||||
bool quit = false;
|
||||
while (!quit)
|
||||
{
|
||||
SDL_PumpEvents();
|
||||
application.Run();
|
||||
application->Run();
|
||||
|
||||
SDL_Event event;
|
||||
while (SDL_PollEvent(&event))
|
||||
@@ -48,7 +49,7 @@ int main(int argc, char *argv[])
|
||||
quit = true;
|
||||
break;
|
||||
case SDL_WINDOWEVENT_RESIZED:
|
||||
application.SetWindow(application.window);
|
||||
application->SetWindow(application->window);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -62,6 +63,10 @@ int main(int argc, char *argv[])
|
||||
|
||||
wi::jobsystem::ShutDown(); // waits for jobs to finish before shutdown
|
||||
|
||||
// explicitly deleting prevents issues with Vulkan debug layers (debugdevice)
|
||||
// which don't like vulkan calls happening during C++ application shutdown
|
||||
delete application;
|
||||
|
||||
SDL_Quit();
|
||||
|
||||
return 0;
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
#include "WickedEngine.h"
|
||||
|
||||
wi::Application application;
|
||||
wi::Application* application;
|
||||
|
||||
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
_In_opt_ HINSTANCE hPrevInstance,
|
||||
_In_ LPWSTR lpCmdLine,
|
||||
_In_ int nCmdShow)
|
||||
{
|
||||
application = new wi::Application();
|
||||
// Win32 window and message loop setup:
|
||||
static auto WndProc = [](HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) -> LRESULT
|
||||
{
|
||||
@@ -14,8 +15,8 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
{
|
||||
case WM_SIZE:
|
||||
case WM_DPICHANGED:
|
||||
if (application.is_window_active)
|
||||
application.SetWindow(hWnd);
|
||||
if (application->is_window_active)
|
||||
application->SetWindow(hWnd);
|
||||
break;
|
||||
case WM_CHAR:
|
||||
switch (wParam)
|
||||
@@ -37,10 +38,10 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
wi::input::rawinput::ParseMessage((void*)lParam);
|
||||
break;
|
||||
case WM_KILLFOCUS:
|
||||
application.is_window_active = false;
|
||||
application->is_window_active = false;
|
||||
break;
|
||||
case WM_SETFOCUS:
|
||||
application.is_window_active = true;
|
||||
application->is_window_active = true;
|
||||
break;
|
||||
case WM_DESTROY:
|
||||
PostQuitMessage(0);
|
||||
@@ -69,16 +70,16 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
ShowWindow(hWnd, SW_SHOWDEFAULT);
|
||||
|
||||
// set Win32 window to engine:
|
||||
application.SetWindow(hWnd);
|
||||
application->SetWindow(hWnd);
|
||||
|
||||
// process command line string:
|
||||
wi::arguments::Parse(lpCmdLine);
|
||||
|
||||
// just show some basic info:
|
||||
application.infoDisplay.active = true;
|
||||
application.infoDisplay.watermark = true;
|
||||
application.infoDisplay.resolution = true;
|
||||
application.infoDisplay.fpsinfo = true;
|
||||
application->infoDisplay.active = true;
|
||||
application->infoDisplay.watermark = true;
|
||||
application->infoDisplay.resolution = true;
|
||||
application->infoDisplay.fpsinfo = true;
|
||||
|
||||
MSG msg = { 0 };
|
||||
while (msg.message != WM_QUIT)
|
||||
@@ -89,12 +90,16 @@ int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
|
||||
}
|
||||
else {
|
||||
|
||||
application.Run();
|
||||
application->Run();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
wi::jobsystem::ShutDown(); // waits for jobs to finish before shutdown
|
||||
// explicitly deleting prevents issues with Vulkan debug layers (debugdevice)
|
||||
// which don't like vulkan calls happening during C++ application shutdown
|
||||
delete application;
|
||||
|
||||
|
||||
return (int)msg.wParam;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user