views:

304

answers:

4

My situation is as follows. I make games that use fixed size backgrounds (say 800x600). When players go fullscreen in a widescreen monitor, I add black bars to the sides, to make sure the game doesn't look stretched.

There are several ways to do this, though, and I wonder what's the best approach :

1) Find a resolution that closely matches the native aspect ratio of the monitor, and scale up the rendered image to fit the height. For example, my monitor is 1280x800, so I set that resolution, and scale the images by 1.33 - it takes 1066x800 but it looks fine. Drawbacks : scaling up, but scaling is uniform (so pixels are still square)

2) Set 800x600 fullscreen, scaling down the width by 0.625, so the rendered image looks not-stretched. Drawbacks : non-uniform scaling. Does this look good?

3) Something else

What do you think is the best way to do this?

+2  A: 

Solution 1) sounds the best for me (easy to implement and performance wise).

You could also render your game in a fixed-size texture (800x600) and then render a quad (two triangles that are screen-aligned) to the native screen resolution, right in the middle, with texturing enabled and the fixed-size texture bound to the pipeline.

Stringer Bell
A: 

Don't really have much experience in this, but is it important that the whole background is visible? If not, how about scaling it like you can do with backgrounds in windows: Fill the screen and clip of the edges that get outside on the bottom and top (or left and right). That way the aspect ratio of the image won't be messed up too.

If the quality is bad, how about having a larger image and scaling down instead? Should be better quality than scaling up at least.

Svish
A: 

Mhn...as far as I know this is already done by most driver as an option without needing of particular coding. (At least Intel one have it, and works perfectly. It has three modes, stretching unrestricted, stretching maintaining aspect ratio (with the black bands), centered (without stretching))

Anyway if you have to code it prefer going with uniform scaling otherwise you'll get bad results. :P

feal87
+3  A: 

I would suggest your option 1 also. Specifically, you want to leave the display resolution in the native monitor resolution if at all possible. Most people are using LCD displays these days, and if the output resolution doesn't match the native display resolution (or isn't a very convenient multiple) then you can get some horrible artefacts and blurring. So definitely start with the native resolution, figure out the lesser dimension (likely height, as widescreen is all the rage) and pillbox the sides. You definitely want to keep square pixels. You might even find (depending on the size ratio between your game assets and the output) that you get better results if you round the scaling down.

gavinb