Skip to content

Commit

Permalink
Preserve aspect ratio on resize
Browse files Browse the repository at this point in the history
  • Loading branch information
tansly committed Jan 9, 2020
1 parent b284112 commit 5c05be6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 0 deletions.
2 changes: 2 additions & 0 deletions assignments/hw3/src/flat.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -345,6 +345,8 @@ void ErrorCallback(int Error, const char *Description)
void FramebufferSizeCallback(GLFWwindow *Window, int Width, int Height)
{
glViewport(/* x = */ 0, /* y = */ 0, Width, Height);
TheState.Matrices.Projection =
glm::perspective(45.0f, (float)Width / Height, 0.1f, 1000.0f);
}

void KeyCallback(GLFWwindow *Window, int Key, int ScanCode, int Action,
Expand Down
2 changes: 2 additions & 0 deletions assignments/hw3/src/sphere.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,8 @@ void ErrorCallback(int Error, const char *Description)
void FramebufferSizeCallback(GLFWwindow *Window, int Width, int Height)
{
glViewport(/* x = */ 0, /* y = */ 0, Width, Height);
TheState.Matrices.Projection =
glm::perspective(45.0f, (float)Width / Height, 0.1f, 1000.0f);
}

void KeyCallback(GLFWwindow *Window, int Key, int ScanCode, int Action,
Expand Down
1 change: 1 addition & 0 deletions assignments/hw3/src/templates/__base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ void ErrorCallback(int Error, const char *Description)
void FramebufferSizeCallback(GLFWwindow *Window, int Width, int Height)
{
glViewport(/* x = */ 0, /* y = */ 0, Width, Height);
TheState.Matrices.Projection = glm::perspective(45.0f, (float)Width/Height, 0.1f, 1000.0f);
}

void KeyCallback(GLFWwindow *Window, int Key, int ScanCode, int Action,
Expand Down

0 comments on commit 5c05be6

Please sign in to comment.