awesomelemonade / Evolution

6 stars 8 forks source link

New LWJGL/GLFW Window Creation #59

Closed awesomelemonade closed 3 years ago

awesomelemonade commented 6 years ago

See: https://www.lwjgl.org/guide

try ( MemoryStack stack = stackPush() ) {
    IntBuffer pWidth = stack.mallocInt(1); // int*
    IntBuffer pHeight = stack.mallocInt(1); // int*

    // Get the window size passed to glfwCreateWindow
    glfwGetWindowSize(window, pWidth, pHeight);

    // Get the resolution of the primary monitor
    GLFWVidMode vidmode = glfwGetVideoMode(glfwGetPrimaryMonitor());

    // Center the window
    glfwSetWindowPos(
        window,
        (vidmode.width() - pWidth.get(0)) / 2,
        (vidmode.height() - pHeight.get(0)) / 2
    );
} // the stack frame is popped automatically