[OpenGL] OpenGL function library Introduction

Source: Internet
Author: User

Here is a brief introduction OpenGL function library And OpenGL utility kit (GLUT) :
1, The core library contains 115 library functions, each of which starts with Gl. These functions are the most basic and can be applied on any OpenGL platform. These functions are used to create various shapes, generate illumination effects, perform anti-sample operations, perform texture ing, and perform projection transformation. Because these core functions have many forms and can accept different types of parameters, these functions can actually derive more than 300 functions.
2 Practical Library: 43 functions, each starting with Glu. It is a higher layer of functions than OpenGL core functions. These functions work by calling core functions. They can be applied on any OpenGL platform. These functions provide simple usage, which reduces the programming burden of developers. OpenGL's practical functions include texture ing, coordinate transformation, polygon differentiation, and drawing some simple polygon entities such as elliptical, cylindrical, and teapot. Such functions can be applied on any OpenGL platform like core functions.
3, Auxiliary Library: 31 functions, each starting with aux. These functions are intended for beginners to do simple exercises. Therefore, these functions cannot be used on all OpenGL platforms, These functions can be used in Windows NT. These functions are easy to use. They can be used for window management, input/output processing, and some simple 3D shapes. To make OpenGL applications Program It has good portability and should be cautious when using the OpenGL auxiliary library.
4, Dedicated library functions, Each window has a function that is used to extend the window system to support OpenGL rendering. In the computer that uses the X Window System, the OpenGL extension (Glx) of the X Window System is provided as an extension of OpenGL. The name of the Glx library function contains the prefix "Glx ". On Windows, six functions starting with WGL provide interfaces between windows and OpenGL.
5, OpenGL utility kit (GLUT, OpenGL utility Toolkit) It is an independent toolkit developed by Mark kilgard to bypass the complexity of the window system API. The glut function name contains the prefix "glut ".
6, Win32 API functions : Five functions without a specific prefix. These functions are used to process pixel storage formats and dual buffers. Obviously, these functions can only be used in Win32 systems but not other OpenGL platforms.

Introduction to OpenGL utility kit (GLUT:
OpenGL contains rendering functions, but is involved as independent from any window system and operating system. Therefore, OpenGL does not use functions to open windows or detect keyboard or mouse events. The glut library is used to simplify these tasks. In addition, it provides functions for creating complex three objects (such as sphere, ring, and teapot.
Window Management Functions
Gluinit (int * argc, char ** argv): Initialize glut and process command line parameters. You should call gluinit () before calling other glut functions ().
Specify the rgba mode or the color index mode. You can also specify whether to use a single cache or dual cache.
Gluinitwindowposition (int x, int y), which specifies the position on the screen in the upper left corner of the window.
Gluinitwindowsize (INT width, int size), which specifies the size of the window, in pixels.
Int ngcreatewindow (char * string), used to create a window in an OpenGL scenario. This function returns an identifier that uniquely identifies the newly created window. Note that before you call glumainloop, the window is not displayed.
Display callback function
Gludisplayfunc (void (* func) (void) is the most important time callback function. Every time glut deems it necessary to re-display the content of the window, it will execute the callback function registered by the function gludisplayfunc (). Therefore, all functions to be called for re-drawing should be placed in the display callback function. If the program modifies the window content, it may need to call the function glupostredisplay (void), which reminds the function glumainloop to call the registered display callback function.
Run the program
The content of all the created windows is displayed. The program starts event processing. The display callback function of this volume is triggered and enters this loop, so it will not exit.
Process input events
(Void (* func) (int w, int H) specifies the measures to be taken when the window size changes;
Glukeyboardfunc (void (* func) (unsigned char key, int X, int y) and glumousefunc (void (* func) (INT button, int state, int X, int y), specifies the callback function to be called when a specific key and mouse button are pressed or released.
Glumotionfunc (void (* func) (int x, int y), which calls the callback function when you press the mouse button and move the mouse.
Management Background Processing
Glutidlefunc (void (* func) (void) specifies a function that is executed when no other events need to be processed (such as idle event loops.
Draw 3D objects
Gldouble size, glsolidcube (gldouble size), glwiresphere (gldouble radius, glint slices, glint statcks), glsolidsphere (gldouble radius, glint slices, glint stacks), etc.

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.