You can now change resolution without any apparent bugs.
This commit is contained in:
@@ -27,15 +27,17 @@ bool MainMenuSystem::OnButtonClick(const Events::ButtonClicked& e)
|
||||
printf("No, you stay");
|
||||
} else if (e.EntityName == "Res1080") {
|
||||
glfwSetWindowSize(m_Renderer->Window(), 1920, 1080);
|
||||
printf("1080");
|
||||
printf("\n1080");
|
||||
} else if (e.EntityName == "Res720") {
|
||||
glfwSetWindowSize(m_Renderer->Window(), 1280, 720);
|
||||
glViewport(0, 0, 1280, 720);
|
||||
printf("720");
|
||||
printf("\n720");
|
||||
} else if (e.EntityName == "Res480") {
|
||||
glfwSetWindowSize(m_Renderer->Window(), 854, 480);
|
||||
glViewport(0, 0, 854, 480);
|
||||
printf("480");
|
||||
printf("\n480");
|
||||
} else if (e.EntityName == "FullScreen") {
|
||||
printf("No fullscreen for now");
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -274,6 +274,12 @@ void DrawFinalPass::ClearBuffer()
|
||||
m_FinalPassFrameBuffer.Unbind();
|
||||
}
|
||||
|
||||
|
||||
void DrawFinalPass::OnWindowResize()
|
||||
{
|
||||
InitializeFrameBuffers();
|
||||
}
|
||||
|
||||
void DrawFinalPass::GenerateTexture(GLuint* texture, GLenum wrapping, GLenum filtering, glm::vec2 dimensions, GLint internalFormat, GLint format, GLenum type) const
|
||||
{
|
||||
glGenTextures(1, texture);
|
||||
@@ -702,7 +708,7 @@ void DrawFinalPass::BindExplosionUniforms(GLuint shaderHandle, std::shared_ptr<E
|
||||
glUniformMatrix4fv(glGetUniformLocation(shaderHandle, "P"), 1, GL_FALSE, glm::value_ptr(scene.Camera->ProjectionMatrix()));
|
||||
GLERROR("Bind 4 uniform");
|
||||
|
||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||
glUniform2f(glGetUniformLocation(shaderHandle, "ScreenDimensions"), m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
GLERROR("Bind 5 uniform");
|
||||
|
||||
glUniform3fv(glGetUniformLocation(shaderHandle, "ExplosionOrigin"), 1, glm::value_ptr(job->ExplosionOrigin));
|
||||
@@ -754,7 +760,7 @@ void DrawFinalPass::BindModelUniforms(GLuint shaderHandle, std::shared_ptr<Model
|
||||
GLERROR("Bind 4 uniform");
|
||||
|
||||
GLint Location_ScreenDimensions = glGetUniformLocation(shaderHandle, "ScreenDimensions");
|
||||
glUniform2f(Location_ScreenDimensions, m_Renderer->Resolution().Width, m_Renderer->Resolution().Height);
|
||||
glUniform2f(Location_ScreenDimensions, m_Renderer->GetViewportSize().Width, m_Renderer->GetViewportSize().Height);
|
||||
GLERROR("Bind 5 uniform");
|
||||
|
||||
GLint Location_FillPercentage = glGetUniformLocation(shaderHandle, "FillPercentage");
|
||||
|
||||
@@ -72,9 +72,7 @@ void FrameBuffer::Generate()
|
||||
|
||||
GLenum* bufferTextures = &attachments[0];
|
||||
glDrawBuffers(attachments.size(), bufferTextures);
|
||||
if(GLERROR("4")) {
|
||||
printf("hello");
|
||||
}
|
||||
GLERROR("GLBufferAttachement error");
|
||||
|
||||
if (GLenum frameBufferStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
|
||||
GLERROR("Framebuffer incomplete");
|
||||
|
||||
@@ -110,6 +110,13 @@ void LightCullingPass::FillLightList(RenderScene& scene)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void LightCullingPass::OnWindowResize()
|
||||
{
|
||||
SetSSBOSizes();
|
||||
InitializeSSBOs();
|
||||
}
|
||||
|
||||
void LightCullingPass::InitializeSSBOs()
|
||||
{
|
||||
glGenBuffers(1, &m_FrustumSSBO);
|
||||
|
||||
@@ -15,6 +15,8 @@ PickingPass::~PickingPass()
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void PickingPass::InitializeTextures()
|
||||
{
|
||||
GenerateTexture(&m_PickingTexture, GL_CLAMP_TO_BORDER, GL_LINEAR,
|
||||
@@ -365,6 +367,13 @@ void PickingPass::ClearPicking()
|
||||
m_PickingBuffer.Unbind();
|
||||
}
|
||||
|
||||
|
||||
void PickingPass::OnWindowResize()
|
||||
{
|
||||
InitializeTextures();
|
||||
InitializeFrameBuffers();
|
||||
}
|
||||
|
||||
PickData PickingPass::Pick(glm::vec2 screenCoord)
|
||||
{
|
||||
int fbWidth;
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
#include "Rendering/Renderer.h"
|
||||
|
||||
std::unordered_map<GLFWwindow*, Renderer*> Renderer::m_WindowToRenderer;
|
||||
|
||||
void Renderer::Initialize()
|
||||
{
|
||||
InitializeWindow();
|
||||
@@ -12,7 +14,6 @@ void Renderer::Initialize()
|
||||
m_TextPass = new TextPass();
|
||||
m_TextPass->Initialize();
|
||||
|
||||
|
||||
/* m_ScreenQuad = ResourceManager::Load<Model>("Models/Core/ScreenQuad.obj");
|
||||
m_UnitQuad = ResourceManager::Load<Model>("Models/Core/UnitQuad.obj");
|
||||
m_UnitSphere = ResourceManager::Load<Model>("Models/Core/UnitSphere.obj");*/
|
||||
@@ -20,6 +21,16 @@ void Renderer::Initialize()
|
||||
m_ImGuiRenderPass = new ImGuiRenderPass(this, m_EventBroker);
|
||||
}
|
||||
|
||||
void Renderer::glfwFrameBufferCallback(GLFWwindow* window, int width, int height)
|
||||
{
|
||||
glViewport(0, 0, width, height);
|
||||
Renderer* currentRenderer = m_WindowToRenderer[window];
|
||||
currentRenderer->m_ViewportSize = Rectangle(width, height);
|
||||
currentRenderer->m_DrawFinalPass->OnWindowResize();
|
||||
currentRenderer->m_LightCullingPass->OnWindowResize();
|
||||
currentRenderer->m_PickingPass->OnWindowResize();
|
||||
}
|
||||
|
||||
void Renderer::InitializeWindow()
|
||||
{
|
||||
// Initialize GLFW
|
||||
@@ -39,6 +50,7 @@ void Renderer::InitializeWindow()
|
||||
LOG_ERROR("GLFW: Failed to create window");
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
glfwSetFramebufferSizeCallback(m_Window, &glfwFrameBufferCallback);
|
||||
glfwMakeContextCurrent(m_Window);
|
||||
|
||||
// GL version info
|
||||
@@ -59,6 +71,8 @@ void Renderer::InitializeWindow()
|
||||
exit(EXIT_FAILURE);
|
||||
}
|
||||
|
||||
m_WindowToRenderer[m_Window] = this;
|
||||
|
||||
int windowSize[2];
|
||||
glfwGetFramebufferSize(m_Window, &windowSize[0], &windowSize[1]);
|
||||
m_ViewportSize = Rectangle(windowSize[0], windowSize[1]);
|
||||
|
||||
Reference in New Issue
Block a user