LWJGL Forum

Programming => Lightweight Java Gaming Library => Topic started by: darkmoon on November 05, 2006, 15:44:48

Title: widescreen support?
Post by: darkmoon on November 05, 2006, 15:44:48
Hello,
I have a widescreen monitor, and my OS allows me to choose between stretched and not stretched display modes for resolutions like 640x480 and  800x600 etc.
When I choose a 640x480 display mode with lwjgl, I always get the stretched one.
Is there some way to make lwjgl choose the non stretched display mode? That would look a lot better for my game...
Title: widescreen support?
Post by: appel on November 06, 2006, 05:47:10
You should check out the wiki page, there is an example there that allows you to define your resolution.
http://lwjgl.org/wiki/doku.php/lwjgl/tutorials/display/basicdisplay
Title: widescreen support?
Post by: darkmoon on November 06, 2006, 09:53:56
Yes, I know how to change resolution. Sorry if my question isn't clear.
What I'd like to do is keep the 4:3 proportions of 640*480 when changing to this resolution on a widescreen monitor. The system can do it (and you get black bars on the left and the right), so it would be cool if this display mode was accessible from lwjgl...
Title: widescreen support?
Post by: ndhb on November 07, 2006, 11:09:30
The aspect ratio usually depends on whether your monitor and/or graphics card is set up to Scaling. It doesn't really depend on the resolution you choose, it depends on your configuration. Check out your driver configuration or OSD on monitor.
Title: widescreen support?
Post by: ndhb on November 07, 2006, 11:27:54
My own system does the same whether I invoke a C OpenGL program or a LWJGL OpenGL program.

If the NVidia driver is set to "Display Adapter Scaling" it scales the resolution (Dell 2005 monitor is set to 1:1) and disregards the aspect ratio of the resolution. Other options in the driver preserves the aspect ratio of the chosen resolution. I don't think there's any way to force users to change aspect ratio (without probing into their OS).
Title: widescreen support?
Post by: darkprophet on November 08, 2006, 00:48:50
Ive managed to hack that...its quite easy actually.


public void createDisplay() {
 DisplayMode mode = Display.getDisplayMode();
 float ratio = mode.getWidth()/mode.getHeight();
 if (ratio >= (16d/9d)) {
   createWidescreen();
 } else if (ratio >= (4d/3d)) {
   createNormalAspect();
 }
}


Enjoy :)
Title: widescreen support?
Post by: the2bears on November 08, 2006, 06:59:24
Quote from: "darkprophet"Ive managed to hack that...its quite easy actually.


public void createDisplay() {
 DisplayMode mode = Display.getDisplayMode();
 float ratio = mode.getWidth()/mode.getHeight();
 if (ratio >= (16d/9d)) {
   createWidescreen();
 } else if (ratio >= (4d/3d)) {
   createNormalAspect();
 }
}


Enjoy :)

Simple, but effective.  I've been thinking about this too, since my laptop is 1920x1200 and fullscreen was bugging me.  Thanks :)

Bill
Title: widescreen support?
Post by: darkmoon on November 08, 2006, 14:40:37
It's not clear to me how you would implement createWidescreen(). For 640*480 to fit, you would need a 853*480 display mode, but this does not exist in the available display modes.
Title: widescreen support?
Post by: darkprophet on November 09, 2006, 11:26:57
You have the ratio for the width to height now. All you need to do is multiply the width by that ratio to get the height, then enumerate through the available display modes to see if one fits.

DP
Title: widescreen support?
Post by: oNyx on November 15, 2006, 00:56:10
Btw the common ratios are 4:3, 5:4 (1280x1024 tft panels), 16:9 (rare) and 16:10.