Wide Screen support for games.

Some ppl are complaning that my game shows a streched view when they run with a wide screen display. I am wondering is there any way for me to detrmine that they are using a wide screen display? Is there any resolution (for instance 1440 x 900) that only widescreen display has so that i can determine this and run the game in windowed mode instead?

float ratio = screen.w/screen.h;

if(ratio is about 4/3) // 1028x1024 is a nasty one

else if(ratio is about 16/9)

else

ok, there seems to be some nice stuff in Toolkit.getDefaultToolkit() to get the dimension of the screen :slight_smile:

java.awt.GraphicsEnvironment.getDefaultScreenDevice().getDisplayMode() getWidth() | getHeight()

java.awt.Toolkit.getDefaultToolkit().getScreenSize() width | height

1028x1024 is a nasty one

Thats 5:4. Or a stupid res used on a 4:3 crt.

The popular ratios are 4:3, 5:4, 16:10 and 16:9 (rare).

Currently i am using this

if(ratio<1.4) goto fullscreen;
else run in windowed mode;

Just so that those 16:9 screens wont get odd graphics.

Is 16:9 really rare?

It’s the ratio humans see the outside world 8)

that’s why they invented the wide-screen in the first place

Or … just write your GUI properly so that it uses a layout manager and doesnt arbitrarily stretch the screen? [/facetious]

Seriously, though, you should always use a layout manager, even if its just a very simple one that adds borders to the sides or top/bottom and keeps fixed ratios internally. IME its pretty easy to write your own manager that will cope with any resolution, and then you dont annoy the people whose large monitors you’re wasting :).

Yes, widescreen PC displays are usually 16:10. Not really sure why… guess it makes sense in this context to have at least that much height.

Can you really reliably determine the screen aspect ratio from the resolution? I suppose this makes the assumtion that pixels are of a fixed aspect ratio, which I think they aren’t. What if your drivers support 1024:768 on a wide screen?
I suppose you can do a guess at best, but you might still need an option to manually switch between 4:3 and 16:9 displays.

Look at the maximum resolution from the display modes. That is indicitive of the ratio of the screen. Do not look at the current resolution…

DP

Oh yea… I made some images a while back to visualize things a bit:
http://kaioa.com/k/ar1.png (scaled to same height)
http://kaioa.com/k/ar2.png (scaled to same width)