[Solved] glfwGetVideoMode and UHD monitor under macOS

Started by BrickFarmer, January 14, 2018, 23:24:25

Previous topic - Next topic

BrickFarmer

The info button on my monitor is showing 3840x2160, but glfwGetVideoMode is reporting 1920x1080.  Is there a scaling factor involved under the hood somewhere like on iOS? About this mac -> displays shows  (3840 x 2160) and I am using 'Default for Display' in the display preferences -> display -> resolution.  I'm a bit confused where the difference is coming from?
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

BrickFarmer

So it turns out that there is some scaling in macOS, the 'Default' option is ignoring the monitor resolution. But by doing the magic hidden Alt-Click on 'Scaled' option a list of actual resolutions shows up, and from there it's clear macOS is defaulting to 1920x1080.  Although having tried the UHD mode, and as nice as the LWJGL looks, my eyes are just too old for text that small :)

oh and glfwGetVideoMode is obviously working perfectly fine.

btw using any other scaled option apart from 1920x1080 and 3840x2160 shows a warning 'using a scaled resolution may affect performance'.  I'll try these out when I have more than a cube to performance test against!
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

spasi

Note that when creating a 1920x1080 window on macOS with GLFW, the window will cover the entire screen. However, the framebuffer backing that window will have the retina 3840x2160 resolution. You can get the framebuffer resolution using glfwGetFramebufferSize or the framebuffer size callback. To disable retina scaling, use glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GLFW_FALSE) before creating the window.

BrickFarmer

Just tested that, and that seems to be true of the internal MBP display. On the external display, the framebuffer size seems to match the screen size regardless of the hint.  Whether or not I use the macOS scaled mode at HD or UHD.  Which is good right?
Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

spasi

I'm not familiar with how macOS handles external displays. What is the native resolution of the external display?

BrickFarmer

Oculus Rift CV1, MBP 2016 - 2.9 i7 - Radeon Pro 460  OSX 10.12.4,  Win7 - i5 4670K - GTX1070.
Oculus Rift VR Experiments: https://github.com/WhiteHexagon

jakethesnake

I'd like to jump in here as I'm having some related issues, don't know if a new post is preferred or not.

Just trying to get the proper result on every mac. I don't really care much for this Cocoa thing.

So what I'm doing is this:

String OS = System.getProperty("os.name", "generic").toLowerCase(Locale.ROOT);
		if ((OS.indexOf("mac") >= 0) || (OS.indexOf("darwin") >= 0)) {
			glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GL11.GL_FALSE);
		}


I'm doing deferred rendering, so in the end I'm just doing a "blit" to the default FB. This is how I get the dimension of the default FB:

IntBuffer w = BufferUtils.createIntBuffer(1);
		IntBuffer h = BufferUtils.createIntBuffer(1);
		glfwGetFramebufferSize(window, w, h);
		blitArea = new Coo(w.get(), h.get());
		Printer.ln("---blit size: " + blitArea.x() + " " + blitArea.y());


This works on a new Imac I have. But on a macbook I'm getting a 4x zoom as a result. Everything is fine and dandy in windowed mode, but this is going full screen. I had problems on the IMac too, but solved it with the first code paragraph. Any hints for me?