Sign in to follow this  

Aspect Ratio

This topic is 2115 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 all,

I'm working on a particle system and I'm having a problem with the aspect ratio. The screen wdith is 1024x768 and I want to move the camera so that the coordinates of the screen vary from -512 to 512 (x) and -384 to 384 (y). However when I'm drawing a square particle it is obviously being stretched and isn't perfectly square. Is there a simple solution to this problem, i.e. a built-in directx function?

Thanks for your time

Share this post


Link to post
Share on other sites
I have no ready-to-fit solution in terms of Directx and similar Windows-based systems.

I can however tell how I solved aspect ratio problems in Turbo-PASCAL version 7, which runs under native MS-DOS as well as under the well-known Windows MS-DOS box (aka Command Prompt).

I programmed my own graphics pipeline. In the programming for the conversion of geometrical coordinates (X, Y) into pixel coordinates (x, y) I included a compensation for non-square pixels. The key ingredient is a variable YoverX, the height-to-width ratio of the actual pixels; the geometrical Y coordinates are reduced by the factor YoverX before conversion into pixel y coordinates. With square pixels the image on screen would be flattened or stretched in the vertical direction. The actual height-to-width ratio of the pixels undoes the reduction of the Y coordinates, and the picture will be shown as intended.
In my programs the YoverX parameter can be set both as a command line parameter and as an Environment Variable.

Two examples:
(1) many TFT screens have rectangular pixels with height exceeding width by 6%. Set YoverX to 1.06
(2) my iiyama ProLite model B2409HDS has a native resolution 1920x1080px; square pixels. Under Turbo-PASCAL version 7 programs running in a Windows MS-DOS box the highest resolution available is VGA 640x480px; when projected full-screen the height of these VGA pixels is 75% of the width. Set YoverX to 0.75

Turbo-PASCAL and MS-DOS are of course Old School. Nevertheless I hope this post will help.

Good luck: Joher

Share this post


Link to post
Share on other sites
I recommend using world space coordinates instead of screen space coordinates. You'll have a much easier time supporting multiple screen resolutions and aspect ratios. DirectX already has built-in functions for handling objects in world space and by using the world-view-projection matricies, you can move objects and cameras around without worrying about resolutions.

Share this post


Link to post
Share on other sites

This topic is 2115 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this