I am using GLFW, glad and glm.
I want to render a simple square, my vertices are correct, but when I render it, it gets stretched into a rectangle. (probably by the viewport)
When the aspect ratio of the window is 1:1, it renders a square, but when it’s 16:9, (1280x720) the square is turned into a rectangle.
Here I create the projection matrix and input it into the shader program:
glm::mat4 projection(1.0f);
projection = glm::perspective(glm::radians(camera.fov), (float)SCR_WIDTH / (float)SCR_HEIGHT, 0.1f, 1000.0f);
glUniformMatrix4fv(glGetUniformLocation(basicShader.ID, "projectionMatrix"), 1, GL_FALSE, glm::value_ptr(projection));
Here is the framebufferSizeCallback, which gets called every time the window is resized:
void framebufferSizeCallback(GLFWwindow *window, int width, int height)
{
glViewport(0, 0, width, height);
}