F3: Toggle drawing bounding boxes

This commit is contained in:
2014-03-13 16:46:07 +01:00
parent 4905c17ebf
commit 235e9648ad
4 changed files with 38 additions and 19 deletions
+10 -1
View File
@@ -3,8 +3,15 @@
Renderer::Renderer() Renderer::Renderer()
{ {
m_VSync = false; m_VSync = false;
#ifdef DEBUG
m_DrawNormals = false; m_DrawNormals = false;
m_DrawWireframe = false; m_DrawWireframe = false;
m_DrawBounds = true;
#else
m_DrawNormals = false;
m_DrawWireframe = false;
m_DrawBounds = false;
#endif
m_ShadowMapRes = 2048*2; m_ShadowMapRes = 2048*2;
m_SunPosition = glm::vec3(0, 0.3f, 10); m_SunPosition = glm::vec3(0, 0.3f, 10);
@@ -131,6 +138,7 @@ void Renderer::Draw(double dt)
#ifdef DEBUG #ifdef DEBUG
// Draw bounding boxes // Draw bounding boxes
if (m_DrawBounds) {
glEnable(GL_BLEND); glEnable(GL_BLEND);
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO); glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
m_ShaderProgramDebugAABB.Bind(); m_ShaderProgramDebugAABB.Bind();
@@ -150,8 +158,9 @@ void Renderer::Draw(double dt)
glBindVertexArray(m_DebugAABB); glBindVertexArray(m_DebugAABB);
glDrawArrays(GL_LINES, 0, 24); glDrawArrays(GL_LINES, 0, 24);
} }
}
DrawDebugShadowMap(); //DrawDebugShadowMap();
#endif #endif
ClearStuff(); ClearStuff();
+3
View File
@@ -69,6 +69,8 @@ public:
void DrawNormals(bool val) { m_DrawNormals = val; } void DrawNormals(bool val) { m_DrawNormals = val; }
bool DrawWireframe() const { return m_DrawWireframe; } bool DrawWireframe() const { return m_DrawWireframe; }
void DrawWireframe(bool val) { m_DrawWireframe = val; } void DrawWireframe(bool val) { m_DrawWireframe = val; }
bool DrawBounds() const { return m_DrawBounds; }
void DrawBounds(bool val) { m_DrawBounds = val; }
private: private:
GLFWwindow* m_Window; GLFWwindow* m_Window;
@@ -77,6 +79,7 @@ private:
bool m_VSync; bool m_VSync;
bool m_DrawNormals; bool m_DrawNormals;
bool m_DrawWireframe; bool m_DrawWireframe;
bool m_DrawBounds;
int m_ShadowMapRes; int m_ShadowMapRes;
glm::vec3 m_SunPosition; glm::vec3 m_SunPosition;
+4
View File
@@ -47,6 +47,10 @@ void Systems::InputSystem::Update(double dt)
if (m_CurrentKeyState[GLFW_KEY_F2] && !m_LastKeyState[GLFW_KEY_F2]) { if (m_CurrentKeyState[GLFW_KEY_F2] && !m_LastKeyState[GLFW_KEY_F2]) {
m_Renderer->DrawNormals(!m_Renderer->DrawNormals()); m_Renderer->DrawNormals(!m_Renderer->DrawNormals());
} }
// Bounds
if (m_CurrentKeyState[GLFW_KEY_F3] && !m_LastKeyState[GLFW_KEY_F3]) {
m_Renderer->DrawBounds(!m_Renderer->DrawBounds());
}
#endif #endif
} }
+3
View File
@@ -77,6 +77,9 @@ void Systems::SoundSystem::UpdateEntity(double dt, EntityID entity, EntityID par
void Systems::SoundSystem::PlaySound(std::shared_ptr<Components::SoundEmitter> emitter, std::string fileName) void Systems::SoundSystem::PlaySound(std::shared_ptr<Components::SoundEmitter> emitter, std::string fileName)
{ {
if (m_Sources.find(emitter.get()) == m_Sources.end())
return;
ALuint buffer = LoadFile(fileName); ALuint buffer = LoadFile(fileName);
ALuint source = m_Sources[emitter.get()]; ALuint source = m_Sources[emitter.get()];
alSourcei(source, AL_BUFFER, buffer); alSourcei(source, AL_BUFFER, buffer);