aboutsummaryrefslogtreecommitdiff
path: root/source/App.cpp
diff options
context:
space:
mode:
authorrtk0c <[email protected]>2022-05-30 17:03:20 -0700
committerrtk0c <[email protected]>2022-05-30 17:03:20 -0700
commite66286ebe30afc9acc4531fc2bea29b7fb924f93 (patch)
treefa6b76554c3eb88bc8f088fbab68e20c40118ca7 /source/App.cpp
parent366ef5a5450c6e0e680c924c3454943a9ae9814d (diff)
Changeset: 56 Buildsystem cleanup: change to layered structure for different targets
Diffstat (limited to 'source/App.cpp')
-rw-r--r--source/App.cpp149
1 files changed, 0 insertions, 149 deletions
diff --git a/source/App.cpp b/source/App.cpp
deleted file mode 100644
index 45a7545..0000000
--- a/source/App.cpp
+++ /dev/null
@@ -1,149 +0,0 @@
-#include "App.hpp"
-
-#include <string>
-#include <utility>
-
-using namespace std::literals;
-
-App::App()
- : mActiveCamera{ &mMainCamera } {
- auto& worldRoot = mWorld.GetRoot();
-
- constexpr int kPlayerCount = 2;
- for (int i = 0; i < kPlayerCount; ++i) {
- auto player = new Player(&mWorld, i);
- worldRoot.AddChild(player);
- mPlayers.push_back(player);
- };
-
-#if defined(BRUSSEL_DEV_ENV)
- SetGameRunning(false);
- SetEditorVisible(true);
-#else
- SetGameRunning(true);
-#endif
-
- mMainCamera.name = "Main Camera"s;
- mMainCamera.SetEyePos(glm::vec3(0, 0, 1));
- mMainCamera.SetTargetDirection(glm::vec3(0, 0, -1));
- mMainCamera.SetHasPerspective(false);
-}
-
-App::~App() {
-}
-
-Camera* App::GetActiveCamera() const {
- return mActiveCamera;
-}
-
-void App::BindActiveCamera(Camera* camera) {
- mActiveCamera = camera;
-}
-
-void App::UnbindActiveCamera() {
- mActiveCamera = &mMainCamera;
-}
-
-bool App::IsGameRunning() const {
- return mGameRunning;
-}
-
-void App::SetGameRunning(bool running) {
- if (mGameRunning != running) {
- mGameRunning = running;
- if (running) {
- mWorld.Awaken();
- } else {
- mWorld.Resleep();
- }
- }
-}
-
-bool App::IsEditorVisible() const {
- return mEditorVisible;
-}
-
-void App::SetEditorVisible(bool visible) {
- if (mEditorVisible != visible) {
- if (visible) {
-#if BRUSSEL_ENABLE_EDITOR
- mEditorVisible = true;
- if (mEditor == nullptr) {
- mEditor = IEditor::CreateInstance(this);
- }
-#endif
- } else {
- mEditorVisible = false;
- }
- }
-}
-
-void App::Show() {
- if (mEditorVisible) {
- mEditor->Show();
- }
-}
-
-void App::Update() {
- if (IsGameRunning()) {
- mWorld.Update();
- }
-}
-
-void App::Draw(float currentTime, float deltaTime) {
- mWorldRenderer.BeginFrame(*mActiveCamera, currentTime, deltaTime);
-
- PodVector<GameObject*> stack;
- stack.push_back(&mWorld.GetRoot());
-
- while (!stack.empty()) {
- auto obj = stack.back();
- stack.pop_back();
-
- for (auto child : obj->GetChildren()) {
- stack.push_back(child);
- }
-
- auto renderObjects = obj->GetRenderObjects();
- mWorldRenderer.Draw(renderObjects.data(), obj, renderObjects.size());
- }
-
- mWorldRenderer.EndFrame();
-}
-
-void App::HandleMouse(int button, int action) {
-}
-
-void App::HandleMouseMotion(double xOff, double yOff) {
-}
-
-void App::HandleKey(GLFWkeyboard* keyboard, int key, int action) {
- if (!mKeyCaptureCallbacks.empty()) {
- auto& callback = mKeyCaptureCallbacks.front();
- bool remove = callback(key, action);
- if (remove) {
- mKeyCaptureCallbacks.pop_front();
- }
- }
-
- switch (key) {
- case GLFW_KEY_F3: {
- if (action == GLFW_PRESS) {
- SetEditorVisible(!IsEditorVisible());
- }
- return;
- }
- }
-
- for (auto& player : mPlayers) {
- for (auto playerKeyboard : player->boundKeyboards) {
- if (playerKeyboard == keyboard) {
- player->HandleKeyInput(key, action);
- }
- }
- }
-}
-
-void App::PushKeyCaptureCallback(KeyCaptureCallback callback) {
- mKeyCaptureCallbacks.push_back(std::move(callback));
-}