Jump to content
  • Advertisement
Sign in to follow this  
dma42

how to detect widescreen displays?

This topic is 4829 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, does anyone know how to detect the aspect ratio of the monitor (4:3, 16:9, 16:10) ? ----- dma

Share this post


Link to post
Share on other sites
Advertisement
You dont really 'detect' the aspect ratio. The best way to support widescreen is not to treat it any differently. Simply gather up all of the reported video modes (GetAdapterModeCount, EnumAdapterModes, etc), present them to the user, and let them choose which one they want. If the user has properly set up their monitor, the supported modes (including widescreen) will be available. If you're doing 3D, set up your projection matrix with D3DXMatrixPerspectiveFovLH or similar, and your widescreen view will be proportionally correct.

Share this post


Link to post
Share on other sites
thanks for your awnser scoob,

but the problem is that not every screen resolution has a 1:1 pixel aspect.

example:
The 800x600 mode is available on both, 16:10 and 4:3 displays. In both cases the image is stretched to the whole area of the monitor. But on a 16:10 display it is more stretched in width and the projection matrix must be set up different than on a 4:3 display ... but how to find out if it is an 16:10 display?

My current solution to that is to get the monitor aspect from the aspect of the desktop window (which normaly has the native resolution of the display), but that doesn't work when the user works on a multimonitor system or uses a virtual desktop ...

----
dma

Share this post


Link to post
Share on other sites
You're going to have to put a checkbox toggle in your game's video settings screen. On XBox you can query the system configuration for things like widescreen, HDTV, NTSC vs. PAL. On a PC you're out of luck. The user can specify their monitor DPI (desktop right click, properties, settings, advanced, general, choose custom DPI, adjust setting), but can't set horizontal and vertical seperately. You could GetMonitorInfoEx(), and keep a list of which monitor names are 16:9. It would be a nice trick to get a default setting for the checkbox you'll invariably need.

Some info on aspect ratios of various modes.
http://www.hitmill.com/html/screen.html

Share this post


Link to post
Share on other sites
the most common solution to this is detect the aspect ratio of the desktop, then use this to determine the widescreen ratio (16:10, 16:9, 4:3). GetDeviceCaps takes an HDC as an argument, this will deal with multi-monitor setups (ie, use the primary monitors HDC). It might also be of some interest to investigate the Multiple Monitors Overview at MSDN, in particular the MONITORINFO and MONITORINFOEX structs.

Share this post


Link to post
Share on other sites
Just a quick question/suggestion. In Managed DirectX you can query the screen width and height using System.Windows.Forms.Screen.PrimaryScreen.Bounds. I don't know if something similar is available in C++, but I always use these bounds for making a fullscreen window.

This discussion made me wonder what the Bounds property actually returns... In the VS docs it says it returns the bounds of the screen, great! But does it return the current desktop resolution or the native screen resolutions? Anyway, either case should typically (i.e. as long as the user didn't set a wrong desktop resolution) be fine to determine the aspect ratio, right?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!