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

后端 未结 3 722
野性不改
野性不改 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 04:11

    As Sabuncu said is hard to know what result should be correct without knowing how you draw the triangle.

    But I guess your problems is related to the fact that with retina screen, when you use the 2.0 scale factor you need to render twice the pixels as you would with a regular screen - see here

    The method you're after is shown just a few lines below your GLFL link

    There is also glfwGetFramebufferSize for directly retrieving the current size of the framebuffer of a window.

    int width, height;
    glfwGetFramebufferSize(window, &width, &height);
    glViewport(0, 0, width, height);
    

    The size of a framebuffer may change independently of the size of a window, for example if the window is dragged between a regular monitor and a high-DPI one.

    In your case I'm betting the framebuffer size you'll get will be twice the window size, and your gl viewport needs to match it.

提交回复
热议问题