From: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) Newsgroups: comp.os.msdos.djgpp Subject: Re: Allegro camera things (aspect) Date: 24 May 1997 07:35:39 GMT Organization: The National Capital FreeNet Lines: 45 Message-ID: <5m65ob$hqr@freenet-news.carleton.ca> References: <01bc66fe$da95ada0$e13663c3 AT default> <5m41fg$61r$1 AT news0 DOT xs4all DOT nl> Reply-To: ao950 AT FreeNet DOT Carleton DOT CA (Paul Derbyshire) NNTP-Posting-Host: freenet2.carleton.ca To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk (ellman AT xs4all DOT nl) writes: > In article <01bc66fe$da95ada0$e13663c3 AT default>, > Thomas Harte 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. What about simply scaling by 4/3? No matter what the viewport settings are, the monitor is 4/3 as wide as high. -- .*. Where feelings are concerned, answers are rarely simple [GeneDeWeese] -() < When I go to the theater, I always go straight to the "bag and mix" `*' bulk candy section...because variety is the spice of life... [me] Paul Derbyshire ao950 AT freenet DOT carleton DOT ca, http://chat.carleton.ca/~pderbysh