Fullscreen not working on Macbook pro M2 Max

I found a bug when testing fullscreen on a Macbook pro M2 max with a screen size of 3024x1964. It should create a window that is the size of the entire monitor, instead creates a small window in the bottom left corner with the rest of the monitor left black. Also, the mouse y co-ordinates are wrong. The OS version is 14.6.1 and I am using the latest version on GLFW.

This is the code I use to create the window:

		int numMonitors;
		GLFWmonitor** monitors = glfwGetMonitors(&numMonitors);
		int ixMonitor = pMonitorSettings->GetIXMonitorCurr();
		const GLFWvidmode* mode = glfwGetVideoMode(monitors[ixMonitor]);
		g_pWindow = glfwCreateWindow(mode->width, mode->height, "Merc Tactics", NULL, NULL);
		glfwSetWindowMonitor(g_pWindow, monitors[ixMonitor],
			0, 0, mode->width, mode->height, GLFW_DONT_CARE);

From the description this sounds like it could be due to the viewport not being set correctly. Could you check that you are calling glViewport with the correct framebuffer width and height after setting the OpenGL context current?

Yes, I am. I mean the same code works on other PCs

I am wondering if this is related to this similar issue on Github which can apparently be resolved by setting the viewport using the framebuffer size after calling glfwShowWindow.

I am not currently able to test/debug MacOS issues as I no longer have a working Mac.

I mean the same code works on other PCs

Note that different OSes handle framebuffer and window coordinates differently. On MacOS with retina framebuffers and GLFW_SCALE_FRAMEBUFFER window hint set to GLFW_TRUE (the default) the framebuffer will be a different size to the window. So the values sent to glViewport need to be the framebuffer size and not the window size. On Windows and X11 platforms the window and framebuffer sizes are the same.

You can turn off framebuffer scaling with glfwWindowHint(GLFW_COCOA_RETINA_FRAMEBUFFER, GL_FALSE).

I tested on three different Macs and only the Macbook shows this bug.

glfwGetFramebufferSize, was returning 2560 x 1332 (which is strange). I could be that I need to set viewport values to the output of glfwGetFramebufferSize when using fullscreen (as you say).

Also, I tried switching the GLFW_COCOA_RETINA_FRAMEBUFFER setting on and off. It seems to have no effect at all. (i.e. glfwGetFrambufferSize always returns 2560 x 1332 and glfwGetMonitorContentScale always returns 1.0)

Note that I meant GLFW_SCALE_FRAMEBUFFER (this is the new hint name for GLFW_COCOA_RETINA_FRAMEBUFFER now more than one OS uses it, but the old name will do the same thing).

Perhaps your main window does not have scaling on.

I’m not sure why the size you’re getting is this odd value sadly. Does your Macbook have a notch?

Unfortunately, I don’t have a macbook to test on, but I got a friend to test on his macbook.

I used the output from glfwGetFramebufferSize to set glViewport and now fullscreen works on the macbook. (BTW you don’t need to call glfwShowWindow)