From 3e16116fd369ad3cf3600b2c3015daa3cea80e63 Mon Sep 17 00:00:00 2001 From: assiduous Date: Wed, 25 Dec 2019 14:30:37 -0800 Subject: Native app: added gloden image processing --- NativeApp/include/AppBase.h | 17 +++++++++++++++++ NativeApp/src/Win32/WinMain.cpp | 21 ++++++++++++++++++--- TextureLoader/src/Image.cpp | 8 ++++++-- 3 files changed, 41 insertions(+), 5 deletions(-) diff --git a/NativeApp/include/AppBase.h b/NativeApp/include/AppBase.h index 634de48..60cf937 100644 --- a/NativeApp/include/AppBase.h +++ b/NativeApp/include/AppBase.h @@ -29,6 +29,13 @@ namespace Diligent class AppBase { public: + enum class GoldenImageMode + { + None = 0, + Capture, + Compare + }; + virtual ~AppBase() {} virtual void ProcessCommandLine(const char* CmdLine) = 0; @@ -42,6 +49,16 @@ public: width = 0; height = 0; } + + virtual GoldenImageMode GetGoldenImageMode() const + { + return GoldenImageMode::None; + } + + virtual int GetExitCode() const + { + return 0; + } }; } // namespace Diligent diff --git a/NativeApp/src/Win32/WinMain.cpp b/NativeApp/src/Win32/WinMain.cpp index 63dd01c..3545c53 100644 --- a/NativeApp/src/Win32/WinMain.cpp +++ b/NativeApp/src/Win32/WinMain.cpp @@ -23,6 +23,8 @@ #include #include +#include + #include #include #include "NativeAppBase.h" @@ -72,13 +74,26 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int cmdShow) rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, instance, NULL); if (!wnd) { - MessageBoxA(NULL, "Cannot create window", "Error", MB_OK | MB_ICONERROR); - return 0; + std::cerr << "Failed to create a window"; + return 1; + } + + g_pTheApp->OnWindowCreated(wnd, WindowWidth, WindowHeight); + + auto GoldenImgMode = g_pTheApp->GetGoldenImageMode(); + if (GoldenImgMode != NativeAppBase::GoldenImageMode::None) + { + g_pTheApp->Update(0, 0); + g_pTheApp->Render(); + g_pTheApp->Present(); + auto ExitCode = g_pTheApp->GetExitCode(); + g_pTheApp.reset(); + return ExitCode; } + ShowWindow(wnd, cmdShow); UpdateWindow(wnd); - g_pTheApp->OnWindowCreated(wnd, WindowWidth, WindowHeight); AppTitle = g_pTheApp->GetAppTitle(); Diligent::Timer Timer; diff --git a/TextureLoader/src/Image.cpp b/TextureLoader/src/Image.cpp index 6472fd7..a5e4414 100644 --- a/TextureLoader/src/Image.cpp +++ b/TextureLoader/src/Image.cpp @@ -477,11 +477,15 @@ Image::Image(IReferenceCounters* pRefCounters, } else if (LoadInfo.Format == EImageFileFormat::dds) { - LOG_ERROR("An image can't be created from DDS file. Use CreateTextureFromFile() or CreateTextureFromDDS() functions."); + LOG_ERROR_MESSAGE("An image can't be created from DDS file. Use CreateTextureFromFile() or CreateTextureFromDDS() functions."); } else if (LoadInfo.Format == EImageFileFormat::ktx) { - LOG_ERROR("An image can't be created from KTX file. Use CreateTextureFromFile() or CreateTextureFromKTX() functions."); + LOG_ERROR_MESSAGE("An image can't be created from KTX file. Use CreateTextureFromFile() or CreateTextureFromKTX() functions."); + } + else + { + LOG_ERROR_MESSAGE("Unknown image format."); } } -- cgit v1.2.3