我是C ++的新手,我正试图通过GLFW获取屏幕宽度和高度,使我的窗口显示在屏幕中央。
我试图通过这样做来获得屏幕的宽度和高度
//Get primary monitor information
const GLFWvidmode* mode = glfwGetVideoMode(glfwGetPrimaryMonitor());
//Center the program to the screen
const int windowPosX = (mode->width - 800) / 2;
const int windowPosY = (mode->height - 600) / 2;
Window window("Game Engine", 800, 600);
glfwSetWindowPos(window.getWindow(), windowPosX, windowPosY);
结果: