So I've been trying to get resolution setting to work correctly in my game for a while to no avail. I have a 16:9 ratio which I am trying to keep constant. I am using SDL with openGL. And here's my changing resolution class:

Now at first I had glOrtho set to scale along with the window size and view port, but that made me see more of the screen as the window size got larger, which wasn't what I wanted. So by setting the camera (glOrtho is like the camera right?) To a constant width and height I was able to always see the same portion of the screen. So far so good.

Now trying the game in window mode, everything works exactly as it should. The game's graphics scale, keeping the aspect ratio, and I always see the same portion of the screen.

Now trying full screen on a 5:4 monitor, this is what I get:

Left: 960x540--- Middle:1024x576--- Right:1200x675

As you can see, only the one in the middle is working as it should, it's stretched to fill the screen, but not stretched to destroy the aspect ratio. The one on the left is keeping it's aspect ratio, but not scaling enough.

The one on the right is getting stretched vertically and the aspect ratio is broken. Why is that? Why would it get stretched like that?Also, how would I go about centering the screen so that, on the middle monitor, the would be a black space on top and bottom, not just one big one at top?

Additional info:

When I try this on a 16:10 laptop, I get similar results with the screen not being scaled enough or not being centered, but it never stretched. Even setting it at a huge resolution of 1920,1080. It exactly scales more than the screen such that I only see a small part, but I'm guessing you can't really squeeze a 1920x1080 on a much smaller resolution.

So my question is really: Why is the resolution thing being completely unpredictable? Sometimes it stretches, sometimes it doesn't scale enough, etc.. and how do I fix that?

For each screen size you need to set up a custom glViewport parameters which can be done manually or by formula...usage:'Width' - a full-screen window width.'Height' - a full-screen window heght.example#1:I want to do make my screen quadratic (adopting to window width and height) which aligned to center:

glViewport((Width-Height)/2,0,Height,Height); // I took 'Height' as minimal value, so I would have it work on displays which it's width is larget than height

result will look like this:+-------+--------------+-------+ < my display|*******|...............|*******||*******|.......my...|*******||*******|..viewport..|*******||*******|...............|*******|+-------+--------------+-------+'*' - black pixel.example#2:I want to make my screen like film look (let say: 800x320) to get a result like watching a video (with these dimensions) in media player full-screen mode:

the result should be like this (for example if my display would be 800x600):+---------------------------+ << my display|************************|+---------------------------+|.............my...........||.........viewport........|+---------------------------+|************************|+---------------------------+

As you see (in your screen-shots) screen always aligned on left-bottom corner.Another thing can be happen:when your display (monitor) first time using these WxH settings sometimes it could do some shift&amp;scale operation which produces strange screen results...If this was happend, on LCD\LED monitors do: Menu->Settings->Reset:true

Thank you for the very detailed post and explanation FXACE! I really really appreciate it!

So I've successful managed to get it to work like a movie, and it works perfectly in the window. However, back in full screen, I still game very similar results.

We know the viewport is working now, could it be something else? If it helps, when I try to move my mouse into the black bars in the full screen window, sometimes the mouse can't go there, other times it can.

I'm also curious about this part:

Another thing can be happen:when your display (monitor) first time using these WxH settings sometimes it could do some shift&amp;scale operation which produces strange screen results...If this was happend, on LCD\LED monitors do: Menu->Settings->Reset:true

I'm on a laptop, I'm not sure if I have these settings.

Again, thank you very much for all the help so far (and in the other thread too!)

Another thing can be happen:when your display (monitor) first time using these WxH settings sometimes it could do some shift&amp;scale operation which produces strange screen results...If this was happend, on LCD\LED monitors do: Menu->Settings->Reset:true

I'm on a laptop, I'm not sure if I have these settings.

From my own experience:When I'm launching game application which enters to full-screen mode (640x480) on my monitors (LG FLATRONs 1920x1080 & 1680x1050) some part of game's screen becomes outside display or not fully stretched to entire display (some parts of screen are not used). If I would set Menu->Settings->Reset:true (on 640x480 mode) it would automatically, correctly changed (as I expect) and saves in monitor's memory (to load next time shift/scale settings when switching to 640x480 again, this settings are customized and located in each resolution mode).

Labtops have some settings for display (accessed with 'fn' key) but I'm not sure do they have these settings.

If you tested some full-screen applications (with modes:960x540, 1024x576, 1200x675) and they were correctly showed, so this is not a display issue.

I have no experience work with SDL(sorry) but I'm curious about this lines (from your code):