Jump to content


glFrustum (.....)


1 reply to this topic

#1 me_here_me

    New Member

  • Members
  • PipPip
  • 24 posts

Posted 14 June 2007 - 12:13 PM

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.microso...y/ms537094.aspx

thanks in advance

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 4979 posts
  • LocationBellevue, WA

Posted 14 June 2007 - 04:18 PM

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.
reedbeta.com - developer blog, OpenGL demos, and other projects





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users