Why retina screen coordinate value is twice the value of pixel value

后端 未结 3 720
野性不改
野性不改 2020-12-18 03:20

My computer is a Mac pro with a 13 inch retina screen. The screen resolution is 1280*800 (default).

Using the following code:

gWindow = glfwCreateWi         


        
3条回答
  •  心在旅途
    2020-12-18 03:59

    The frame-buffer size never needs to be equal to the size of the window, as of that you need to use glfwGetFramebufferSize:

    This function retrieves the size, in pixels, of the framebuffer of the specified window. If you wish to retrieve the size of the window in screen coordinates, see glfwGetWindowSize.

    Whenever you resize your window you need to retrieve the size of its frambuffer and update the Viewport according to it:

     glfwGetFramebufferSize(gWindow, &framebufferWidth, &framebufferHeight);
    
     glViewport(0, 0, framebufferWidth, framebufferHeight);
    

提交回复
热议问题