get projection matrix

Started by
7 comments, last by lamtab 14 years, 11 months ago
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...
Advertisement
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.
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.
are u check it in every frame?

i think becase you are using glLoadIdentity , its values is same in every frame.
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);
Curious as to why you want to translate the projection matrix. The view matrix is ideally for the camera, the world matrix for your objects.
i need the projection matrices to apply motion blur :)
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
...

}
thx pooya65.
i had in mind something like this myself. i was just missing something.

This topic is closed to new replies.

Advertisement