• Advertisement

Archived

This topic is now archived and is closed to further replies.

i can not understand it

This topic is 5007 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

i am just beginner in open gl i read almost beginner''s lesson i find it in the net and i can not understand whae i use it. and i don''t know they using for what all what i know about it glMatrixMode(GL_PROJECTION);// Select The Projection Matrix glMatrixMode(GL_MODELVIEW);// Select The MODEL VIEW glLoadIdentity();// Reset The Matrix Mode that''s all i know about them -i am sorry for my bad english- ff8

Share this post


Link to post
Share on other sites
Advertisement
If your using the nehe.gamedev.net tutorials, they may be a little confusing at first without some knowledge of C/C++ and the Win32 API.

Check out the tutorials at: http://www.winprog.net, that will teach you a little more about some functions and structures involved.

If your still having problems, consider using GLUT in the meantime.

Share this post


Link to post
Share on other sites
The GL_PROJECTION matrix is for setting up the projection mode. There are two: perspective and orthogonal projection. Perspective projection will be set using the glFrustum() or gluPerspective() functions. gluPerspective is a bit more intuitive and easier to use for beginners. Orthogonal projection will be set up using glOrtho(). For gaming you want to user perspective projection, I think.

The GL_MODELVIEW matrix is for setting up the object transformations (translate, rotate, scale). With glLoadIdentity() you will reset the matrix with the identity-matrix (even the projection matrix, too).

Share this post


Link to post
Share on other sites
thanks all for answer me but why we use glLoadIdentity();
after glMatrixMode(); i don''t know what you mean from "reset the matrix with the identity-matrix "
i want example

Share this post


Link to post
Share on other sites
OpenGL''s matrix are 4x4 matrix. If you use glLoadIdentity after glMatrixMode(GL_MODELVIEW); your model/view matrix will be

1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1

That is to say that your objects will not be translated, rotated or scaled before transformation and rendering.
I suggest you to read some maths about matrix transformation. For example http://www-scf.usc.edu/~akotaobi/gptut.html in three dimensional Graphics section

Plotark

Share this post


Link to post
Share on other sites
mmmmmmmmmmmmm
i understand it

when i use glLoadIdentity(); after glMatrixMode(GL_MODELVIEW);
the matrix will change to
1 0 0 0
0 1 0 0
0 0 1 0
0 0 0 1
that''s mean i cannot translated, rotated or scaled before transformation and rendering when i use it after glMatrixMode(GL_PROJECTION); what would the matirx change to?

some lessones the wrote you can make your own matrix how?

Share this post


Link to post
Share on other sites
The matrices will be accumulated each time you perform a transformation. For example:

void Render() {
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glTranslatef(0.0f, 0.0f, -1.0f); // matrix M1
glRotate(45.0f, 1.0, 0.0, 0.0); // matrix M2
glScalef(0.5f, 0.5f, 0.5f); // matrix M3
glutSolidCube(1.0f);
}

This will end up in a accumulated matrix like

P = M1 * M2 * M3

The calculations will be made from right to left. So the cube will first be scaled by half each axis, then rotated by 45 deg. around the x-axis and finally translated along the negative z-axis by 1.0f.

Share this post


Link to post
Share on other sites

  • Advertisement