Introduction to OpenGL Basic Library

Source: Internet
Author: User
Tags types of functions

To develop OpenGL-based applications, you must first understand the library functions of OpenGL. It uses the C language style and provides a number of functions for graphics processing and display. OpenGL library functions are named in a very regular manner. All OpenGL functions take the following format:

< library prefix >< root command >< optional number of parameters >< optional parameter types >

The library prefix, which has GL, Glu, aux, Glut, WGL, GLX, AGL, and so on, indicates that the function belongs to the OpenGL Development Library.
You can also see how many parameters are required and the type of the parameters from behind the function name. 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 a three float parameter pointer. We use glvertex* () to represent this type of function.

OpenGL Library-related APIs include core libraries (GL), utility libraries (GLU), auxiliary libraries (aux), utility libraries (glut), window libraries (GLX, AGL, WGL), and extension function libraries. As can be seen, GL is the core, Glu is a partial encapsulation of GL. GLX, AGL, and WGL are functions for different windowing systems. GLUT is a toolkit for cross-platform OpenGL programs that is more powerful than the Aux feature. The extension function library is a function developed by hardware vendors to implement the extended mechanism of OpenGL for hardware updates. These libraries are described in detail below.


1. OpenGL Core Library

The core library contains 115 functions with a prefix of GL for the function name. This part of the function is used for regular, core graphics processing. This function is interpreted by gl.dll to interpret execution. Because many functions can receive different numbers of the following classes. Based on the type of parameters, so the derived function is more than 300 prototypes. Functions in the core library can be divided into the following types of functions:

◇ the functions of drawing basic geometry elements: Glbegain (), Glend (), glnormal* (), glvertex* ();
◇ matrix operation, geometric transformation and projection transformation functions: such as matrix into the Stack function Glpushmatrix (), Matrix stack function Glpopmatrix (), Load matrix function Glloadmatrix (), matrix multiplication function Glmultmatrix (), The current matrix functions Glmatrixmode () and matrix normalization functions glloadidentity (), Geometric transformation functions gltranslate* (), glrotate* () and glscale* (), Projection transformation Functions Glortho (), Glfrustum () and viewport transform function glviewport ();
◇ functions of color, illumination and material: such as setting the color mode function glcolor* (), glindex* (), setting the Illumination effect function gllight* (), gllightmodel* () and setting the material effect function glmaterial ();
◇ Display list functions: There are functions glnewlist (), Glendlist (), glgenlists (), Glcalllist (), and gldeletelists () that create, end, generate, delete, and invoke display lists;
◇ Texture mapping Function: There are one-dimensional texture function glteximage1d (), two-dimensional texture function glteximage2d (), set texture parameters, texture environment and texture coordinates function gltexparameter* (), gltexenv* () and gltetcoord* ();
◇ Special effect function: Fusion function Glblendfunc (), anti-aliasing function glhint () and atomization effect glfog* ();
◇ rasterization, pixel operation function: Elephant position glrasterpos* (), line width gllinewidth (), polygon drawing Mode Glpolygonmode (), read Pixel glreadpixel (), copy pixel Glcopypixel ();
◇ Selection and feedback function: mainly have the rendering mode Glrendermode (), select Buffer Glselectbuffer () and feedback buffer glfeedbackbuffer ();
◇ curve and surface drawing function: function of generating curve or surface glmap* (), glmapgrid* (), Function of glevalcoord* () glevalmesh* ();
◇ status Setting and query function: glget* (), glenable (), Glgeterror ().

2. OpenGL Utility Library The OpenGL Utility Library (GLU)

Contains 43 functions with a prefix of Glu for the function name. OpenGL provides powerful but few drawing commands, and all more complex drawings must start with points, lines, and polygons. Glu in order to alleviate the heavy programming work, encapsulates the OpenGL function, the Glu function by invoking the core library function, provides the relatively simple usage for the developer, realizes some more complex operation. This function is interpreted by glu.dll to interpret execution. The core libraries and utility libraries in OpenGL can be run on all OpenGL platforms. The main include the following several:

◇ auxiliary Texture mapping functions: Gluscaleimage (), Glubuild1dmipmaps (), Glubuild2dmipmaps ();  
◇ Coordinate transformation and projection transformation functions: Define the projection mode function gluperspective (), gluortho2d (), Glulookat (), Pick and drop view body function Glupickmatrix (), Projection matrix calculation gluproject () and Gluunproject ();
◇ Polygon mosaic tool: Glunewtess (), gludeletetess (), Glutesscallback (), Glubeginpolygon (), Glutessvertex (), Glunextcontour (), Gluendpolygon ();
◇ two times surface drawing tools, mainly drawing spherical, conical, cylindrical, 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 Library

Contains 31 functions, and the function name prefix is aux. This part of the function provides window management, input and output processing, and drawing some simple three-dimensional objects. This function is interpreted by glaux.dll to interpret execution. The Aux library is created to learn and write OpenGL programs, which are more like a preliminary base takeover for testing ideas. The AUX library has many errors in Windows implementations , so it is easy to cause frequent crashes. In cross-platform programming examples and demos, theaux has largely been replaced by the GLUT library . the secondary libraries 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 and solid body, such as drawing Cubes auxwirecube () and Auxsolidcube (). Here, for example, the box Auxwirebox (), the annular surface auxwiretorus (), the cylindrical auxwirecylinder (), the 20-face Auxwireicosahedron (), the eight-body Auxwireoctahedron (), tetrahedron Auxwiretetrahedron (), 12-Face body Auxwiredodecahedron (), Cone auxwirecone () and Teapot Auxwireteapot ();
◇ Background Process management function: Auxidlefunc ();
◇ program running function: Auxmainloop ().

4. OpenGL Tool Library OpenGL Utility Toolkit

Contains approximately 30 functions, and the function name prefix is glut. Glut is an OpenGL toolkit that is not dependent on the Windows platform , written by Mark Klilgrad in SGI (now in Nvidia) to hide the complexity of the 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 interpreted by glut.dll to interpret execution. Because window management functions in glut are not dependent on the operating environment, the tools library in OpenGL can be run under X-window, Windows NT, OS/2 and other systems, especially for developing OpenGL sample programs that do not require complex interfaces. 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 Function: Create a function to add menu Glutcreatemenu (), Glutsetmenu (), Glutaddmenuentry (), Glutaddsubmenu (), and Glutattachmenu ();
◇ program running function: Glutmainloop ().

5. Windows Dedicated Library

For Windows platform extensions, there are 16 functions with a function name prefix of WGL.   This part of the function is mainly used to connect OpenGL and windows to compensate for OpenGL's lack of text. Windows dedicated libraries can only be used in Windows environments.

Such functions mainly include the following categories:

◇ Drawing Context related functions: Wglcreatecontext (), Wgldeletecontext (), Wglgetcurrentcontent (), WGLGETCURRENTDC (), wgldeletecontent ();
◇ text and Text processing functions: Wglusefontbitmaps (), Wglusefontoutlines ();
◇ covering layer, stratum and main plane layer processing function: Wglcopycontext (), Wglcreatelayerplane (), Wgldescribelayerplane (), Wglreakizelayerplatte ();
◇ Other functions: Wglsharelists (), wglgetprocaddress ().

6. Win32 API function Library

Contains 6 functions, the function name does not have a dedicated prefix, is the Win32 extension function. This part of the function is mainly used to deal with the pixel storage format and the two-frame cache; These 6 functions replace the same functions that Windows GDI has. The Win32API library can only be used in Windows 95/98/NT environments.

7. X Window Special Library

is an extension function for UNIX and Linux. Include render context, draft entity, display list, texture map, etc.;

◇ initialization: glxqueryextension ();
◇ Render Context functions: Glxcreatecontext (), Glxdestroycontext (), Glxcopycontext (), Glxmakecurrent (), Glxcreateglxpixmap ();
◇ execution: GLXWAITGL (), GLXWAITX ();
◇ Buffer and font: glxswapbuffers (), Glxusexfont ().

8. Other extension libraries

These functions may be new OpenGL functions, are not implemented in standard OpenGL libraries, or they are used to extend the functionality of existing OpenGL functions. Like Glu, GLX, and WGL, these OpenGL extensions are developed by hardware vendors and vendor organizations. OpenGL extension (OpenGL extention) contains a number of extended API functions.

As hardware updates, hardware vendors first apply to SGI to register for new extensions and write Specifications (specification). Then follow the instructions to develop the extension program. The extensions supported by the different OpenGL implementations (OpenGL implementation) may not be the same, and the extension will be supported in all OpenGL implementations only as a result of an extension and application as well as hardware technology, eventually becoming part of the OpenGL standard library. The extensions are maintained by SGI and are listed on the SGI website for the currently open registered extensions and their official specifications. The extension source is indicated by the suffix of the extension function (or by using an extended constant suffix). For example, the suffix win indicates an extension that complies with the Windows specification, and the ext or ARB suffix indicates that the extension is defined by multiple vendors.


This article is from the "11486263" blog, please be sure to keep this source http://11496263.blog.51cto.com/11486263/1831853

Introduction to OpenGL Basic Library

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.