Getting frame buffer size for a blit

Please help.

I render everything offline until it’s time to blit the result to the default FB and I’m having annoyances on mac.

Now I’ve tried all kinds of different things, I’ve used the


It works on some macs, and not on others.

First thing I do is:


I’ve read the whole internet on the subject, please help. I need the correct input for:


Hi @songsofsyx,

Welcome to the GLFW forum!

glfwGetFramebufferSize will give you the size of the framebuffer you need.

Have you checked that the issue is the framebuffer size returned by glfwGetFramebufferSize is incorrect, or is it that the glBlitFramebuffer in your program does not succeed?



Thanks for fast response. On my mac, if I do full screen with my app, the value from glfwGetFramebufferSize is too big by a factor of two. The blit succeeds, but the result is only the lover left part of my offline rendering. If I do windowed it works… on my mac at least. If I divide the result from glfwGetFramebufferSize by two, I get the result I want.

Just to clarify, the blit always succeeds and the offline rendering does too. It’s just that I can’t get the correct dimensions for the blit.

I’ve tried frambufferSize, windowSize, disabling the COCOA thing in all possible combinations, and while I can get it to work on my own Imac in both windowed and full screen, other mac users will have issues instead.

I see you are using GL11.GL_FALSE rather than GLFW_FALSE which indicates you are using the Java bindings. These are likely the same so that shouldn’t be an issue.

That seems odd - if you are asking for 2x the framebuffer I would have expected you get the whole framebuffer but in only one half. What size are you using for the other parameters and framebuffer - this sounds like the destination size or framebuffer size is wrong?

Some further questions for debugging this:

  1. What version of GLFW are you using & have you tried this with the latest version of GLFW?
  2. Have you checked the returned fullscreen framebuffer size against the monitors actual resolution (and not the screen coordinates)?



Disabling The COCOA thing is just a desperate measure. It should work anyways right?

I render everything to my own FBO’s, using a fixed dimension for those, not dependent on the default framebuffer at all. And when I’m done, I simply do this:

glBlitFramebuffer(0, 0, offlineW, offlineH, 0, 0, defaultFBW, defaultFBH, GL_COLOR_BUFFER_BIT, GL_NEAREST);

where defaultFB is the values from
IntBuffer w = BufferUtils.createIntBuffer(1);
IntBuffer h = BufferUtils.createIntBuffer(1);
glfwGetFramebufferSize(window, w, h);
Coo sc = (new Coo(w.get(), h.get()));

So I’m confounded. It doesn’t make sense. The result is always the same no matter what resolution I pick with full screen mode. Possibly it could be an opengl state being applied to the blit?

  1. The glfwVersionString returns 3.4 cocoa for me.
  2. I’m not sure I know what this means? The window size is always half of my FB size when going full screen. glfwGetWindowSize returns glfwGetFramebufferSize/2. It’s like its pretending to be HDPI, but maybe it isn’t?

The question is what is your monitors resolution (in pixels, this should be in the hardware docs or you can search online), and what are the values returned by glfwGetFramebufferSize.

Now that I understand you are blitting to your final FB I see that it makes sense that your value from glfwGetFramebufferSize may be 2x the underlying framebuffer resolution.

There may be an issue here with glfwGetFramebufferSize - are you able to update GLFW to the latest from Github to see if it’s working with that?

The system info of my mac says it’s 4096 x 2304 . And it’s retina.

When I launch, glfwGetVideoMode(glfwGetPrimaryMonitor()) says my resolution is 2304x1296

glfwGetVideoModes(glfwGetPrimaryMonitor()) returns resolutions from 640x480 -> 4096x2304

If I launch a full screen window, glfwGetFramebufferSize gives me double the numbers. I.e. window = 4096x2304, FB = double, window = 2304x1296, FB = 4096x2304

If I launch a windowed window with 2304x1296 in resolution, I get the same size framebuffer.

If I do glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GL11.GL_FALSE); I get the correct results even in full screen.

Unfortunately, I’m tied to LWJGL’s java wrapper, so I can’t update any further. I’m kind of hoping I’ve overlooked something. seems unlikely there would be a bug and I’d be the first to spot it.

I don’t know what the resolution numbers mean though. This is a standard Imac. Even with retina 8x4 k sounds a bit high to me. It’s more likely 2304x1296 and 4096x2304?

Before I launch into full screen with 4096x2304, I do indeed see the desktop switching to a much higher resolution, which looks like a transition from 2304x1296 -> 4096x2304. Definitely not 8000x4000 though.

This seems what I would expect - the video mode is in screen coordinates and the actual framebuffer is the size of the monitor which is 2x this at 4096 x 2304.

The last set, window = 2304x1296, FB = 4096x2304 seems correct.

However when you ask for a video mode of 4096x2304 this is a ‘non-retina’ mode so the FB should be the same size.

This looks like a bug - if you don’t want to file it to then I can go ahead and do it for you.