Created
January 30, 2018 06:39
-
-
Save kodai100/9a30f87f733efc8a9986382cfc134828 to your computer and use it in GitHub Desktop.
For centering GLFW window
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
void centering(GLFWwindow* window) { | |
// Get screen resolution | |
const GLFWvidmode * mode = glfwGetVideoMode(glfwGetPrimaryMonitor()); | |
int screen_width = mode->width, screen_height = mode->height; | |
int halfx = screen_width / 2, halfy = screen_height / 2; | |
int hw = WIN_SIZE_X / 2, hh = WIN_SIZE_Y / 2; | |
int posx = halfx - hw, posy = halfy - hh; | |
glfwSetWindowPos(window, posx, posy); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment