Composition of OpenGL Development Library

Source: Internet
Author: User
To develop OpenGL-based applications, you must first understand the library functions of OpenGL. It adopts the C language style and provides a large number of functions for graphic processing and display. The names of OpenGL library functions are quite regular. All OpenGL functions use the following format: <database prefix> <root command> <number of optional parameters> <optional parameter types> database prefix GL, Glu, aux, glut, WGL, glx, AGL, etc, it indicates that the function belongs to the Development Library of OpenGL. You can see the number of parameters and the type of parameters after the function name. I indicates the int type, F indicates the float type, D indicates the double type, and u indicates the unsigned integer type. For example, glvertex3fv () indicates that the function belongs to the GL Library and the parameter is three float parameter pointers. We use glvertex * () to represent this type of function.

The APIS related to OpenGL function libraries include core libraries (gl), practical libraries (glu), auxiliary libraries (aux), utility libraries (glut), and window libraries (glx, agl, and wgl) and extended function libraries. As shown in figure 1, gl is the core and glu is the partial encapsulation of gl. Glx, agl, and wgl are functions for different window systems. Glut is a tool kit for cross-platform OpenGL programs and is more powerful than aux. Extended Function libraries are functions developed by hardware vendors Using OpenGL to update hardware. The following describes these databases in detail. 1. The core library of OpenGL contains 115 functions and the function name prefix is gl. These functions are used for conventional and core graph processing. This function is interpreted and executed by gl. dll. Because many functions can receive different numbers of the following classes. Data Type parameters, so the derived function has more than 300 original types. Functions in the core library can be divided into the following types. The function that draws the basic geometric elements. For example, the function glBegain (), glEnd (), glNormal * (), and glVertex * () for drawing elements *(). Matrix operation, geometric transformation, and Projection Transformation functions. Such as glPushMatrix (), glPopMatrix (), glLoadMatrix (), glMultMatrix (), and glMatrixMode () and matrix standardization functions glLoadIdentity (), geometric transformation functions glTranslate * (), glRotate * () and glScale * (), projection transformation functions glOrtho (), glFrustum () and glViewport. Color, illumination, and material functions. For example, set the color mode function glColor * (), glIndex * (), glLight * (), glLightModel * (), and glMaterial. Display list functions, including glNewList (), gldlist (), glGenLists (), glCallList (), and glDeleteLists (). Texture ing functions include glTexImage1D (), glTexImage2D (), glTexImage2D (), glTexParameter * (), and glTexEnv *() and glTetCoord. Special Effect functions. GlBlendFunc (), glHint (), and glFog *(). Raster and pixel operation functions. Such as glRasterPos * (), glLineWidth (), glPolygonMode (), glReadPixel (), and glCopyPixel. Select and feedback functions. It mainly includes the rendering mode glRenderMode (), the selection buffer glSelectBuffer (), and the feedback buffer glFeedbackBuffer. Curves and surfaces. The glMap * () and glMapGrid * () functions that generate curves or surfaces, and the glEvalCoord * () glEvalMesh * () function of the calculator *(). Status settings and query functions. Mainly include glGet * (), glable (), and glGetError. 2. The OpenGL Utility Library (GLU) contains 43 functions with The prefix of The function name. OpenGL provides powerful but few drawing commands, and all the more complex drawings must be drawn from points. Line and plane start. In order to reduce the heavy programming workload, Glu encapsulates OpenGL functions. by calling the functions of the core library, it provides relatively simple usage for developers and implements some complex operations. This function is interpreted and executed by glu. dll. The core library and utility library in OpenGL can be run on all OpenGL platforms. It mainly includes the following types. Auxiliary texture map functions, including gluScaleImage (), gluBuild1Dmipmaps (), and gluBuild2Dmipmaps (). Coordinate Transformation and Projection Transformation functions, define projection method functions gluPerspective (), gluOrtho2D (), gluLookAt (), pick up the projection visual body function gluPickMatrix (), and calculate the projection matrix gluProject () and gluUnProject. Polygon embedding tools include gluNewTess (), gluDeleteTess (), gluTessCallback (), gluBeginPolygon () gluTessVertex (), gluNextContour (), and gluEndPolygon. Quadratic Surface rendering tools, mainly including spherical surface, cone surface, cylindrical surface, ring surface gluNewQuadric (), gluSphere (), gluCylinder (), gluDisk (), gluPartialDisk (), gluDeleteQuadric () and so on. A non-uniform rational B-spline drawing tool is mainly used to define and plot the curve and surface of a rectangle, including gluNewNurbsRenderer (), gluNurbsCurve (), gluBeginSurface (), gluEndSurface (), and gluBeginCurve () and gluNurbsProperty. Error feedback tool. The string gluErrorString () for obtaining error information. 3. The OpenGL auxiliary library contains 31 functions with the function name prefix aux. These functions provide window management, input and output processing, and some simple 3D objects. This function is interpreted and executed by glaux. dll. The aux library is created to learn and write OpenGL programs. It is more like a preliminary pipeline for testing creativity. The Aux library has many errors in windows implementation, so it is easy to cause frequent crashes. In cross-platform programming examples and demonstrations, aux has been largely replaced by the glut library. The auxiliary libraries in OpenGL cannot run on all OpenGL platforms. Auxiliary library functions mainly include the following types. Window initialization and exit functions, auxInitDisplayMode () and auxInitPosition (). Window processing and time input functions, auxReshapeFunc (), auxKeyFunc (), and auxMouseFunc (). Color index Loading Function, auxSetOneColor (). 3D object rendering function. There are two forms of mesh and solid body, such as drawing a cube auxWireCube () and auxSolidCube (). Here we take the mesh as an example. The cuboid auxWireBox (), the ring surface auxWireTorus (), the cylindrical auxWireCylinder (), the twenty surface auxWireIcosahedron (), auxWireDodecahedron (), cone auxWireCone () and teapot auxWireTeapot (). Background process management function auxIdleFunc (). The program runs the auxMainLoop () function (). 4. OpenGL Utility Toolkit contains more than 30 functions with the prefix of glut. Glut is an OpenGL toolkit independent of the window platform. It is written by Mark KLilgrad in SGI (currently in Nvidia) to hide the complexity of APIs on different Windows platforms. Functions start with glut. They serve as a more powerful alternative to the aux library and provide more complex plotting functions. This function is interpreted and executed by glut. dll. Since Window management functions in glut do not depend on the runtime environment, the tool libraries in OpenGL can run in X-Window, Windows NT, OS/2, and other systems, it is particularly suitable for developing OpenGL sample programs that do not require complex interfaces. For experienced programmers, glut is usually used to straighten out 3D graphics code and then integrate it into a complete application. These functions mainly include window operation functions, window initialization, window size, window location, and other functions such as gluinit () gluinitdisplaymode () gluinitwindowsize () gluinitwindowposition. Callback function. Response to refresh messages, keyboard messages, mouse messages, timer functions, etc (). Create complex 3D objects. These functions are the same as those of the aux database. Create a mesh and a solid body. For example. We will not describe it here. Menu function. Create the functions for adding a menu, such as glucreatemenu (), glusetmenu (), gluaddmenuentry (), gluaddsubmenu (), and gluattachmenu (). Program running function, FIG (). 5. Windows dedicated library for windows platform extension. Contains 16 functions with the prefix wgl. These functions are mainly used to connect OpenGL and Windows to make up for OpenGL's text deficiency. Windows libraries can only be used in Windows environments. These functions mainly include the following types: Graph context-related functions WglCreateContext () , WglDeleteContext () wglGetCurrentContent () wglGetCurrentDC () wglDeleteContent () And so on Text and text processing functions WglUseFontBitmaps () , WglUseFontOutlines () . Covering Layer, formation layer, and Main Plane layer processing function WglCopyContext () , WglCreateLayerPlane () , WglDescribeLayerPlane () , WglReakizeLayerPlatte () And so on Other functions, WglShareLists () , WglGetProcAddress () . 6. The Win32 API function library contains six functions without a special prefix. Is a Win32 Extension function. These functions are mainly used to process the pixel storage format and dual-frame cache. These six functions will replace the original functions of Windows GDI. The WIN32API function library can only be used in Windows 95/98/NT. The 7 X Window dedicated library is an extension function for UNIX and Linux. Including rendering context, drawing elements, display list, texture maps, etc. Initialize glXQueryExtension () Rendering Context Function, glXCreateContext () glXDestroyContext () glXCopyContext () glXMakeCurrent () glXCreateGLXPixmap () Run glXWaitGL () and glXWaitX () Buffer and font glXSwapBuffers (), glXUseXFont ()8. Other extended libraries these functions may be new OpenGL functions that are not implemented in the standard OpenGL library, or they are used to extend existing OpenGL functions. Like glu, glx, and wgl, these OpenGL extensions are developed by hardware vendors and vendors. OpenGL Extention contains a large number of extended API functions. As the hardware is updated, the hardware vendor first applies to SGI to register new extensions and write the specification (specification ). Then follow the instructions to develop the extension program. Different OpenGL Implementation may support different extensions, only with the promotion of a certain extension and the improvement of application and hardware technology will the extension be supported in all OpenGL implementations and eventually become part of the OpenGL standard library. Extensions are maintained by SGI and are listed on the SGI website as publicly available extensions and their official manuals. The extension source is indicated by the extension function suffix (or the extension constant suffix is used ). For example, the suffix WIN indicates an extension that complies with Windows specifications, and the EXT or ARB suffix indicates that the extension is defined by multiple vendors. Which of the following are the official provisions of OpenGL?Naming rules: ARB-The extension officially approved by OpenGL Architecture Review Board is often developed by the vendor. If the extension developed by the vendor and the ARB extension exist at the same time, the ARB extension should be used first. EXT-Multiple OpenGL vendors agree to support extensions HP-Hewlett-Packard HP IBM-International Business Machines KTX-Kinetix, maker of 3D Studio Max INTEL-Intel NV-NVIDIA MESA-Brian Paul's freeware portable OpenGL implementation SGI-Extensions developed by Silicon Graphics SGIX-Experimental extensions developed by Silicon Graphics (experimental) SUN-Sun Microsystems WIN-Since Microsoft extends OpenGL to different platforms and drivers, OpenGL cannot put all interface programs in gl. h, glx. h. wgl. h, but put these function headers in glext. h. glxext. h and wglext. h. These extensions are seen as the addition and modification of OpenGL core library specifications. OpenGL extensions do not have any disadvantages. Because each hardware vendor can develop its own extensions, the number of extensions is large and a bit confusing. Some extensions implement the same functions, however, because the interfaces are developed by different vendors, different programs are often required for different graphics cards to implement this function. This problem may be solved after OpenGL 2.0 is released. One goal of OpenGL 2.0 is to unify the extension and reduce the number of extensions.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.