Jump to content
  • Advertisement
Sign in to follow this  
validator

OpenGL I am new in GL I can't undeerstand what does MatrixMode do

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

Hi, I am new in OpenGL. I tyr to write code in OpenGL so I examine sample codes. while examinig I can not understand What glMatrixMode does and How MatrixMode works. what is the difference GL_PROJECTION and GL_MODELVIEW . in the below jogl code ,why the first GL_PROJECTION, why not MODELVIEW. That is I can not understand. GL gl = drawable.getGL (); gl.glMatrixMode (GL.GL_PROJECTION); gl.glLoadIdentity (); float aspect = (float) width/(float) height; glu.gluPerspective (FOVY, aspect, NEAR, FAR); gl.glMatrixMode (GL.GL_MODELVIEW);

Share this post


Link to post
Share on other sites
Advertisement
By using matrixmode, you specify which matrix you are going to manipulate.
There are four matrixmodes you can operate on:

GL_MODELVIEW:
used for positioning objects in the world.
GL_PROJECTION:
Used to specify screen projection (field of view, aspect ratio etc, perspective correction etc)

GL_TEXTURE:
Used to manipulate texture coordinates.
GL_COLOR:
Used to manipulate colors (Allthough I have no idea how or why)


In your code sample you first specify that you want to work on the projection matrix.
glLoadIdentity resets the matrix.
After that you set the perspective (which should operate on the projection matrix)

Then you specify that you want to operate on the modelview matrix.
Often that matrix is also reset using glLoadIdentity.

Now idealy you start by positioning the camera ( or in other words moving all object in the world). Then you render objects ( possibly moving them in advance)

Hope that helps.

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!