Jump to content
  • Advertisement
Sign in to follow this  
lamtab

get projection matrix

This topic is 3456 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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
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.

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
are u check it in every frame?

i think becase you are using glLoadIdentity , its values is same in every frame.

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
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.

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
thx pooya65.
i had in mind something like this myself. i was just missing something.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!