Jump to content
  • Advertisement
Sign in to follow this  

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

This topic is 3685 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
By using matrixmode, you specify which matrix you are going to manipulate.
There are four matrixmodes you can operate on:

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

Used to manipulate texture coordinates.
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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!