Skip to content

Commit 6c27c07

Browse files
committed
Added shouldUpdate logic to camera.
* No need to render gui to separate framebuffer.
1 parent 523ca1b commit 6c27c07

File tree

8 files changed

+24
-30
lines changed

8 files changed

+24
-30
lines changed

MP-APS/.vs/MP-APS/v15/.suo

2.5 KB
Binary file not shown.

MP-APS/.vs/MP-APS/v15/Browse.VC.db

0 Bytes
Binary file not shown.

MP-APS/Camera.cpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,23 @@ Camera::Camera(const glm::vec3& position, const glm::vec3& up, const float yaw,
2020

2121
/***********************************************************************************/
2222
void Camera::Update(const double deltaTime) {
23-
// Update view from mouse movement
24-
updateView();
25-
26-
// Update Keyboard
27-
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_W)) { processKeyboard(Direction::FORWARD, deltaTime); }
28-
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_S)) { processKeyboard(Direction::BACKWARD, deltaTime); }
29-
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_A)) { processKeyboard(Direction::LEFT, deltaTime); }
30-
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_D)) { processKeyboard(Direction::RIGHT, deltaTime); }
31-
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_SPACE)) { processKeyboard(Direction::UP, deltaTime); }
32-
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_LEFT_CONTROL)) { processKeyboard(Direction::DOWN, deltaTime); }
23+
24+
if (Input::GetInstance().IsKeyPressed(GLFW_KEY_TAB)) {
25+
m_shouldUpdate = !m_shouldUpdate;
26+
}
27+
28+
if (m_shouldUpdate) {
29+
// Update view from mouse movement
30+
updateView();
31+
32+
// Update Keyboard
33+
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_W)) { processKeyboard(Direction::FORWARD, deltaTime); }
34+
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_S)) { processKeyboard(Direction::BACKWARD, deltaTime); }
35+
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_A)) { processKeyboard(Direction::LEFT, deltaTime); }
36+
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_D)) { processKeyboard(Direction::RIGHT, deltaTime); }
37+
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_SPACE)) { processKeyboard(Direction::UP, deltaTime); }
38+
if (Input::GetInstance().IsKeyHeld(GLFW_KEY_LEFT_CONTROL)) { processKeyboard(Direction::DOWN, deltaTime); }
39+
}
3340
}
3441

3542
/***********************************************************************************/

MP-APS/Camera.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ class Camera {
4949
// Mouse positions
5050
bool m_firstMouse;
5151
double m_prevX, m_prevY;
52+
53+
bool m_shouldUpdate = true;
5254
};

MP-APS/Core/GUISystem.cpp

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,6 @@ void GUISystem::Init(GLFWwindow* windowPtr) {
2727
nk_glfw3_font_stash_begin(&atlas);
2828
nk_glfw3_font_stash_end();
2929
}
30-
31-
int width, height;
32-
glfwGetWindowSize(windowPtr, &width, &height);
33-
34-
m_guiFBO.Init("GUI FBO", width, height);
3530
}
3631

3732
/***********************************************************************************/
@@ -83,13 +78,10 @@ void GUISystem::Render() {
8378
nk_end(m_nuklearContext);
8479

8580

86-
// Todo: render to different framebuffer and blit onto default
87-
//glClear(GL_COLOR_BUFFER_BIT);
8881
nk_glfw3_render(NK_ANTI_ALIASING_ON, m_maxVertexBuffer, m_maxElementBuffer);
8982
}
9083

9184
/***********************************************************************************/
92-
void GUISystem::Shutdown() {
93-
m_guiFBO.Delete();
85+
void GUISystem::Shutdown() const {
9486
nk_glfw3_shutdown();
9587
}

MP-APS/Core/GUISystem.h

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
#pragma once
22

3-
#include "../Graphics/GLFramebuffer.h"
4-
53
#include <cstddef>
64

75
/***********************************************************************************/
@@ -19,13 +17,11 @@ class GUISystem {
1917
void Init(GLFWwindow* windowPtr);
2018
void Update();
2119
void Render();
22-
void Shutdown();
20+
void Shutdown() const;
2321

2422
private:
2523
nk_context* m_nuklearContext;
2624

2725
std::size_t m_maxVertexBuffer = 512 * 1024;
2826
std::size_t m_maxElementBuffer = 128 * 1024;
29-
30-
GLFramebuffer m_guiFBO;
3127
};

MP-APS/Engine.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,7 @@ void Engine::Execute() {
7676
while (!m_mainWindow.ShouldClose()) {
7777
update();
7878

79-
// No need to render when the cursor is enabled
80-
if (!m_mainWindow.IsCursorVisible()) {
81-
m_renderer.Render(*m_activeScene, false);
82-
}
79+
m_renderer.Render(*m_activeScene, false);
8380

8481
m_guiSystem.Render();
8582

@@ -100,7 +97,7 @@ void Engine::update() {
10097
}
10198

10299
/***********************************************************************************/
103-
void Engine::shutdown() {
100+
void Engine::shutdown() const {
104101
m_guiSystem.Shutdown();
105102
m_renderer.Shutdown();
106103
ResourceManager::GetInstance().ReleaseAllResources();

MP-APS/Engine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class Engine {
2424

2525
private:
2626
void update();
27-
void shutdown();
27+
void shutdown() const;
2828

2929
Timer m_timer;
3030

0 commit comments

Comments
 (0)