glFrustum() maths... are they correct?
As I'm becoming increasingly irritated by the limitations of gluPerspective(), I thought I'd code a quick function to set-up a perspective view...
It's missing a lot of useful functionality (ensuring near < far, for a start), but I've quickly tested it, and it seems to return the results I'd expect (for example, for a 45° view, as the apparent dimensions of an object halve every time the distance from the near point doubles.)
But I just wondered whether a more knowledgable coder would take a look, point out any (inevitable?) errors in the maths
Code:
void Perspective( const double p_halfWidth,
const double p_halfHeight,
const double p_angle,
const double p_far,
double *p_near )
{
const double near = ( p_halfWidth / tan( p_angle * ( 3.141592654 / 180.0 )));
glFrustum( -p_halfWidth, p_halfWidth,
p_halfHeight, p_halfHeight,
near, p_far );
*p_near = near;
return;
}But I just wondered whether a more knowledgable coder would take a look, point out any (inevitable?) errors in the maths
Mark Bishop
What on earth is wrong with using gluPerspective()?
- Alex Diener
- Alex Diener
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Having trouble with glFrustum()? | KittyMac | 2 | 3,353 |
May 2, 2007 01:32 PM Last Post: arekkusu |
|
| correct glDepthFunc() parameter? | Vertizor | 4 | 3,472 |
Sep 28, 2004 08:32 AM Last Post: Vertizor |
|

