Created
September 25, 2016 02:39
-
-
Save dymk/09730fb806d0d0cfbdedcde9af138d5c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| diff --git a/main.cpp b/main.cpp | |
| index a1ac7bc..5bb18df 100644 | |
| --- a/main.cpp | |
| +++ b/main.cpp | |
| @@ -1,21 +1,20 @@ | |
| #include "main.h" | |
| -GLFWwindow* window; | |
| - | |
| void error_callback(int error, const char* description) | |
| { | |
| // Print error | |
| fputs(description, stderr); | |
| } | |
| -void setup_callbacks() | |
| +void setup_callbacks(GLFWwindow* window) | |
| { | |
| // Set the error callback | |
| glfwSetErrorCallback(error_callback); | |
| // Set the key callback | |
| glfwSetKeyCallback(window, Window::key_callback); | |
| // Set the window resize callback | |
| - glfwSetWindowSizeCallback(window, Window::resize_callback); | |
| + glfwSetFramebufferSizeCallback(window, Window::resize_callback); | |
| } | |
| @@ -81,20 +80,14 @@ void print_versions() | |
| #endif | |
| } | |
| -int main(void) | |
| +int main() | |
| { | |
| // Create the GLFW window | |
| - window = Window::create_window(640, 480); | |
| + GLFWwindow* window = Window::create_window(640, 480); | |
| print_versions(); | |
| - setup_callbacks(); | |
| + setup_callbacks(window); | |
| setup_opengl_settings(); | |
| Window::initialize_objects(); | |
| while (!glfwWindowShouldClose(window)) | |
| { | |
| // Main render display callback. Rendering of objects is done here. | |
| @@ -104,10 +97,8 @@ int main(void) | |
| } | |
| Window::clean_up(); | |
| glfwDestroyWindow(window); | |
| glfwTerminate(); | |
| diff --git a/Window.cpp b/Window.cpp | |
| index e757b68..9c7211f 100644 | |
| --- a/Window.cpp | |
| +++ b/Window.cpp | |
| @@ -44,7 +44,9 @@ GLFWwindow* Window::create_window(int width, int height) | |
| glfwSwapInterval(1); | |
| // Call the resize callback to make sure things get drawn immediately | |
| - Window::resize_callback(window, width, height); | |
| + int fwidth, fheight; | |
| + glfwGetFramebufferSize(window, &fwidth, &fheight); | |
| + Window::resize_callback(window, fwidth, fheight); | |
| return window; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment