Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lightrocker

Getting aspect ratio of a monitor

This topic is 5200 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

Is it possible to retrieve the aspect ration of a monitor? I need this to project scenes and graphical user interfaces correctly to the screen, because there are some computers, which got a widescreen monitor. Dividing resolution width by height can result in wrong values (e.g. for 1280x1024 -> 5:4 and not 4:3). So I need a way to get the correct aspect ratio of the monitor. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
1280/1024 == 5/4 == 1.25
1024/768 == 4/3 == 1.3333

else, the user has to specify it (means if the screen is native for 1280x1024 but runs at 1024x768, then the whole image would be deformed anyways)




If that''s not the help you''re after then you''re going to have to explain the problem better than what you have. - joanusdmentia

davepermen.net

Share this post


Link to post
Share on other sites
The aspect ration, which is set in a projection matrix, should not depend on the resolution but the real monitor. If there is a 4:3 monitor, then I want to set 4:3 also for non-4:3 resolutions like 1280x1024. And if there is a widescreen monitor, then I want to set its real aspect ratio and not the one of the user-defined resolution.

Is it possible? I did not find a method to get it.

Share this post


Link to post
Share on other sites
If you use a projection matrix built with a correct aspect ratio in mind and you don''t do any direct blitting of pixels, then you won''t have a problem. For 3d graphics, this is a non issue.

If you have a 2D interface or view images, things get weird.

Share this post


Link to post
Share on other sites
quote:
Original post by GameCat
If you use a projection matrix built with a correct aspect ratio in mind and you don''t do any direct blitting of pixels, then you won''t have a problem. For 3d graphics, this is a non issue.

It''s not a non-issue in the case the original poster was concerned about - widescreen monitors. The vast majority of users have standard 4:3 monitors but there are widescreen monitors out there with a 16:9 aspect ratio and also monitors that can be rotated to give a portrait display with a 3:4 aspect ratio. Monitors with non-standard aspect ratios may well have non-square pixels in many video modes so you can''t automatically calculate the correct aspect ratio based on the screen resolution (that doesn''t work in the inexplicably popular 1280x1024 screen mode on a standard monitor for example). As far as I know all displays are one of 4:3, 16:9 or 3:4 and 3:4 displays can always (I believe) be rotated to a standard 4:3 mode so the easiest thing to do is probably to let the user specify the aspect ratio of their monitor as either 4:3 or 16:9 and use that regardless of the resolution.

Share this post


Link to post
Share on other sites
mattnewport is right. I have no problems with displaying two-dimensional images or interfaces, if I have got the correct aspect ratio. I hoped, that there is a Windows API function, which returns the dimension or the aspect ratio of the monitor. GetDeviceCaps is not doing so.
So a user definition seems to be the only way, but I found out that my desktop TFT monitor has got a 5:4 aspect ratio while my CRT and my laptop TFT are 4:3 ones. Does anybody know, if there are some other monitors than 16:9, too?

Share this post


Link to post
Share on other sites
Out of curiosity, how did you verify that GetDeviceCaps does not work? I am asking since (years ago) I wrote an app where I wanted stuff to appear the same size on screen as the dimensions specified and I used it - seemed to work with the limited tests I did. Thus I simply cut/paste the code in my gl app thinking it would.

I did notice that ASPECTX/ASPECTY returns a small integer and probably is rounded off so I chose to use HORZSIZE/VERTSIZE (since they were in mm) and did my calculations off there.

I was assuming that (if the user has the proper monitor type in Display Properties) that everything would work fine.

Guess I should get off my lazy butt and haul this computer in the other room and try it on my widescreen DLT with that DVI connector aching to be used. Then I''ll know for sure.

Share this post


Link to post
Share on other sites
One thing I would suggest is to just use the desktop resolution that the user is normally running off. I know that''s not really what you want to do, but think about it this way.... If the user is running a res that gives a 4:3 aspect ratio, then that is what the user is comfortable with, and most likely is the proper ratio for his/her monitor.. If the user has a widescreen, then the ratio will most likely represent that..

Share this post


Link to post
Share on other sites
@JotDot:

GetDeviceCaps() using HORZSIZE/VERTSIZE results in 4:3 for resolutions like 640x480, 800x600, 1024x768... and 5:4 for 1280x1024 and not real monitor aspect ratio. I already tried that.

@mrhodes:

The GUI of Windows is working another way than I want for my games, in which the GUI should be arranged the same way for the same monitor in every possible resolution. In Windows there fits more information into the screen the higher the resolution is. I only want a higher quality for a higher resolution.

Share this post


Link to post
Share on other sites

  • 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!