Advertisement

Calculating aspect ratio

Started by October 10, 2000 01:55 AM
5 comments, last by neocron 24 years, 3 months ago
Hi, How do you get the aspect ratio of a surface in DirectDraw? (Fullscreen and window modes) Thanks! Karen
quote: Original post by neocron

How do you get the aspect ratio of a surface in DirectDraw? (Fullscreen and window modes)


Just divide the width by the height.

-Jussi
Advertisement

I''ve been using:

    //// Fullscreen//double fAspect = (double(m_nVidHeight)/m_nVidWidth)*320./240.;//// Windowed//double fAspect = double(GetDeviceCaps(hdc,LOGPIXELSY))/GetDeviceCaps(hdc,LOGPIXELSX);    


Using the constant 320./240. in my app seems to work ok - it seems a bit of a hack though. Is there a more sensible way?
???? the formula is simple as f**k, Width / Height. So I wonder if your question is not something else ...

did you try to use the GetSystemMetrics, so you would get the different pixel sizes of the screen (among other things ... as usual, read the MSDN ! )

Why on earth would you use constants in your fulscreen formula ???
What you are getting with the current formula is a ... ratio between two ratio, which is not very useful, is it ?

16/9 or 4/3 are classic screen ratio, used in TV. Is that the aspect ratio you are referring to, or do you have something different in mind ?

hope it helps.

youpla :-P
-----------------------------Sancte Isidore ora pro nobis !

Thanks Selrank/ahw.

All I really want to do is to be able to, say, draw an ellipse on any screen mode and it comes out looking like a circle every time.

Using just Width/Height as the pixel aspect doesn''t work. Fudging in 320./240. helps a lot (this constant is also used in commercial games; look at the ''Quake'' source for instance). It''s saying that at any mode where the w/h ratio is 240./320. you will get a pixel aspect ratio of 1.0.

I know the formula is simple but it simply doesn''t work without the fudged constant! I know there has to be a better way.

Yes, I do feel dumb asking such a simple question :-)
oooh, I get it now. It''s not as simple as you say. The problem is that the *pixel* ratio is ometimes different from the *monitor* ratio. Taht''s why 320x200 was reknowned to make slightly elliptical circles (but you could correct that through modifying your monitor''s setting, you know, the little switches and stuff on the monitor face), and 320x240 was said to be displaying *square pixels*

You CAN''T make sure that the circle is a circle, because if the settings on the user screen are f**ked up, it''s his fault. It''s like the gamma settings, colour settings, etc.
you''d have to do a calibrating thing in your program if it''s taht vital

youpla :-P
-----------------------------Sancte Isidore ora pro nobis !
Advertisement
quote: Original post by ahw

Taht''s why 320x200 was reknowned to make slightly elliptical circles


It''s funny that they still looked like circles, except if you twisted your head 90 degrees, they didn''t. I guess people just got used to it.

-Jussi

This topic is closed to new replies.

Advertisement