2
$\begingroup$

I'm using GLFW to create a full screen GL application. I'm running it on my Ubuntu 20.04 laptop that has a typical 1920:1080 display, at least that's the screen resolution reported under Settings->Displays. When I run the following code:

int monitor_x = 0;
int monitor_y = 0;
int monitor_width = 0;
int monitor_height = 0;

GLFWmonitor *monitor = glfwGetPrimaryMonitor();
glfwGetMonitorWorkarea(monitor, &monitor_x, &monitor_y, &monitor_width, &monitor_height);
printf("before monitor %d, %d, %d, %d\n", monitor_x, monitor_y, monitor_width, monitor_height);
window = glfwCreateWindow(1920, 1080, "OpenGL", glfwGetPrimaryMonitor(), nullptr); // Fullscreen
glfwGetMonitorWorkarea(monitor, &monitor_x, &monitor_y, &monitor_width, &monitor_height);
printf("after monitor %d, %d, %d, %d\n", monitor_x, monitor_y, monitor_width, monitor_height);

When I run the code, I get the following output on stdout:

before monitor 72, 27, 1848, 1053
after monitor 72, 27, 1848, 1053

Also, it seems as if there's a horizontal band at the top and a vertical band at the right of the full screen that remains the background color, no matter what my application attempts to write to those areas.

So 72 + 1848 = 1920 and 27 + 1053 = 1080, but it seems that the system is reserving these horizontal and vertical bands for something else that I assume has something to do with that 72 and 27.

Is there some hint or some such thing that i need to specify in order to make the entire 1920 by 1080 of the screen available for rendering?

Thanks

=======================================================

update:

So far I've tried this (including your suggestion, EthanKim8683, and some from others).

GLFWmonitor *monitor = glfwGetPrimaryMonitor();
vid_mode = glfwGetVideoMode(monitor);
printf("mode.width %d, mode.height %d\n", vid_mode->width, vid_mode->height);
screen_x = vid_mode->width;
screen_y = vid_mode->height;
// screen_x = 640; screen_y = 480;
// screen_x = 1600; screen_y = 900;
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
glfwWindowHint(GLFW_GREEN_BITS, vid_mode->greenBits);
glfwWindowHint(GLFW_BLUE_BITS, vid_mode->blueBits);
glfwWindowHint(GLFW_REFRESH_RATE, vid_mode->refreshRate);
glfwWindowHint(GLFW_MAXIMIZED, GLFW_TRUE);
window = glfwCreateWindow(screen_x, screen_y, window_title, monitor, nullptr); // Fullscreen
glfwSetWindowAttrib(window, GLFW_DECORATED, GLFW_FALSE);
glfwSetWindowSize(window, screen_x, screen_y);
glfwSetWindowPos(window, 0, 0);
glfwShowWindow(window);

The behavior is the same as reported before. There's these apparently inaccessible bands of screen real estate at the top and on the right side of the screen. But if I uncomment the line where I assign 1600 and 900 to screen_x and screen_y, the unaccessible bands disappear. The whole full screen shows the output of my application.

$\endgroup$

1 Answer 1

1
$\begingroup$

I'm not entirely sure about this case, but at least with some APIs I've worked with, there's a "maximize window" option.

The bands that you're having is most likely because the window isn't maximized (isn't fullscreen) and so the computer makes no effort to align it with the edges of your screen.

The reason why the window dimensions are funky are probably because, since the window isn't aligned to the edges of your screen, it has to get slimmed down a bit to still fit on your screen.

Edit: Ah, found something: https://www.glfw.org/docs/3.3/window_guide.html

GLFW_MAXIMIZED, set it to GLFW_TRUE and you'll be set :)

$\endgroup$
1
  • $\begingroup$ But passing the monitor to the 4th parameter of glfwCreateWindow is supposed to create a fullscreen window - it shouldn't be necessary to maximize it. (And maximize doesn't mean fullscreen anyway - maximized windows still allow room for the taskbar or menu bar, etc.) $\endgroup$ Jul 25, 2021 at 16:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.