delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/05/23/14:48:56

From: ellman AT xs4all DOT nl ()
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Allegro camera things (aspect)
Date: 23 May 1997 12:10:24 GMT
Organization: XS4ALL
Message-ID: <5m41fg$61r$1@news0.xs4all.nl>
References: <01bc66fe$da95ada0$e13663c3 AT default>
NNTP-Posting-Host: xs2.xs4all.nl
Lines: 42
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

In article <01bc66fe$da95ada0$e13663c3 AT default>,
Thomas Harte <T DOT Harte AT btinternet DOT com DOT REMOVE_THIS_BIT> wrote:
>	I just recompiled Allegro (under Pentium GCC, as it happens, but I don't
>think this is related), and now I notice that when I use 3d, the correct
>aspect ratio is no longer set. What I want to now is - how do you calculate
>this? I know the aspect ratio of a monitor is 4:3, but I do not understand
>what Allegro wants of me.
>
>		-Thomas

I don't know what effect re-compiling Allegro with PGCC has, but normaly,
the persp_project() function distorts the view to the rectangle of the
projection viewport (which isn't usually square). If you have some points at
the end of the long-end of the viewport and rotate 90 degrees, the points are
now at the short-end instead of off the viewport where they should be.

To correct this, use the following matrix to compensate for the perspective
distortion.

get_scaling_matrix_f(&tmp_matrix_1, 1.0, ((float) SCREEN_W)/((float)SCREEN_H), 1.0);
Or if you're using fixed numbers, use:
get_scaling_matrix(&tmp_matrix_1, 1<<16, fdiv(itofix(SCREEN_W),itofix(SCREEN_H)), 1<<16);

Replace SCREEN_W with the viewport width and SCREEN_H with the viewport height.

This matrix must be applied after the rotations, etc, so if you're using it
with a camera matrix, do the following.

matrix_mul_f(&orginal_camera_matrix, &tmp_matrix_1, &camera_matrix);

If you're using Allegro's get_camera_matrix to do your transformations, you can
make use of the 'aspect' paramater (the last paramater) and pass the the
height-to-width ratio (although this may be the width-to height ratio) as used
with get_scaling_matrix.

AE.

--
Andrei Ellman -- URL: http://www.xs4all.nl/~ellman/ae-a -- ae1 AT york DOT ac DOT uk
"All I wanna do is have some fun     :-)      ||  ae-a AT minster DOT york DOT ac DOT uk
 I've got the feeling I'm not the only one"   ||  mailto:ellman AT xs4all DOT nl
     -- Sheryl Crow      :-)    ||       It's what you make of it. 

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019