Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[core] Fullscreen mode not working properly in some monitors #31

Closed
raysan5 opened this issue Sep 4, 2015 · 5 comments
Closed

[core] Fullscreen mode not working properly in some monitors #31

raysan5 opened this issue Sep 4, 2015 · 5 comments
Assignees

Comments

@raysan5
Copy link
Owner

raysan5 commented Sep 4, 2015

When compiling a program to be fullscreen, depending on the monitor it runs it is not scaled (just centered on the screen) or not scaled properly. It seems this issue could be related to monitor supported videomodes; GLFW library initializes the correct videomode.

To enable fullscreen mode, call SetConfigFlags(FLAG_FULLSCREEN_MODE) before InitWindow()

Related functions [core.c]:

static void InitDisplay(int width, int height);

Useful code snippet:

const GLFWvidmode *mode = glfwGetVideoMode(glfwGetPrimaryMonitor());

int windowWidth = mode->width; 
int windowHeight = mode->height; 

int count; 
const GLFWvidmode *modes = glfwGetVideoModes(glfwGetPrimaryMonitor(), &count);

Tested on Windows platform

@raysan5
Copy link
Owner Author

raysan5 commented Oct 21, 2015

After some testing with GLFW library, it seems window scaling depends GPU and monitor capabilities. On an nvidia GPU I get fullscreen scaling despite the adjustment of resolution to a supported videomode resolution; on an Intel HD Graphics GPU I get no scaling to fullscreen (image just centered in monitor).

From GLFW documentation:

The supported video mode most closely matching the desired video mode will be set for the chosen monitor as long as the window has input focus.

Useful documentation:

GLFW: Window creation
GLFW: Video modes
GLFW: glfwCreateWindow

@raysan5
Copy link
Owner Author

raysan5 commented Oct 21, 2015

Further investigations:

On nvidia GPU (image scaled to fullscreen - full monitor area), if using a valid videomode and 16:9 aspect ratio for framebuffer, all works ok.

On Intel HD Graphics GPU (image not scaled to full monitor area, just centered), if using a valid monitor videomode and 16:9 aspect ratio for framebuffer, not scaled but centered ok. In any other configuration image gets cut or wrongly scaled or even wrong positioned in monitor area... very weird...

Issue also seems to be related to the framebuffer redimension I do to match the monitor aspect ratio (adding black bars up-down or right-left).

UPDATE 1: Intel HD Graphics not scaling to fullscreen is a know driver issue.

UPDATE 2: The real problem resides on framebuffer redimension (adding black bars) to match monitor (display) aspect ratio; when doing that, selected framebuffer could be not compatible with a supported videomode.

SOLUTION: Redimension framebuffer (adding black bars) but matching the closest supported videomode.

@raysan5 raysan5 self-assigned this Nov 3, 2015
@raysan5 raysan5 added this to the raylib v1.4 milestone Nov 3, 2015
@raysan5 raysan5 modified the milestones: raylib v1.5, raylib v1.4 Feb 19, 2016
@raysan5
Copy link
Owner Author

raysan5 commented Jun 9, 2016

New function added to GLFW 3.2 for full-screen mode management: glfwSetWindowMonitor()

More info here and here.

@raysan5
Copy link
Owner Author

raysan5 commented Jun 26, 2016

This issue is quite a nightmare... some code updated with commit 6981e2b

Now, I check for monitor supported videomodes and I choose the closest videomode to the desired screen size. I set that mode to be the display size and I calculate the render size and viewport offsets considering that display size. It works... but I find another issue, what happens if the supported videomode does not match the monitor default aspect ratio?

Example:

Desired screen size:        800x450 (16:9)
Closest videomode detected: 800x600 (4:3)

Display size:     800x600
Render size:      800x600
Screen size:      800x450
Viewport offsets:   0, 75      // (600 - 450)/2

The result is: it renders correctly in the 800x600 framebuffer but, as long as the monitor aspect-ratio is 16:9, it gets stretched by the sides once displayed on the monitor.

When using weird screen sizes, the problem is worst (as expected...).

Possible solutions:

  1. Look for the closest aspet-ratio on the list of supported videomodes and then the closest display size; once aspect-ratio matches desired aspect-ratio and display size is bigger enough to store desired screen size, calculate a scaling matrix to scale all data drawn to screen (keep in mind that the objective is letting the user work with any desired screen size and that everything gets rendered right in any display).
  2. Limit the supported screen sizes to match a number of supported videomodes, preferably, the most common ones.

Note that this issue is limited to PLATFORM_DESKTOP and desktop monitor videomodes, on other platforms (Android, HTML5) fullscreen mode is managed correctly.

I'll keep this issue open for the future...

@raysan5 raysan5 removed this from the raylib v1.5 milestone Jun 26, 2016
@raysan5
Copy link
Owner Author

raysan5 commented Aug 24, 2017

After long time thinking I concluded that most users will limit to a set of standard resolutions (like most of the games offer), some 4:3 and some 16:9. There is no point in trying to support any weird resolution provided... in that case it will be addressed by case.

Just closing this issue, if someone feels it needs to be considered, please, feel free to reopen it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant