Mail Archives: djgpp/1997/05/25/10:01:55
In article <5m65ob$hqr AT freenet-news DOT carleton DOT ca>,
Paul Derbyshire <ao950 AT FreeNet DOT Carleton DOT CA> wrote:
>
> (ellman AT xs4all DOT nl) writes:
>> 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.
Allegro's persp_project function lets you specify the viewport size, and it
doesn't have to be a rectangle of 4*3. In fact, you could have four
1*3 views next to each other.
As for pixel aspect ratio, I don't think it's worth taking that into account
anymore (except for the really odd versions of MODEX), because most monitors
have the ability to stretch the image either horizontally or vertically and
different users have different settings, so pixel aspect for the same mode is
no longer conststent on different monitors.
AE.
- Raw text -