get projection matrix
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...
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.
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.
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.
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);
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.
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
...
}
{
// load projection matrix
}
void render_func()
{
glMatrixMode(GL_PROJECTION);
glTranslatef (x,y,z);
// render some thing
glMatrixMode(GL_MODELVIEW);
glLoadIdentity()
// render object
...
}
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement