Encapsulated Renderer WIDTH and HEIGHT variables.
This commit is contained in:
+6
-6
@@ -31,11 +31,11 @@ void Renderer::Initialize()
|
||||
}
|
||||
|
||||
// Create a window
|
||||
WIDTH = 1280;
|
||||
HEIGHT = 720;
|
||||
m_Width = 1280;
|
||||
m_Height = 720;
|
||||
// Antialiasing
|
||||
//glfwWindowHint(GLFW_SAMPLES, 16);
|
||||
m_Window = glfwCreateWindow(WIDTH, HEIGHT, "OpenGL", nullptr, nullptr);
|
||||
m_Window = glfwCreateWindow(m_Width, m_Height, "OpenGL", nullptr, nullptr);
|
||||
if (!m_Window)
|
||||
{
|
||||
LOG_ERROR("GLFW: Failed to create window");
|
||||
@@ -63,7 +63,7 @@ void Renderer::Initialize()
|
||||
}
|
||||
|
||||
// Create Camera
|
||||
m_Camera = std::make_shared<Camera>(45.f, (float)WIDTH / HEIGHT, 0.01f, 1000.f);
|
||||
m_Camera = std::make_shared<Camera>(45.f, (float)m_Width / m_Height, 0.01f, 1000.f);
|
||||
m_Camera->Position(glm::vec3(0.0f, 0.0f, 2.f));
|
||||
|
||||
glfwSwapInterval(m_VSync);
|
||||
@@ -187,7 +187,7 @@ void Renderer::Draw(double dt)
|
||||
void Renderer::DrawSkybox()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glViewport(0, 0, m_Width, m_Height);
|
||||
|
||||
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
||||
m_ShaderProgramSkybox.Bind();
|
||||
@@ -200,7 +200,7 @@ void Renderer::DrawSkybox()
|
||||
void Renderer::DrawScene()
|
||||
{
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
glViewport(0, 0, WIDTH, HEIGHT);
|
||||
glViewport(0, 0, m_Width, m_Height);
|
||||
|
||||
glClear(GL_DEPTH_BUFFER_BIT);
|
||||
//glClearColor(1.0f, 1.0f, 0.0f, 1.0f);
|
||||
|
||||
+4
-3
@@ -20,7 +20,9 @@ public:
|
||||
glm::mat4 viewMatrix;
|
||||
glm::mat4 projectionMatrix;
|
||||
|
||||
int HEIGHT, WIDTH;
|
||||
|
||||
int Width() const { return m_Width; }
|
||||
int Height() const { return m_Height; }
|
||||
|
||||
std::list<std::tuple<Model*, glm::mat4, bool, bool>> ModelsToRender;
|
||||
int Lights;
|
||||
@@ -65,9 +67,8 @@ public:
|
||||
void DrawBounds(bool val) { m_DrawBounds = val; }
|
||||
void DrawSkybox();
|
||||
|
||||
|
||||
|
||||
private:
|
||||
int m_Width, m_Height;
|
||||
GLFWwindow* m_Window;
|
||||
GLint m_glVersion[2];
|
||||
GLchar* m_glVendor;
|
||||
|
||||
@@ -51,8 +51,8 @@ void Systems::InputSystem::Update(double dt)
|
||||
// Lock mouse while holding LMB
|
||||
if (m_CurrentMouseState[GLFW_MOUSE_BUTTON_LEFT])
|
||||
{
|
||||
m_LastMouseX = m_Renderer->WIDTH / 2.f; // xpos;
|
||||
m_LastMouseY = m_Renderer->HEIGHT / 2.f; // ypos;
|
||||
m_LastMouseX = m_Renderer->Width() / 2.f; // xpos;
|
||||
m_LastMouseY = m_Renderer->Height() / 2.f; // ypos;
|
||||
glfwSetCursorPos(m_Renderer->GetWindow(), m_LastMouseX, m_LastMouseY);
|
||||
}
|
||||
// Hide/show cursor with LMB
|
||||
|
||||
Reference in New Issue
Block a user