To develop an OpenGL based application, you must first understand the library functions of OpenGL. It uses C language style, provides a large number of functions for graphics processing and display. OpenGL library functions are named in a very regular way. All OpenGL functions take the following format: < library prefix >< root command >< optional parameters >< optional parameter type the > library prefix has gl, glu, aux, Glut, WGL, GLX, AGL, etc. It means that the function belongs to the development library of OpenGL, and it can be seen from the function name to see how many parameters are required and the type of the parameter. I stands for int, F for float, d for Double, and U for unsigned integer. 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.
OpenGL function Library related APIs are core library (GL), utility Library (GLU), auxiliary library (AUX), utility library (GLUT), window library (GLX, AGL, WGL) and extended function library. As can be seen from the diagram, GL is the core, and Glu is a partial encapsulation of GL. GLX, AGL, WGL are functions for different window systems. GLUT is a toolkit for cross-platform OpenGL programs that are more powerful than aux. The Extended function library is a function developed by hardware vendors to realize hardware update using OpenGL extension mechanism. These libraries are described in detail below.1. OpenGL Core Library The core library contains 115 functions, and the function name is prefixed by GL. This part of the function is used for conventional, core graphics processing. This function is gl.dll to interpret execution. Because many functions can receive different numbers of the following classes. According to the type of the parameter, so the derivation of the function prototype as many as 300. Functions in the core library can be divided into the following types of functions: the function of drawing basic geometric entities: Glbegain (), Glend (), glnormal* (), glvertex* (), Matrix operations, function of geometric transformation and projection transformation: such as matrix into Stack function Glpushmatrix (), matrix out Stack function Glpopmatrix (), Loading matrix function Glloadmatrix (), matrix multiplication function Glmultmatrix (), The current matrix function Glmatrixmode () and matrix normalization function glloadidentity (), Geometric transformation function gltranslate* (), glrotate* () and glscale* (), Projection transformation function Glortho (), Glfrustum () and viewport transformation function glviewport (), color, lighting and material functions: such as setting the color mode function glcolor* (), glindex* (), setting the function of lighting effect gllight* (), gllightmodel* () and set the material effect function glmaterial (); Display list functions: Main have functions to create, end, build, delete, and invoke display lists Glnewlist (), Glendlist (), glgenlists (), Glcalllist () and gldeletelists (); Texture mapping functions: There are mainly one-dimensional texture function glteximage1d (), two-dimensional texture function glteximage2d (), the function of setting texture parameters, texture environment and texture coordinates gltexparameter* (), Gltexenv* () and gltetcoord* (); Special effect function: Fusion function Glblendfunc (), anti-aliasing function Glhint () and atomization effect glfog* (), raster, pixel operation function: Elephant element position glrasterpos* (), Line width gllinewidth (), polygon drawing Mode Glpolygonmode (), reading Pixel glreadpixel (), copy Pixel Glcopypixel (), Selection and feedback function: mainly have rendering mode Glrendermode (), Select Buffer Glselectbuffer () and feedback buffer glfeedbackbuffer ();
Drawing functions for curves and surfaces: functions that generate curves or surfaces glmap* (), glmapgrid* (), Functions of the glevalcoord* () glevalmesh* (), State settings and query functions: glget* (), glenable (), Glgeterror ().2. OpenGL Utility Library The OpenGL Utility Library (GLU)Contains 43 functions with a function name prefixed by Glu. OpenGL provides a powerful but small number of drawing commands, and all the more complex drawings must start with dots, lines, and faces. Glu in order to reduce the heavy programming work, encapsulates the OpenGL function, the Glu function through calls the core library function, provides the developer the relatively simple usage, realizes some more complex operations. This function is glu.dll to interpret execution. The core and utility libraries in OpenGL can be run on all OpenGL platforms. Mainly include the following: auxiliary texture mapping functions: Gluscaleimage (), Glubuild1dmipmaps (), glubuild2dmipmaps (), coordinate transformation and projection transformation functions: the definition of projection mode function gluperspective ( ), gluortho2d (), Glulookat (), Glupickmatrix (), Projection matrix calculation gluproject () and Gluunproject (), Polygon inlay tool: glunewtess (), Gludeletetess (), Glutesscallback (), Glubeginpolygon (), Glutessvertex (), Glunextcontour (), Gluendpolygon (), two-time surface rendering tools, Mainly draw spherical surface, cone, cylinder, torus glunewquadric (), Glusphere (), Glucylinder (), Gludisk (), Glupartialdisk (), Gludeletequadric (); Non-uniform rational B-spline drawing tool: Mainly used to define and draw nurbs curves and surfaces, including glunewnurbsrenderer (), Glunurbscurve (), Glubeginsurface (), Gluendsurface (), Glubegincurve (), Glunurbsproperty (); Error Feedback tool: Gets the string gluerrorstring () of the error message.3. OpenGL Auxiliary LibraryContains 31 functions with a function name prefix of aux. This part of the function provides window management, input and output processing, and the drawing of some simple three-dimensional objects. This function is glaux.dll to interpret execution. The Aux library is created to learn and write OpenGL programs, and it is more like a preliminary base takeover for testing ideas. The Aux library has many errors in Windows implementations, so it can easily lead to frequent crashes. In Cross-platform programming instances and demos, aux has largely been replaced by the glut library. The secondary library in OpenGL cannot be run on all OpenGL platforms. Auxiliary library functions mainly include the following categories: window initialization and exit functions: Auxinitdisplaymode () and auxinitposition (); window processing and time input functions: Auxreshapefunc (), Auxkeyfunc () and Auxmousefunc (); Color index loading function: Auxsetonecolor (); three-dimensional object drawing function: Includes two forms of mesh body and solid body, such as drawing Cube Auxwirecube () and Auxsolidcube (). Here, for example, the lattice body, rectangular auxwirebox (), circular auxwiretorus (), cylindrical auxwirecylinder (), 20-face body Auxwireicosahedron (), eight-face body Auxwireoctahedron (), tetrahedron Auxwiretetrahedron (), 12 surface auxwiredodecahedron (), Cone auxwirecone () and Teapot auxwireteapot (); Background process management function: Auxidlefunc () ; program run function: Auxmainloop ().4. OpenGL Tool Library OpenGL Utility ToolkitContains approximately 30 functions with a function name prefix of GLUT. Glut is an OpenGL toolkit that is not dependent on the window platform, written by Mark Klilgrad in SGI (now in Nvidia) to hide the complexity of different window platform APIs. Functions begin with glut, which serve as a more powerful alternative to the AUX library, providing a more complex rendering function, which is explained by Glut.dll. Because the window management functions in glut are not dependent on the running environment, the tool libraries in OpenGL can be run under X-window, Windows NT, OS/2, and so on, especially for the development of OpenGL sample programs that do not require a complex interface. For experienced programmers, it is common to use glut to straighten out 3D graphics code and then set it up as a complete application. This part of the function mainly includes: Window operation function: Window initialization, window size, window position function, etc. [Glutinit (), Glutinitdisplaymode (), Glutinitwindowsize (), Glutinitwindowposition ()]; callback function: Response refresh message, keyboard message, mouse message, timer function [Glutdisplayfunc (), Glutpostredisplay (), Glutreshapefunc (), Gluttimerfunc (), Glutkeyboardfunc (), Glutmousefunc ()]; Create complex three-dimensional objects: These functions are the same as those of the Aux Library; menu functions: Create a function that adds a menu Glutcreatemenu (), Glutsetmenu (), Glutaddmenuentry (), Glutaddsubmenu () and Glutattachmenu (); program run function: Glutmainloop ().5. Windows Private LibraryFor Windows platform extensions, there are 16 functions that have a function name prefix of WGL. This part of the function is primarily used to connect OpenGL and Windows to make up for OpenGL's lack of text. Windows private libraries can only be used in Windows environments. This type of function mainly includes the following categories: drawing context-related functions: Wglcreatecontext (), Wgldeletecontext (), Wglgetcurrentcontent (), WGLGETCURRENTDC (), Wgldeletecontent (); text and text processing functions: Wglusefontbitmaps (), Wglusefontoutlines (), overlay, stratum and main plane layer processing functions: Wglcopycontext (), Wglcreatelayerplane (), Wgldescribelayerplane (), Wglreakizelayerplatte (), other functions: Wglsharelists (), wglgetprocaddress ().6. Win32 API function LibraryContains 6 functions, the function name has no private prefix, is the Win32 extension function. This part of the function is mainly used for processing pixel storage format and double frame caching; These 6 functions will replace the same functions in Windows GDI. The WIN32API function library can only be used in Windows 95/98/NT environments.7. X Window Dedicated Libraryis an extension function for UNIX and Linux. Includes render context, draft entity, display list, texture map, and so on; Initialize: Glxqueryextension (); Render context function: Glxcreatecontext (), Glxdestroycontext (), Glxcopycontext ( ), Glxmakecurrent (), Glxcreateglxpixmap (), Execution: GLXWAITGL (), GLXWAITX (); Buffers and fonts: glxswapbuffers (), Glxusexfont ().8. Other extension Libraries These functions may be new OpenGL functions that are not implemented in the standard OpenGL library or are used to extend the functionality of existing OpenGL functions. Like Glu, GLX, and WGL, these OpenGL extensions are developed by hardware vendors and vendors. The OpenGL extension (OpenGL extention) contains a large number of extended API functions. With the hardware update, the hardware vendors first to the SGI application for registration of new extensions, the preparation of specifications (specification). Then follow the instructions to develop the extension program. Different OpenGL implementations (OpenGL implementation) support extensions that may not be the same, only with the extension and application of an extension and the improvement of hardware technology that will be supported in all OpenGL implementations, and eventually become part of the OpenGL standard library. The extensions are maintained by SGI and are listed on the SGI Web site for the currently open registered extensions and their official manuals. The extension source is indicated by the suffix of the extension function (or by using the extended constant suffix). For example, the suffix win indicates an extension that conforms to the Windows specification, and the ext or ARB suffix indicates that the extension is defined by multiple vendors. below gives an OpenGL official naming convention: ARB&NBSP;–OPENGL Architecture Review Board officially approved extensions, often developed by the manufacturer, and if there is an extended and ARB extension of vendor development, Priority should be given to the use of ARB extensions; ext– Many OpenGL vendors agreed to support the expansion; Hp –hewlett-packard hp; ibm –international Business machines; ktx –kinetix, maker of 3D Studio Max; Intel –intel company; Nv –nvidia Company; Mesa–brian Paul ' s freeware portable Open The expansion of GL implementation Sgi –silicon Graphics Company, the experimental extension of Sgix–silicon Graphics (experimental) company development; Sun–sun Micro systems; Win –microsoft. As OpenGL expands on different platforms and different drives, OpenGL is unlikely to put theSome interface programs are all placed in Gl.h, Glx.h, wgl.h, but they are placed in glext.h, Glxext.h, and Wglext.h. These extensions are seen as the addition and modification of the OpenGL Core Library specification.
Reprint Address: http://blog.csdn.net/pizi0475/article/details/5442258