glFrustum (.....)

3216e03e8ddff73a6b3aaa14ddd7830c
0
me_here_me 101 Jun 14, 2007 at 12:13

Hi,
When i use the glFrustum funtion to set up my projection matrix, it works fine. But as soon as I want to calculate the matrix myself, it does not work.

Following code works:

glViewport( 0, 0, (GLsizei)w, (GLsizei)h );

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
glFrustum( -.4, .4, -.3, .3, 1., 1300. );
glMatrixMode( GL_MODELVIEW );

// continues

the following does not :(

glViewport( 0, 0, (GLsizei)w, (GLsizei)h );

glMatrixMode( GL_PROJECTION );
glLoadIdentity();
matrix4x4 projection;
projection = calculateFrustum(-.4, .4, -.3, .3, 1., 1300.);
glLoadMatrixf(projection);
glMatrixMode( GL_MODELVIEW );

// code continues

Some how my calculation of the Frustum matrix does not match that of the one calculated by the openGl. Can you please point out whats wrong in here.

I am using the defination given on the following page for “calculateFrsutum” funtions call:

http://msdn2.microsoft.com/en-us/library/ms537094.aspx

thanks in advance

1 Reply

Please log in or register to post a reply.

A8433b04cb41dd57113740b779f61acb
0
Reedbeta 167 Jun 14, 2007 at 16:18

Make sure you store your matrix in column major order, since that’s how OpenGL will expect it. The “natural” way to store a matrix in C uses row major order. You’ll have to transpose to interchange the two.