Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
IRIS GL and OpenGL handle matrices and transformations in a similar manner. But there are several differences to keep in mind when porting code from IRIS GL:
In OpenGL you are always in double-matrix mode; there is no single-matrix mode.
Angles are measured in degrees, instead of tenths of degrees.
Projection matrix calls, like glFrustum and glOrtho, now multiply onto the current matrix, instead of being loaded onto the current matrix.
The OpenGL function, glRotate, is very different from rotate. You can rotate around any arbitrary axis, instead of being confined to the x-, y-, and z- axes. For example, you can translate:
rotate(200*(i+1), 'z');
to:
glRotate(.1*(200*(i+1), 0.0, 0.0, 1.0);
When translating from rotate to glRotate you switch to degrees from tenths of degrees and replace 'z' with a vector for the z-axis.
OpenGL has no equivalent to the polarview function. You can replace it easily with a translation and three rotations. For example, you can translate:
polarview(distance, azimuth, incidence, twist);
to:
glTranslatef( 0.0, 0.0, -distance); glRotatef( -twist * 10.0, 0.0, 0.0, 1.0); glRotatef( -incidence * 10.0, 1.0, 0.0, 0.0); glRotatef( -azimuth * 10.0, 0.0, 0.0, 1.0);
The following table lists the OpenGL matrix functions and their equivalent IRIS GL functions.
IRIS GL function | OpenGL function | Meaning |
---|---|---|
mmode | glMatrixMode | Sets current matrix mode. |
glLoadIdentity | Replaces current matrix with the identity matrix. | |
loadmatrix | glLoadMatrixf,glLoadMatrixd |
Replaces current matrix with the specified matrix. |
multmatrix | glMultMatrixf,glMultMatrixd |
Post-multiplies current matrix with the specified matrix (note that multmatrix pre-multiplied). |
mapw, mapw2 | gluUnProject | Projects world-space coordinates to object space (see also gluProject). |
ortho | glOrtho | Multiplies current matrix by an orthographic projection matrix. |
ortho2 | gluOrtho2D | Defines a two-dimensional orthographic projection matrix. |
perspective | gluPerspective | Defines a perspective projection matrix. |
picksize | gluPickMatrix | Defines a picking region. |
popmatrix | glPopMatrix | Pops current matrix stack, replacing the current matrix with the one below it. |
pushmatrix | glPushMatrix | Pushes current matrix stack down by one, duplicating the current matrix. |
rotate,rot |
glRotated,glRotatef |
Rotates current coordinate system by the given angle about the vector from the origin through the given point. Note that rotate rotated only about the x-, y-, and z-axes. |
scale | glScaled,glScalef |
Multiplies current matrix by a scaling matrix. |
translate | glTranslatef,glTranslated |
Moves coordinate-system origin to the point specified, by multiplying the current matrix by a translation matrix. |
window | glFrustum | Given coordinates for clipping planes, multiplies the current matrix by a perspective matrix. |
OpenGL has three matrix modes, which are set with glMatrixMode. The following table lists the modes available as parameters for glMatrixMode.
IRIS GL matrix mode | OpenGL mode | Meaning | Min stack depth |
---|---|---|---|
MTEXTURE | GL_TEXTURE | Operates on the texture matrix stack. | 2 |
MVIEWING | GL_MODELVIEW | Operates on the model view matrix stack. | 32 |
MPROJECTION | GL_PROJECTION | Operates on the projection matrix stack. | 2 |