-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApp.h
More file actions
86 lines (70 loc) · 2.22 KB
/
App.h
File metadata and controls
86 lines (70 loc) · 2.22 KB
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
#pragma once
#include "Window.h"
#include "Tools/Timer.h"
#include "Tools/DungeonGenerator.h"
#include "Graphics/Camera.h"
#include "Graphics/Drawable/Box.h"
#include "Graphics/Drawable/CubeMap.h"
#include "Graphics/Drawable/Ground.h"
#include "Graphics/Drawable/Model.h"
#include "Graphics/Drawable/Primitive.h"
#include "Graphics/Lighting/DirectionalLight.h"
#include "Graphics/Lighting/PointLight.h"
#include "Graphics/Lighting/SpotLight.h"
#include "Graphics/Renderer.h"
#include "Physics/PhysicsWorld.h"
#include "imgui/ImguiManager.h"
#include "Scene/Scene.h"
#include "Scene/GameObject.h"
#include "Components/Component.h"
#include "Components/DrawableComponent.h"
#define TARGET_FPS 60.0f
class App
{
private:
struct Config
{
int width;
int height;
std::string title;
Config();
};
public:
App();
~App();
int Begin(); // handles message pump between windows and the app
private:
void Update(float dt); // called per frame
void RenderFrame(float alpha); // renders the frame, alpha for physics interpolation
void ResetSimulation(); // resets camera, light, and all drawables to initial state
void CacheSceneComponents() noexcept;
DirectX::SimpleMath::Ray BuildMouseRay(int mouseX, int mouseY) noexcept;
void HandleInput(float dt); // handles input per frame
private:
Config config;
ImguiManager imgui; // initializes imgui
Window wnd;
Timer timer;
Scene scene;
// Cameras for different modes
Camera editorCam;
std::vector<Camera*> gameCams;
Camera* activeCam = nullptr; // reference to currently active camera
std::vector<PointLight*> pointLights;
std::vector<SpotLight*> spotLights;
std::vector<DirectionalLight*> directionalLights;
Renderer renderer;
// Persistent game objects for inter-scene use (e.g. player character)
std::vector<GameObject*> persistentObjects;
// Simulation state
bool isPlayMode = false; // false = Edit Mode, true = Play Mode
bool isPaused = false; // true = Simulation Paused (while in Play Mode)
bool needsReset = false; // flag to indicate if simulation needs reset (used to defer reset until end of frame)
// Input state
int lastMouseX = 0;
int lastMouseY = 0;
// Physics
Physics::PhysicsWorld physicsWorld;
const float dt = 1.0f / TARGET_FPS;
float accumulator = 0.0f;
};