   [matrix]modelview and projection
  I'm not really understand what  do the1)MatrixMode and Projection Matrix2)MODELVIEW and modelview matrixglViewport(0,0,width,height);// Reset The Current ViewportglMatrixMode(GL_PROJECTION);// Select The Projection MatrixglLoadIdentity();// Reset The Projection Matrix// Calculate The Aspect Ratio Of The WindowgluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,100.0f);glMatrixMode(GL_MODELVIEW);// Select The Modelview MatrixglLoadIdentity();thanks   
  The MatrixMode selects which of the 3 matrix stacks OpenGL knows is affected by sub-sequently invoked glTranslate, glRotate, glMultMatrix, and so on. E.g. with the MatrixMode set to GL_PROJECTION the projection matrix is affected.The projection matrix is part of the mapping of the 3D scene (as is seen from the camera (or eye)) to the 2D screen. E.g. one kind of projection, namely the perspective projection, is responsible for the depth foreshortening, i.e. that objects more far away appear smaller.The MODELVIEW matrix is for transforming the mesh of a model from its local co-ordinates to world co-ordinates (the MODEL portion of the matrix), and then from the world co-ordinates to the camera (or eye) co-ordinates (the VIEW portion).Looking at all those transformations, OpenGL applies them asP * V * Mwhere P denotes the matrix that is build when GL_PROJECTION was active, V is the view matrix, and M the model matrix, in summary build when GL_MODELVIEW was active.Utility routines like gluPerspective build a projection matrix, as glFrustum and glOrtho do, too. So they are sensefully to be invoked when GL_PROJECTION is active (although they _can_ be invoked for any other matrix stack, too).   ;  I'm also confused by the matrices since i started working with OpenGl. But somehow i was always able to acchief what i indended.Can it be described like this?Projection: That's how the "photo" of the 3d space is taken. It defines how to project the 3d coordinates onto the 2d screen.Modelview:Describes the object'S alignment in comparision to the global world.Modelviewprojection: Does this actually deliver pixel coordinates for 3D points? That's basicly what i'd understand.Remember, i asked this as a question, don't take is as an answer.   ;  MODEL is how the object (a.k.a model) is placed in the worldVIEW is how the world is placed w.r.t. the camera (or, in other words, its the inverse of how the camera is placed in the world)hence MODELVIEW is how the objects are placed w.r.t. the cameraPROJECTION is how the 3D scene seen through the camera (i.e. already influenced by the MODELVIEW) is made 2D; (okay, this is a bit coarse; there is a little bit more to do; in fact the projection matrix computes a cube from the visible volume (see below) and that is mapped then to the pixel of the screen, but this level may not be of interest here)In the above to "place" means a combination of positioning, orientating, and perhaps scaling, whatever is used.The usual projection is perspective projection. Assume you shoot a ray from the camera's position through each pixel of the view. Since all these rays start in a single point but go throught different pixels, they are not parallel but can be seen as a pyramid. Now, all these rays are a line-of-sight, each one for the particular pixel they pass through. Hence, in principle all surface points of objects hit by a particular ray are to be mapped onto the same pixel. The frontmost pixel will hide all others behind, and hence will be displayed in the end.However, the projection matrix does exactly this when being set-up as perspective matrix. It does it in another way: It transforms the space so that the rays all become parallel. Then all hits of a particular ray will have the same (x,y) co-ordinates, but still different z (depth) co-ordinates.If you ask how it could be done to make those rays parallel, then I must say that I was a bit sloppy. In fact, not a pyramid but a frustum is used by cutting the apex of the pyramid. For such a construct the space can be scaled in local x and y direction until the rays are in parallel. Such a frustum is called the view frustum, and glFrustum (if using OpenGL) is useable to set it up. The fact that the pyramid cannot be scaled accordingly is the reason why the near plane must have a distance greater than zero (see the  parameters of glFrustum).   ;Quote:Original post by haegarrHowever, the projection matrix does exactly this when being set-up as perspective matrix. It does it in another way: It transforms the space so that the rays all become parallel. Then all hits of a particular ray will have the same (x,y) co-ordinates, but still different z (depth) co-ordinates.Let me add few points here 1. Here the perspective transformation converts a point in (homogeneous) eye coordinates (x,y,z,1) to a point in  clipping coordinates (x',y',z',w'). The clipping coordinates are converted to normalized device coordinates (x'',y'',z'') by dividing with w (homogeneous coordinate). The first two coordinates, (x'',y''),  obtained thereby determines the image point.  The third coordinate, z'', is used for visible surface determination by means of the Z-buffer algorithm, where points lying closer should have a smaller z'' value. 2.In raster graphics technique, no ray is generated from the camera. This idea is only in ray tracing technique.;Quote:Original post by serious_learner072.In raster graphics technique, no ray is generated from the camera. This idea is only in ray tracing technique.Technically that is correct, but the rays help (IMHO) to undestand why the viewing volume is a frustum. That's the reason I've mentioned them. But you're right: I have should hinted at this being used for explanation only.   