From f691da4103b6c2d9c870877cacc7fb57cdb65047 Mon Sep 17 00:00:00 2001 From: "Grayson Riffe (Laptop)" Date: Tue, 14 Dec 2021 21:20:22 -0600 Subject: [PATCH] Added ProdDebug config for end-user debugging; Logger stuff --- Game/Game.vcxproj | 51 +++++++++++++++++++++++- Game/Game.vcxproj.user | 4 ++ NothinFancy/NothinFancy.vcxproj | 58 +++++++++++++++++++++++++++- NothinFancy/src/Application.cpp | 10 ++--- NothinFancy/src/AudioEngine.cpp | 2 +- NothinFancy/src/PhysicsEngine.cpp | 2 +- NothinFancy/src/Utility.cpp | 37 +++++++----------- NothinFancy/src/include/nf/Utility.h | 9 ++--- STEMSln.sln | 7 ++++ 9 files changed, 142 insertions(+), 38 deletions(-) diff --git a/Game/Game.vcxproj b/Game/Game.vcxproj index 11af1ff..973506d 100644 --- a/Game/Game.vcxproj +++ b/Game/Game.vcxproj @@ -5,6 +5,10 @@ Debug x64 + + ProdDebug + x64 + Release x64 @@ -24,6 +28,12 @@ v143 Unicode + + Application + true + v143 + Unicode + Application false @@ -39,6 +49,9 @@ + + + @@ -48,6 +61,11 @@ $(ProjectDir)bin\$(Platform)$(Configuration)\ $(ProjectDir)int\$(Platform)$(Configuration)\ + + $(ProjectDir)bin\$(Platform)$(Configuration)\ + $(ProjectDir)int\$(Platform)$(Configuration)\ + false + false $(ProjectDir)bin\$(Platform)$(Configuration)\ @@ -57,7 +75,7 @@ Level3 true - _DEBUG;_CONSOLE;%(PreprocessorDefinitions) + NFDEBUG;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ $(IntDir)obj\ @@ -78,6 +96,37 @@ if exist "$(OutDir)assets" (rmdir "$(OutDir)assets" /S /Q && goto end) e mkdir "$(OutDir)assets" move "*.nfpack" "$(OutDir)assets\" cd "$(SolutionDir)NothinFancy\assets" +if exist "base.nfpack" (copy "base.nfpack" "$(OutDir)assets\") + + + + + Level3 + true + NFDEBUG;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)src\include\;$(SolutionDir)NothinFancy\src\include\ + $(IntDir)obj\ + true + MultiThreadedDLL + ProgramDatabase + + + Console + true + mainCRTStartup + libcmt.lib + /ignore:4099 %(AdditionalOptions) + UseLinkTimeCodeGeneration + + + cd assets +"$(SolutionDir)NFAssetBuilder\bin\x64Release\NFAssetBuilder.exe" +if exist "$(OutDir)assets" (rmdir "$(OutDir)assets" /S /Q && goto end) else goto end +:end +mkdir "$(OutDir)assets" +move "*.nfpack" "$(OutDir)assets\" +cd "$(SolutionDir)NothinFancy\assets" if exist "base.nfpack" (copy "base.nfpack" "$(OutDir)assets\") diff --git a/Game/Game.vcxproj.user b/Game/Game.vcxproj.user index 2c303bf..20f2914 100644 --- a/Game/Game.vcxproj.user +++ b/Game/Game.vcxproj.user @@ -7,6 +7,10 @@ $(OutDir) WindowsLocalDebugger + + $(OutDir) + WindowsLocalDebugger + $(OutDir) WindowsLocalDebugger diff --git a/NothinFancy/NothinFancy.vcxproj b/NothinFancy/NothinFancy.vcxproj index 1e6d76e..a79a4d6 100644 --- a/NothinFancy/NothinFancy.vcxproj +++ b/NothinFancy/NothinFancy.vcxproj @@ -5,6 +5,10 @@ Debug x64 + + ProdDebug + x64 + Release x64 @@ -31,6 +35,13 @@ true Unicode + + StaticLibrary + false + v143 + true + Unicode + @@ -42,6 +53,9 @@ + + + true @@ -53,11 +67,16 @@ $(ProjectDir)bin\$(Platform)$(Configuration)\ $(ProjectDir)int\$(Platform)$(Configuration)\ + + false + $(ProjectDir)bin\$(Platform)$(Configuration)\ + $(ProjectDir)int\$(Platform)$(Configuration)\ + Level3 true - GLEW_STATIC;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) + NFDEBUG;GLEW_STATIC;_DEBUG;_CONSOLE;%(PreprocessorDefinitions) true $(ProjectDir)src\include\;$(ProjectDir)dep\include\ $(IntDir)obj\ @@ -116,6 +135,43 @@ cd assets +"$(SolutionDir)NFAssetBuilder\bin\x64Release\NFAssetBuilder.exe" + + + + + Level3 + true + true + true + NFDEBUG;GLEW_STATIC;NDEBUG;_CONSOLE;%(PreprocessorDefinitions) + true + $(ProjectDir)src\include\;$(ProjectDir)dep\include\ + $(IntDir)obj\ + true + true + false + + + Console + true + true + true + + + glew32s.lib;opengl32.lib;freetype.lib;xaudio2.lib;Cabinet.lib;libogg.lib;libvorbis.lib;libvorbisfile.lib;PhysXFoundation.lib;PhysXCommon.lib;PhysX.lib;PhysXCooking.lib;PhysXExtensions.lib;%(AdditionalDependencies) + + + $(ProjectDir)dep\lib\Release;%(AdditionalLibraryDirectories) + /ignore:4006 %(AdditionalOptions) + false + + + true + + + + cd assets "$(SolutionDir)NFAssetBuilder\bin\x64Release\NFAssetBuilder.exe" diff --git a/NothinFancy/src/Application.cpp b/NothinFancy/src/Application.cpp index d1c3caf..90e0276 100644 --- a/NothinFancy/src/Application.cpp +++ b/NothinFancy/src/Application.cpp @@ -80,7 +80,7 @@ namespace nf { void Application::run() { NFLog("Running application..."); -#ifdef _DEBUG +#ifdef NFDEBUG Debug::startTimer(); SetThreadDescription(GetCurrentThread(), L"Input Thread"); SetConsoleTitle(toWide("Nothin' Fancy v" + (std::string)NFVERSION).data()); @@ -115,9 +115,10 @@ namespace nf { std::this_thread::sleep_for(std::chrono::milliseconds(5)); } mainThread.join(); -#ifdef _DEBUG +#ifdef NFDEBUG Debug::stopTimer(); #endif + NFLog("Exited application"); } bool Application::hasCustomWindowIcon() { @@ -312,7 +313,7 @@ namespace nf { } void Application::runMainGameThread() { -#ifdef _DEBUG +#ifdef NFDEBUG SetThreadDescription(GetCurrentThread(), L"Main Engine Thread"); #endif m_renderer = new Renderer(this); @@ -341,7 +342,7 @@ namespace nf { m_fpsDuration = m_fpsClock2 - m_fpsClock1; if (m_fpsDuration.count() >= 0.2) { m_FPS = (int)std::round(1.0 / m_deltaTime); -#ifdef _DEBUG +#ifdef NFDEBUG static int i = 0; i++; if (i % 5 == 0) @@ -452,7 +453,6 @@ namespace nf { break; } case WM_CLOSE: { - NFLog("Exiting NF application"); DestroyWindow(hWnd); return 0; } diff --git a/NothinFancy/src/AudioEngine.cpp b/NothinFancy/src/AudioEngine.cpp index 0444040..9274f30 100644 --- a/NothinFancy/src/AudioEngine.cpp +++ b/NothinFancy/src/AudioEngine.cpp @@ -59,7 +59,7 @@ namespace nf { } void AudioEngine::runAudioThread() { -#ifdef _DEBUG +#ifdef NFDEBUG SetThreadDescription(GetCurrentThread(), L"Audio Thread"); #endif //Wait to initialize stuff until the master voice is created if it hasn't been already diff --git a/NothinFancy/src/PhysicsEngine.cpp b/NothinFancy/src/PhysicsEngine.cpp index 1e67c70..8276ad4 100644 --- a/NothinFancy/src/PhysicsEngine.cpp +++ b/NothinFancy/src/PhysicsEngine.cpp @@ -7,7 +7,7 @@ namespace nf { class PhysicsErrorCallback : public PxErrorCallback { virtual void reportError(PxErrorCode::Enum code, const char* message, const char* file, int line) { -#ifdef _DEBUG +#ifdef NFDEBUG Debug::ErrorImp(message, file, line); __debugbreak(); #else diff --git a/NothinFancy/src/Utility.cpp b/NothinFancy/src/Utility.cpp index d68b10b..243c7d0 100644 --- a/NothinFancy/src/Utility.cpp +++ b/NothinFancy/src/Utility.cpp @@ -16,8 +16,10 @@ namespace nf { static const float deg2rad = (float)M_PI / 180.0f; -#ifdef _DEBUG - NFDEBUGINIT; +#ifdef NFDEBUG + std::chrono::steady_clock::time_point Debug::m_initTime = std::chrono::high_resolution_clock::now(); + bool Debug::m_timerStarted = false; + static HANDLE cmd = GetStdHandle(STD_OUTPUT_HANDLE); void Debug::startTimer() { m_timerStarted = true; @@ -31,45 +33,34 @@ namespace nf { void Debug::LogImp(const char* in) { if(m_timerStarted) printCurrentTime(); - std::printf("NF Log: %s\n", in); + std::printf("NF "); + SetConsoleTextAttribute(cmd, 6); + std::printf("Log: "); + SetConsoleTextAttribute(cmd, 7); + std::printf("%s\n", in); } void Debug::LogImp(const std::string& in) { - if (m_timerStarted) - printCurrentTime(); - std::printf("NF Log: "); - std::cout << in << "\n"; + LogImp(in.c_str()); } void Debug::LogImp(int in) { - if (m_timerStarted) - printCurrentTime(); - std::printf("NF Log: %i\n", in); + LogImp(std::to_string(in)); } void Debug::LogImp(float in) { - if (m_timerStarted) - printCurrentTime(); - std::printf("NF Log: %.4f\n", in); + LogImp(std::to_string(in)); } //TODO: Test every Error in release mode void Debug::ErrorImp(const char* in, const char* filename, int line) { if (m_timerStarted) printCurrentTime(); - static HANDLE cmd = GetStdHandle(STD_OUTPUT_HANDLE); SetConsoleTextAttribute(cmd, FOREGROUND_RED); std::printf("NF Error (%s, %i): %s\n", filename, line, in); - SetConsoleTextAttribute(cmd, 7); } void Debug::ErrorImp(const std::string& in, const char* filename, int line) { - if (m_timerStarted) - printCurrentTime(); - static HANDLE cmd = GetStdHandle(STD_OUTPUT_HANDLE); - SetConsoleTextAttribute(cmd, FOREGROUND_RED); - std::printf("NF Error (%s, %i): ", filename, line); - std::cout << in << "\n"; - SetConsoleTextAttribute(cmd, 7); + ErrorImp(in.c_str(), filename, line); } void Debug::printCurrentTime() { @@ -91,7 +82,7 @@ namespace nf { if (!m_loading) NFLog("\"" + m_funcName + (std::string)"\" took " + std::to_string(dur.count() * 1000.0f) + (std::string)" ms."); else - NFLog("Loading took " + std::to_string(dur.count()) + (std::string)" seconds."); + NFLog("Loading state took " + std::to_string(dur.count()) + (std::string)" seconds."); } #endif diff --git a/NothinFancy/src/include/nf/Utility.h b/NothinFancy/src/include/nf/Utility.h index 9aa3a97..d002928 100644 --- a/NothinFancy/src/include/nf/Utility.h +++ b/NothinFancy/src/include/nf/Utility.h @@ -21,12 +21,9 @@ namespace nf { * Current version of the engine in the format major.minor.patch */ #define NFVERSION "0.5.0" -#if defined(_DEBUG) || defined(doxygen) +#if defined(NFDEBUG) || defined(doxygen) //Strips __FILE__ down to only the name of the file #define __FILENAME__ strrchr(__FILE__, '\\') + 1 -//Initializes static variables needed for debugging -#define NFDEBUGINIT std::chrono::steady_clock::time_point Debug::m_initTime = std::chrono::high_resolution_clock::now(); \ -bool Debug::m_timerStarted = false /** * @defgroup macros Macros * @@ -113,7 +110,7 @@ __debugbreak();} #define NFSleepS(x) #define NFSleepMS(x) #define NFLog(x) -#define NFError(x) {MessageBox(FindWindow(L"NFClass", NULL), toWide(x).data(), L"NF Engine Error", MB_OK | MB_ICONERROR);\ +#define NFError(x) {MessageBox(FindWindow(L"NFClass", NULL), nf::toWide(x).data(), L"NF Engine Error", MB_OK | MB_ICONERROR);\ std::exit(-1);} #define NFTimeFunc #define NFTimerLoad @@ -414,9 +411,9 @@ std::exit(-1);} float w; }; -#ifndef NFIMPL const std::wstring toWide(const char* in); const std::wstring toWide(const std::string& in); +#ifndef NFIMPL Vec4 degToQuat(const Vec3& in); #endif diff --git a/STEMSln.sln b/STEMSln.sln index 5c0f53b..c66b0af 100644 --- a/STEMSln.sln +++ b/STEMSln.sln @@ -15,19 +15,26 @@ EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|x64 = Debug|x64 + ProdDebug|x64 = ProdDebug|x64 Release|x64 = Release|x64 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Debug|x64.ActiveCfg = Debug|x64 {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Debug|x64.Build.0 = Debug|x64 + {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.ProdDebug|x64.ActiveCfg = ProdDebug|x64 + {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.ProdDebug|x64.Build.0 = ProdDebug|x64 {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Release|x64.ActiveCfg = Release|x64 {1B9C5361-E301-41BF-97E7-56D65F11E2BB}.Release|x64.Build.0 = Release|x64 {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Debug|x64.ActiveCfg = Debug|x64 {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Debug|x64.Build.0 = Debug|x64 + {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.ProdDebug|x64.ActiveCfg = ProdDebug|x64 + {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.ProdDebug|x64.Build.0 = ProdDebug|x64 {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x64.ActiveCfg = Release|x64 {B7FEC2D6-1D8F-487E-89CB-FD611FD1AEB6}.Release|x64.Build.0 = Release|x64 {771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x64.ActiveCfg = Release|x64 {771B4AEE-E2C6-4745-AC40-1EF57149612E}.Debug|x64.Build.0 = Release|x64 + {771B4AEE-E2C6-4745-AC40-1EF57149612E}.ProdDebug|x64.ActiveCfg = Release|x64 + {771B4AEE-E2C6-4745-AC40-1EF57149612E}.ProdDebug|x64.Build.0 = Release|x64 {771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x64.ActiveCfg = Release|x64 {771B4AEE-E2C6-4745-AC40-1EF57149612E}.Release|x64.Build.0 = Release|x64 EndGlobalSection