feat: aspect ration correction
This commit is contained in:
9
main.cpp
9
main.cpp
@@ -15,6 +15,7 @@ const char *fragmentShaderSource =
|
||||
{
|
||||
glViewport(0, 0, wdth, height);
|
||||
}*/
|
||||
float aspect = 1.0;
|
||||
|
||||
void processInput(GLFWwindow *window) {
|
||||
if (glfwGetKey(window, GLFW_KEY_ESCAPE) == GLFW_PRESS)
|
||||
@@ -70,6 +71,7 @@ unsigned int compShader() {
|
||||
|
||||
void framebuffer_size_callback(GLFWwindow *window, int width, int height) {
|
||||
glViewport(0, 0, width, height);
|
||||
aspect = float(width) / height;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv) {
|
||||
@@ -98,7 +100,7 @@ int main(int argc, char **argv) {
|
||||
|
||||
glfwSetFramebufferSizeCallback(window, framebuffer_size_callback);
|
||||
|
||||
unsigned int shaderProgramm = compShader();
|
||||
unsigned int shaderProgram = compShader();
|
||||
|
||||
FullScreenQuad fsq{};
|
||||
|
||||
@@ -109,8 +111,9 @@ int main(int argc, char **argv) {
|
||||
glClearColor(0.2f, 0.3f, 0.3f, 1.0f);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glUseProgram(shaderProgramm);
|
||||
|
||||
glUseProgram(shaderProgram);
|
||||
int aspectLocation = glGetUniformLocation(shaderProgram, "aspect");
|
||||
glUniform1f(aspectLocation, aspect);
|
||||
glBindVertexArray(fsq.getVAO());
|
||||
glDrawArrays(GL_TRIANGLES, 0, 6);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user