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, 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: Thanks to Vaillancourt for providing the correct API to determine the screen width and height, but the problem remains.

I modified my window creating code like so:

unsigned int screen_x;
unsigned int screen_y;

const GLFWvidmode *vid_mode;

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;
window = glfwCreateWindow(screen_x, screen_y, window_title, monitor, nullptr);

where window_title is a char * pointing to the string "tetrahedron".

If I use gdb to put a break point following the call to glfwCreateWindow() but before entry into the main loop where rendering happens, run the program to that break point and then take a desktop screen shot using the PrtSc key, I see the following:

screen shot

On the console I see:

mode.width 1920, mode.height 1080

Normally, that "tetrahedron" window only appears briefly, the break point gives me enough time to screen shot it.

Its hard to tell once it makes it to full screen mode, but the bands of the screen on the top and to the right that don't get rendered to seem to be about at the same locations as the gaps between the "tetrahedron" window and the entire desktop that are visible at the break point. It seems like full screen mode is "inheriting" the dimensions of that temporary window once it gets to full screen.

Is another API call necessary to get full screen to use the full screen?

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

Another update:

Using Vaillancourt's advice and adding more wild guesses, I tried this for creating the full screen window:

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);
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 resulting behavior is exactly same as reported before. However, if I uncomment out the line above where I assign 1600 and 900 to screen_x and screen_y (which is the second highest listed 16x9 aspect ratio resolution listed video mode under Settings->Displays after the primary listing of 1920x1080), then the entire full screen gets used once my application starts rendering stuff to the screen.

Seems like a system bug.

Would it be in GLFW itself or perhaps the video driver? If its a driver bug, I don't quite get how my desktop could run right in 1920x1080. I don't understand the inner workings of video drivers, but it would seem that the driver wouldn't care whether what was using it was a windowing desktop or a full screen application.

\$\endgroup\$
4
  • 1
    \$\begingroup\$ What is the size returned when you use glfwGetVideoMode instead of glfwGetMonitorWorkarea? \$\endgroup\$
    – Vaillancourt
    Jul 24, 2021 at 0:31
  • \$\begingroup\$ mode.width 1920, mode.height 1080. Ah, the old "I called the wrong API function" strikes me again. Thanks a bunch. \$\endgroup\$
    – user256552
    Jul 24, 2021 at 1:53
  • \$\begingroup\$ Yeah, I'm not sure this helps with the issue regarding the top and right bands that don't draw correctly, though. \$\endgroup\$
    – Vaillancourt
    Jul 24, 2021 at 11:57
  • \$\begingroup\$ One thing I read about this was to create the window hidden using hints, then set the size and position properly, then display the window. Maybe that could help? \$\endgroup\$
    – Vaillancourt
    Jul 24, 2021 at 21:51

0

You must log in to answer this question.

Browse other questions tagged .