[LWJGL3] drawing full-screen FBO with orthographic projection is half-sized

Started by orange451, November 24, 2015, 06:01:50

Previous topic - Next topic

orange451

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:


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).

Kai

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.