Appendix a Opengl Function Reference
Total Page:16
File Type:pdf, Size:1020Kb
Appendix A OpenGL Function Reference The graphics routines of OPEN GEOMETRY are based on OPENGL. In order to use OPEN GEOMETRY you need do not need to know anything about OPENGL, but still it may be interesting to get a more profound insight in the background of the OPEN GEOMETRY class library. If you want to use OPEN GEOMETRY for a certain specific task, you might feel the need to adapt some of its drawing and shading routines. In this case you will need to know a few basics about OPENGL. Therefore, we give a very short description of the most important OPENG L functions. Of course, this list is far from complete. If you need more information, please refer to "pure" OPENGL books (e.g., [1], [17], or [36]). We have sorted the routines according to the following groups: 1. Coordinate Transformations glFrustum, glLoadldentity, glLoadMatrix, glMatrixMode, glMultMatrix, glPopMatrix, glPusbMatrix, glRotate, glScale, glTranslate 2. Primitives (Lines, Polygons, Points, ... ) glBegin, glCullFace, glEdgeFIag, glEnd, glFrontFace, glGetPolygonStripple, glLineStrippIe, glLine Widtb, glPointSize, glPolygonMode, glPolygonStrip pIe, glVertex 3. Color glClearColor, glClearlndex, glColor, glColorv, glColorMask, glIndex, glIn dexMask, glLogicOp, glSbadeModel 622 Appendix A. OpenGL Function Reference 4. Lighting glColorMaterial, glGetMaterial, glGetLight, glLight, glLightModel, glMate rial, glNorma13 5. Texture Mapping glTexCoord, glTexEnv, glTexGen, glTexlmage2D, glTexImagelD, glTexPa rameter, glEnable 6. Raster Graphics glCopyPixels, glDrawPixels, glPixelMap, glPixelStore, glPixelTransfer, glPix elZoom, glReadPixels, glRasterPos A.I Coordinate Transformations Whenever you write OPENGL code, it is important to have an understanding of how coordinate transformations in OPENGL work. In particular, you have to think about the order of the transformations if you apply several in a row. Always keep in mind that OPENG L transformations will not change the coordinates of your objects, whereas many OPEN GEOMETRy-transformations will actually change them. void glFrustum( GLdouble left, GLdouble right, GLdouble bottom, GLdouble top, GLdouble near, GLdouble far); <> Multiplies the current matrix by a matrix <> for a perspective-view frustum. left, right define left and right clipping planes bottom, top define bottom and top clipping planes near, far distance to the near and far clipping planes I I void glLoadldentity( void ); <> Sets the current matrix to Identity. void glLoadMatrix<d,f> ( const TYPE* m ); <> Sets the current matrix to the one specified. m 4x4 matrix I I void glMatrixMode( GLenum mode ); Section A.I. Coordinate Transformations 623 o Specifies the current matrix mode. mode can be GLMODELVIEW, GL_PROJECION, GLTEXTURE I void glMultMatrix<d,f> ( TYPE *m ); o Multiplies the current matrix by the one specified. m 4x4 matrix I I void glPopMatrix( void ); o Pops the current matrix off the matrix stack. I void glPushMatrix( void ); o Pushes the current matrix onto the matrix stack. I void glRotate<d,f> ( TYPE angle, TYPE x, TYPE y, TYPE z ); o Rotates the current matrix by a rotation matrix. angle specifies the angle of rotation in degrees x,y,z vector from the origin that is used as the axis of rotation. I void glScale<d,f> ( TYPE x, TYPE y, TYPE z ); o Multiplies the current matrix by a matrix that o scales an object along the x,y,z axes. x,y,z Scale factors along the x,y, and z axes I I void glTranslate<d,f> ( TYPE x, TYPE y, TYPE z ); o Multiplies the current matrix by a matrix that o translates an object along the axes. x,y,z translation vector I A.2 Primitives OPENGL offers only a few geometrical primitives to be drawn: lines, polygons, and points. The auxiliary libraries provide the programmer with some other "primitives" like spheres and teapots. 624 Appendix A. OpenGL Function Reference void glBegin( GLenum mode ); o Sets the beginning of a group of vertices o that build one or more primitives. mode type of primitive operation GLPOINTS individual points GL_LINES simple lines GL_LINKSTRlP series of connected lines GL_LINKLOOP same as above with first and last vertices connected GLTRlANGLES simple triangle GL_TRlANGLESYAN linked fan of triangles GL_TRlANGLES_STRIP linked strip of triangles GLPOLYGON convex polygon GLQUADS four-sided polygon GLQUAD_STRlP linked strip of four-sided polygons I void glCullFace( GLenum mode ); mode GLYRONT, GL_BACK, GLYRONLAND_BACK; I void glEdgeFlag<v> ( GLboolean<const GLboolean *>flag ); o Indicates whether a vertex should be considered o as initializing a boundary edge of a polygon. flag Sets the edge flag to this value. GL_TRUE (default) or GLFALSE I void glEnd ( ); o Terminates a group of vertices specified by glBegin ( ). I void glFrontFace( GLenum mode ); o Defines the front and back sides of a polygon. mode GL_CCW faces with counterclockwise orientation are considered front-facing. (default) GL_CW faces with clockwise orientation are considered front-facing. I void glGetPolygonStipple( GLubyte *mask ); o Returns the stipple pattern of a polygon. Section A.2. Primitives 625 Pointer to the polygon stipple pattern. I void glLineStipple( GLint factor, GLushort pattern ); o Specifies the stipple pattern for GLLINE... o primitive operations. First enable strip piing o by calling glEnable( GLLINKSTIPPLE ). factor The pattern is stretched out by this factor. pattern Sets the 16-bit long strippling pattern. I~-----------------------------------------------------------~ I void glLine Width ( GLBoat width ); o Sets the current line width. width width of line in pixels (default is 1.0) I void glPointSize( GLBoat size) ; o Sets the current point size. size size of point (default is 1.0) I I void glPolygonMode( GLenum face, GLenum mode) ; o Sets the drawing mode for the front faces and back faces of a polygon. face Specifies which faces are affected by the mode change. GLFRONT, GL_BACK, GL_FRONT_AND_BACK mode can be GL_POINT, GL_LINE, GL_FILL I void glPolygonStipple( const GLubyte* mask ) o Specifies the stipple pattern used to fill polygons. *mask pointer to a 32 * 32-bit array that contains the stipple pattern. I void gIVertex<2,3,4><s,i,f,d><v> ( TYPE coords ) o Specifies the 3D coordinates of a vertex. o Example: glVertex3f( 1.0 , 1.5 , 4.0 ); coords can be 1-4 dimensional (x,y,z,w) w coordinate for scaling purposes 626 Appendix A. OpenGL Function Reference (default is 1.0) I void glClearColor( GLc1ampf red, GLc1ampf green, GLc1ampf blue, GLc1ampf alpha ) o Specifies the current clear color for glClear. I void glClearlndex( GLfloat index) ; o Specifies the clearing value for the color index buffer. index clear color value I void glColor<3,4><b,i,s,u,d,f> ( TYPE red, TYPE green, TYPE blue, TYPE alpha ); o Sets the current drawing color. I void glColor<3,4><b,i,s,u,d,f>v( const TYPE *v); o Sets the current drawing color. v points to an array with four elements I void glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha ); o Defines the current mask used to control o writing in RGBA mode. I void glIndex<i,s,d,f><v> ( TYPE index); o Sets the current drawing index color. index color index; I I void glIndexMask( GLuint mask ); o Sets the mask used to control writing into the color o index buffer by protecting individual bits from being set. mask bit mask; I void glLogicOp( GLenum opcode ); Section A.2. Primitives 627 (> Defines the current logical pixel operation for color o index mode. opcode can be GLCLEAR, GLCOPY (default), GLNOOP, GL_SET, GL_COPY_INVERTED, GLINVERT, GL_AND, GLOR, GLNOR, GL_XOR, GL_EQUIV, GLAND_INVERTED, GLOKINVERTED; I void glShadeModel( GLenum mode); o Specifies the current shade model mode GLFLAT or GLSMOOTH (default) ; A.3 Color OPENGL allows you to set RGB colors. Furthermore, it enables the programmer to set a-values for transparency. void glClearColor( GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha) (> Specifies the current clear color for glClear. I void glClearIndex( GLf-loat index) ; o Specifies the clearing value for the color index buffer. index clear color value I I void glColor<3,4><b,i,s,u,d,f> ( TYPE red, TYPE green, TYPE blue, TYPE alpha ); (> Sets the current drawing color. I void glColor<3,4><b,i,s,u,d,f>v( const TYPE *v); o Sets the current drawing color. v points to an array with four elements I void glColorMask( GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) ; 628 Appendix A. OpenGL Function Reference <> Defines the current mask used to control <> writing in RGBA mode. I void glIndex<i,s,d,f><v> ( TYPE index); <> Sets the current drawing index color. index color index I void glIndexMask( GLuint mask ); <> Sets the mask used to control writing into the color <> index buffer by protecting individual bits from being set. mask bit mask I void glLogicOp( GLenum opcode ); <> Defines the current logical pixel operation for color <> index mode. opcode can be GLCLEAR, GLCOPY (default), GLNOOP, GL_SET, GL_COPYJNVERTED, GLJNVERT, GL-AND, GL_OR, GLNOR, GL_XOR, GL-EQUIV, GL_ANDJNVERTED, GLOKINVERTED; I void glShadeModel ( GLenum mode ); <> Specifies the current shade model mode GLYLAT or GL_SMOOTH (default) ; A.4 Lighting When it comes to lighting, OPENG L offers a palette of functions that allow you to use a number of light sources and to provide the objects with physical properties like shininess, etc. Remember that OPEN GEOMETRY does not use those functions by default, and that it is up to the programmer to introduce the corresponding code. Section A.4. Lighting 629 void glColorMaterial( GLenum face, GLenum mode); <> Allows material colors to track the color set by glColor. face GLFRONT, GLJ3ACK or GLFRONT-AND_BACK mode GLEMISSION, GL_AMBIENT, GL_DIFFUSE, GL_SPECULAR or GL_AMBIENT-AND_DIFFUSE I void glGetMaterial<i,f>v( GLenum face, GLenum pname, TYPE param ) <> Returns the current material property settings. face GLFRONT, GLJ3ACK or GLYRONT_AND_BACK pname: param: GL_EMISSION RGBA values GL_AMBIENT RGBA values GL-.DIFFUSE RGBA values GLSPECULAR RGBA values GL_SHININESS specular exponent GL_COLORJNDEXES 3 values ( ambient, diffuse, specular components ) I void glGetLight<i,f>v( GLenum light, GLenum pname, TYPE *params ); <> Returns information about the current light source settings.