summaryrefslogtreecommitdiffstats
path: root/Common/NativeApp
diff options
context:
space:
mode:
authorEgor Yusov <egor.yusov@gmail.com>2019-10-26 05:49:01 +0000
committerEgor Yusov <egor.yusov@gmail.com>2019-10-26 05:49:01 +0000
commit17ea2759a84820ea1d703fb69e98d1828ec8a960 (patch)
treeeecf0c2433b8a0137b25b4bdd8d58c1d5e0e4c24 /Common/NativeApp
parentTravis and Appveyor: updated CMake to 3.15.4 (diff)
downloadDiligentEngine-17ea2759a84820ea1d703fb69e98d1828ec8a960.tar.gz
DiligentEngine-17ea2759a84820ea1d703fb69e98d1828ec8a960.zip
Gracefully handling unsupported device modes (fixed https://github.com/DiligentGraphics/DiligentEngine/issues/62)
Diffstat (limited to 'Common/NativeApp')
-rw-r--r--Common/NativeApp/src/UWP/App.cpp41
-rw-r--r--Common/NativeApp/src/Win32/WinMain.cpp1
2 files changed, 31 insertions, 11 deletions
diff --git a/Common/NativeApp/src/UWP/App.cpp b/Common/NativeApp/src/UWP/App.cpp
index bf5a523..a36fe49 100644
--- a/Common/NativeApp/src/UWP/App.cpp
+++ b/Common/NativeApp/src/UWP/App.cpp
@@ -147,7 +147,9 @@ void App::Run()
{
CoreWindow::GetForCurrentThread()->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessAllIfPresent);
- auto commandQueue = GetDeviceResources();//->GetCommandQueue();
+ // Initialize device resources
+ GetDeviceResources();
+
//PIXBeginEvent(commandQueue, 0, L"Update");
{
m_Main->Update();
@@ -224,8 +226,11 @@ void App::OnResuming(Platform::Object^ sender, Platform::Object^ args)
void App::OnWindowSizeChanged(CoreWindow^ sender, WindowSizeChangedEventArgs^ args)
{
- GetDeviceResources()->SetLogicalSize(Size(sender->Bounds.Width, sender->Bounds.Height));
- m_Main->OnWindowSizeChanged();
+ if (auto DeviceResources = GetDeviceResources())
+ {
+ DeviceResources->SetLogicalSize(Size(sender->Bounds.Width, sender->Bounds.Height));
+ m_Main->OnWindowSizeChanged();
+ }
}
void App::OnVisibilityChanged(CoreWindow^ sender, VisibilityChangedEventArgs^ args)
@@ -246,19 +251,28 @@ void App::OnDpiChanged(DisplayInformation^ sender, Object^ args)
// if it is being scaled for high resolution devices. Once the DPI is set on DeviceResources,
// you should always retrieve it using the GetDpi method.
// See DeviceResources.cpp for more details.
- GetDeviceResources()->SetDpi(sender->LogicalDpi);
- m_Main->OnWindowSizeChanged();
+ if (auto DeviceResources = GetDeviceResources())
+ {
+ DeviceResources->SetDpi(sender->LogicalDpi);
+ m_Main->OnWindowSizeChanged();
+ }
}
void App::OnOrientationChanged(DisplayInformation^ sender, Object^ args)
{
- GetDeviceResources()->SetCurrentOrientation(sender->CurrentOrientation);
- m_Main->OnWindowSizeChanged();
+ if (auto DeviceResources = GetDeviceResources())
+ {
+ DeviceResources->SetCurrentOrientation(sender->CurrentOrientation);
+ m_Main->OnWindowSizeChanged();
+ }
}
void App::OnDisplayContentsInvalidated(DisplayInformation^ sender, Object^ args)
{
- GetDeviceResources()->ValidateDevice();
+ if (auto DeviceResources = GetDeviceResources())
+ {
+ DeviceResources->ValidateDevice();
+ }
}
void App::OnKeyDown(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
@@ -324,9 +338,14 @@ std::shared_ptr<DX::DeviceResources> App::GetDeviceResources()
if (m_deviceResources == nullptr)
{
m_deviceResources = m_Main->InitDeviceResources();
- m_deviceResources->SetWindow(CoreWindow::GetForCurrentThread());
- m_Main->OnWindowSizeChanged();
- m_Main->CreateRenderers();
+ if (m_deviceResources)
+ {
+ m_deviceResources->SetWindow(CoreWindow::GetForCurrentThread());
+ auto Title = Diligent::WidenString(m_Main->GetAppTitle());
+ Windows::UI::ViewManagement::ApplicationView::GetForCurrentView()->Title = ref new Platform::String(Title.c_str());
+ m_Main->OnWindowSizeChanged();
+ m_Main->CreateRenderers();
+ }
}
return m_deviceResources;
}
diff --git a/Common/NativeApp/src/Win32/WinMain.cpp b/Common/NativeApp/src/Win32/WinMain.cpp
index 58d155e..8f63460 100644
--- a/Common/NativeApp/src/Win32/WinMain.cpp
+++ b/Common/NativeApp/src/Win32/WinMain.cpp
@@ -79,6 +79,7 @@ int WINAPI WinMain(HINSTANCE instance, HINSTANCE, LPSTR, int cmdShow)
UpdateWindow(wnd);
g_pTheApp->OnWindowCreated(wnd, WindowWidth, WindowHeight);
+ AppTitle = g_pTheApp->GetAppTitle();
Diligent::Timer Timer;
auto PrevTime = Timer.GetElapsedTime();