Sign in to follow this  
lamtab

get projection matrix

Recommended Posts

Hello all!!!! I'd like some help getting the projection matrix. I use the following code but it doesnt seem to work properly. What id does is get the same matrix no matter what transformations I apply. glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(80,1.0,1.0,5000.0); glTranslatef(100.0,-10.0,-5.0f); //Here I render the geometry. no transformations are taking place. glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrix); projectionMatrix is an array float[16] No matter any changes to the translatef parameters the projectionMatrix is always the same. Thanks in advance...

Share this post


Link to post
Share on other sites
switch to modelview matrix then use glTranslatef

glMatrixMode (GL_MODELVIEW);
glLoadIdenity();
glTranslatef(x,y,z);
// render jeomtry


calling projection matrix at first of program is enought and you dont need to recalculate and load it in every frame.

Share this post


Link to post
Share on other sites
I've tried that and the projection matrix is still the same.
What i'm actually trying to do is get the projection matrix before and after the translate command.

Share this post


Link to post
Share on other sites
yeap in every frame i print the matrices.
u mean i shouldnt use loadidentity?

can u give me a small example of how u think this should be done?
(i mean with code)
something like

glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrixA);
gluPerspective(80,1.0,1.0,5000.0);
glTranslatef(100.0,-10.0,-5.0f);
//geomtry
glGetFloatv(GL_PROJECTION_MATRIX, projectionMatrixB);

Share this post


Link to post
Share on other sites
void init_func()
{
// load projection matrix
}

void render_func()
{
glMatrixMode(GL_PROJECTION);
glTranslatef (x,y,z);
// render some thing
glMatrixMode(GL_MODELVIEW);
glLoadIdentity()
// render object
...

}

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this