Document directory
- Composition of OpenGL Development Library
To develop OpenGL-based applications, you must first understand the OpenGL library functions. 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.
Figure 1
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 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.