LWJGL Forum

Programming => OpenGL => Topic started by: orange451 on November 24, 2015, 06:01:50

Title: [LWJGL3] drawing full-screen FBO with orthographic projection is half-sized
Post by: orange451 on November 24, 2015, 06:01:50
I am on a Retina Display macbook pro at the moment, and I now that I've gotten my lwjgl3 project to run on mac os, I've noticed that the game displays in only half the screen.

At the moment, the entire scene is rendered to a 1280x720 fbo, then some post-processing is applied, then that fbo is drawn as a quad over the screen.

Here's a picture:
(http://i.imgur.com/EJbX53G.jpg?1)

Since it doesn't happen in windows, I'm assuming it's because my mac has a retina display. Is there a way to disable this in lwjgl?

I am using the JOML library (using their orthographic projection math). I am setting the ortho projection to 1280x720 (same size as screen).
Title: Re: [LWJGL3] drawing full-screen FBO with orthographic projection is half-sized
Post by: Kai on November 24, 2015, 08:29:52
Yes, you are right. When using a Retina display, window coordinates (screen coordinates) do not map to framebuffer pixels 1:1.
If you request a window with a client rect that is 1280x720 in window/screen coordinates you'll get a framebuffer that is double the size in each dimension.
You can query the actual framebuffer pixel size with the following code after creating the GLFW window:

IntBuffer framebufferSize = BufferUtils.createIntBuffer(2);
GLFW.nglfwGetFramebufferSize(window, MemoryUtil.memAddress(framebufferSize), MemoryUtil.memAddress(framebufferSize) + 4);
int width = framebufferSize.get(0);
int height = framebufferSize.get(1);

Use this obtained width/height as the real framebuffer size for creating the render texture and setting the viewport.
Title: Re: [LWJGL3] drawing full-screen FBO with orthographic projection is half-sized
Post by: orange451 on November 24, 2015, 16:40:14
Works perfectly :)