Public Group

# Aspect Ratio

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

## 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?

##### Share on other sites
Your projection would normally take care of this. Your horizontal field of view is essentially too wide.

##### 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 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.

1. 1
2. 2
Rutin
21
3. 3
A4L
15
4. 4
5. 5

• 13
• 26
• 10
• 11
• 44
• ### Forum Statistics

• Total Topics
633740
• Total Posts
3013621
×