F3: Toggle drawing bounding boxes
This commit is contained in:
@@ -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,27 +138,29 @@ void Renderer::Draw(double dt)
|
|||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
// Draw bounding boxes
|
// Draw bounding boxes
|
||||||
glEnable(GL_BLEND);
|
if (m_DrawBounds) {
|
||||||
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
|
glEnable(GL_BLEND);
|
||||||
m_ShaderProgramDebugAABB.Bind();
|
glBlendFunc(GL_ONE_MINUS_DST_COLOR, GL_ZERO);
|
||||||
for (auto tuple : AABBsToRender) {
|
m_ShaderProgramDebugAABB.Bind();
|
||||||
glm::mat4 modelMatrix;
|
for (auto tuple : AABBsToRender) {
|
||||||
bool colliding;
|
glm::mat4 modelMatrix;
|
||||||
std::tie(modelMatrix, colliding) = tuple;
|
bool colliding;
|
||||||
// Model matrix
|
std::tie(modelMatrix, colliding) = tuple;
|
||||||
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix();
|
// Model matrix
|
||||||
glm::mat4 MVP = cameraMatrix * modelMatrix;
|
glm::mat4 cameraMatrix = m_Camera->ProjectionMatrix() * m_Camera->ViewMatrix();
|
||||||
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramDebugAABB.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
glm::mat4 MVP = cameraMatrix * modelMatrix;
|
||||||
// Color
|
glUniformMatrix4fv(glGetUniformLocation(m_ShaderProgramDebugAABB.GetHandle(), "MVP"), 1, GL_FALSE, glm::value_ptr(MVP));
|
||||||
glm::vec4 color(1.f, 1.f, 1.f, 0.f);
|
// Color
|
||||||
if (colliding)
|
glm::vec4 color(1.f, 1.f, 1.f, 0.f);
|
||||||
color = glm::vec4(1.f, 0.f, 0.f, 0.f);
|
if (colliding)
|
||||||
glUniform4fv(glGetUniformLocation(m_ShaderProgramDebugAABB.GetHandle(), "Color"), 1, glm::value_ptr(color));
|
color = glm::vec4(1.f, 0.f, 0.f, 0.f);
|
||||||
glBindVertexArray(m_DebugAABB);
|
glUniform4fv(glGetUniformLocation(m_ShaderProgramDebugAABB.GetHandle(), "Color"), 1, glm::value_ptr(color));
|
||||||
glDrawArrays(GL_LINES, 0, 24);
|
glBindVertexArray(m_DebugAABB);
|
||||||
|
glDrawArrays(GL_LINES, 0, 24);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
DrawDebugShadowMap();
|
//DrawDebugShadowMap();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
ClearStuff();
|
ClearStuff();
|
||||||
|
|||||||
@@ -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;
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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);
|
||||||
|
|||||||
Reference in New Issue
Block a user