From 4b4e991c39328c0a06feab6ef9b2f9fd6bba881c Mon Sep 17 00:00:00 2001 From: Luke Street Date: Mon, 24 May 2021 22:02:57 -0400 Subject: [PATCH] Fix Windows build --- Runtime/CMain.cpp | 18 +++++++++++++----- imgui/ImGuiEngine.cpp | 1 + imgui/ImGuiShader.shader | 2 +- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/Runtime/CMain.cpp b/Runtime/CMain.cpp index 8d4ffb38a..e99b0cc31 100644 --- a/Runtime/CMain.cpp +++ b/Runtime/CMain.cpp @@ -1,5 +1,6 @@ #include #include +#include #include #include "boo/boo.hpp" @@ -222,6 +223,7 @@ private: Limiter m_limiter{}; std::atomic_bool m_running = {true}; bool m_noShaderWarmup = false; + bool m_imGuiInitialized = false; bool m_firstFrame = true; using delta_clock = std::chrono::high_resolution_clock; @@ -286,13 +288,16 @@ public: onAppIdle(); } - ImGuiEngine::Shutdown(); + if (m_imGuiInitialized) { + ImGuiEngine::Shutdown(); + } + if (g_mainMP1) { + g_mainMP1->Shutdown(); + } + g_mainMP1.reset(); if (m_window) { m_window->getCommandQueue()->stopRenderer(); } - if (g_mainMP1) - g_mainMP1->Shutdown(); - g_mainMP1.reset(); m_voiceEngine.reset(); m_amuseAllocWrapper.reset(); CDvdFile::Shutdown(); @@ -369,6 +374,7 @@ public: g_mainMP1->WarmupShaders(); } ImGuiEngine::Initialize(gfxF, m_window->getWindowFrame(), scale); + m_imGuiInitialized = true; } float dt = 1 / 60.f; @@ -556,6 +562,8 @@ using namespace Windows::ApplicationModel::Core; } #elif _WIN32 +#include + int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) { int argc = 0; const boo::SystemChar** argv; @@ -568,7 +576,7 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE, LPWSTR lpCmdLine, int) { for (int i = 0; i < argc; ++i) booArgv[i + 1] = argv[i]; - const DWORD outType = GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)); + const DWORD outType = GetFileType(GetStdHandle(STD_ERROR_HANDLE)); if (IsClientLoggingEnabled(argc + 1, booArgv) && outType == FILE_TYPE_UNKNOWN) logvisor::CreateWin32Console(); return wmain(argc + 1, booArgv); diff --git a/imgui/ImGuiEngine.cpp b/imgui/ImGuiEngine.cpp index 0311ad67f..5231b2ddb 100644 --- a/imgui/ImGuiEngine.cpp +++ b/imgui/ImGuiEngine.cpp @@ -74,6 +74,7 @@ void ImGuiEngine::Initialize(boo::IGraphicsDataFactory* factory, const boo::SWin void ImGuiEngine::Shutdown() { ImGui::DestroyContext(); + ShaderDataBinding.reset(); ShaderPipeline.reset(); } diff --git a/imgui/ImGuiShader.shader b/imgui/ImGuiShader.shader index 32bfcea75..480d081cb 100644 --- a/imgui/ImGuiShader.shader +++ b/imgui/ImGuiShader.shader @@ -68,7 +68,7 @@ struct VertToFrag float4 col : COLOR0; }; -VertToFrag main(in VS_INPUT v) +VertToFrag main(in VertData v) { VertToFrag vtf; vtf.pos = mul(xf, float4(v.pos.xy, 0.f, 1.f));