kabrit

12-01-2001, 03:15 PM

glViewport(0, 0, cx, cy);

glMatrixMode (GL_PROJECTION);

glLoadIdentity();

gluPerspective (60.0f, (GLfloat)cx/(GLfloat)cy, 1.0f, 1000.0f);

I would like to know what these command mean

Morglum

12-03-2001, 07:30 AM

Hi !

These few line are very typical. You should look for a book (the superbible is the best to start with under windows). This code just sets up the viewport position/size and the perspective parameters (e.g. the angle of view , which is here 60 degrees).

Here is a short line-by-line description :

glViewport(0, 0, cx, cy);

Specifies the region of the window that will be used for opengl rendering. if cx = width of window and cy = height of window, then the whole window will be used. This will be the case if cx and cy are passed as arguments in a "reshape" or "resize" function.

glMatrixMode (GL_PROJECTION);

Specifies that we want to manipulate the projection matrix. In general, there are 2 important matrices in ogl : GL_PROJECTION ( used here to specify the perspective) and the GL_MODELVIEW, used to manipulate objects in the 3D space.

glLoadIdentity();

Sets the current matrix to the identity matrix. Concretely, this cancels all past modifications to this matrix.

gluPerspective (60.0f, (GLfloat)cx/(GLfloat)cy, 1.0f, 1000.0f);

Sets the current matrix to a "perspective" matrix. Don't matter about how this matrix is computed. You just need to know that this line sets a 60 degree angle of view (which is rather large, in most cases 40-50 degrees yield a better result), that the second parameter is the aspect ratio (try setting it to 2 times more, and then to 0.5 times more, and see what happens) and the two last parameters specify distances of the nearest viewable point and of the farthest one.

Good luck !

Morglum

Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.