-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSonarPropagationMain.cpp
114 lines (93 loc) · 3.58 KB
/
SonarPropagationMain.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#include "pch.h"
#include "SonarPropagationMain.h"
//#include "Common\DirectXHelper.h"
using namespace SonarPropagation;
using namespace Windows::Foundation;
using namespace Windows::System::Threading;
using namespace Concurrency;
// The DirectX 12 Application template is documented at https://go.microsoft.com/fwlink/?LinkID=613670&clcid=0x409
// Loads and initializes application assets when the application is loaded.
SonarPropagationMain::SonarPropagationMain()
{
// TODO: Change the timer settings if you want something other than the default variable timestep mode.
// e.g. for 60 FPS fixed timestep update logic, call:
/*
m_timer.SetFixedTimeStep(true);
m_timer.SetTargetElapsedSeconds(1.0 / 60);
*/
}
// Creates and initializes the renderers.
void SonarPropagationMain::CreateRenderers(const std::shared_ptr<DX::DeviceResources>& deviceResources)
{
// TODO: Replace this with your app's content initialization.
m_sceneRenderer = std::unique_ptr<RayTracingRenderer>(new RayTracingRenderer(deviceResources));
OnWindowSizeChanged();
}
// Updates the application state once per frame.
void SonarPropagationMain::Update()
{
// Update scene objects.
m_timer.Tick([&]()
{
// TODO: Replace this with your app's content update functions.
m_sceneRenderer->Update(m_timer);
});
}
// Renders the current frame according to the current application state.
// Returns true if the frame was rendered and is ready to be displayed.
bool SonarPropagationMain::Render()
{
// Don't try to render anything before the first Update.
if (m_timer.GetFrameCount() == 0)
{
return false;
}
// Render the scene objects.
// TODO: Replace this with your app's content rendering functions.
return m_sceneRenderer->Render();
}
// Updates application state when the window's size changes (e.g. device orientation change)
void SonarPropagationMain::OnWindowSizeChanged()
{
// TODO: Replace this with the size-dependent initialization of your app's content.
m_sceneRenderer->CreateWindowSizeDependentResources();
}
// Notifies the app that it is being suspended.
void SonarPropagationMain::OnSuspending()
{
// TODO: Replace this with your app's suspending logic.
// Process lifetime management may terminate suspended apps at any time, so it is
// good practice to save any state that will allow the app to restart where it left off.
m_sceneRenderer->SaveState();
// If your application uses video memory allocations that are easy to re-create,
// consider releasing that memory to make it available to other applications.
}
// Notifes the app that it is no longer suspended.
void SonarPropagationMain::OnResuming()
{
// TODO: Replace this with your app's resuming logic.
}
// Notifies renderers that device resources need to be released.
void SonarPropagationMain::OnDeviceRemoved()
{
// TODO: Save any necessary application or renderer state and release the renderer
// and its resources which are no longer valid.
m_sceneRenderer->SaveState();
m_sceneRenderer = nullptr;
}
void SonarPropagationMain::OnKeyPressed(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
{
m_sceneRenderer->KeyPressed(args);
}
void SonarPropagationMain::OnKeyReleased(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::KeyEventArgs^ args)
{
m_sceneRenderer->KeyReleased(args);
}
void SonarPropagationMain::OnMouseMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args)
{
m_sceneRenderer->MouseMoved(args);
}
void SonarPropagationMain::OnMouseWheelMoved(Windows::UI::Core::CoreWindow^ sender, Windows::UI::Core::PointerEventArgs^ args)
{
m_sceneRenderer->MouseWheelMoved(args);
}