OpenGL basic graphics programming-OpenGL in Windows NT

Source: Internet
Author: User
Tags types of functions
3.1. OpenGL functions in Windows NT
As described in the previous chapter, OpenGL in Windows NT also contains more than 100 library functions. These functions are named in a certain format, that is, each function starts with GL. In addition to basic OpenGL functions, OpenGL in Windows NT also supports the following four types of functions:

Corresponding Function Description
OpenGL utility Library 43 functions. Each function starts with Glu.
OpenGL auxiliary Library 31 functions. Each function starts with aux.
Windows dedicated library function (WGL) Six functions. Each function starts with WGL.
Win32 API functions Five functions, without a special prefix.

There are 115 core functions in OpenGL, which 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.
OpenGL functions are higher than OpenGL core functions. These functions work by calling core functions. 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 (this guide will detail the specific usage of these functions. Such functions can be applied on any OpenGL platform like core functions.
The auxiliary libraries of OpenGL are some special functions that are originally used by beginners for 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 highly portable, exercise caution when using the OpenGL auxiliary library.
Six WGL functions are used to connect OpenGL and Windows NT. These functions are used to render and color OpenGL windows in Windows NT, draw bitmap fonts in the window and place the text in a certain position in the window. These functions combine windows and OpenGL. The last five Win32 functions are used to process pixel storage formats and dual-buffers. Obviously, these functions can only be used for Win32 systems, but not other OpenGL platforms.

3.2 Basic OpenGL functions
OpenGL can render and color the entire 3D model to draw a 3D scene that is very similar to the objective world. In addition, OpenGL can perform 3D Interaction and action simulation. The specific functions mainly include the following content.

  • Model drawing
    OpenGL can draw points, lines, and polygon. Using these basic forms, we can construct almost all 3D models. OpenGL usually uses the vertices of the polygon of the model to describe the 3D model. How to Use polygon and vertices to describe the 3D model will be detailed in the subsequent sections of the Guide.
  • Model observation
    After creating a 3D scene model, we need to use OpenGL to describe how to observe the created 3D model. The 3D model is observed through a series of coordinate transformations. The coordinate transformation of the model enables the observer to observe the 3D model landscape that is compatible with the viewpoint position. During the observation of the 3D model, the type of projection transformation determines the observation mode of the 3D model. Different projection transformations produce different scenes of the 3D model. In the final window transformation, the scene of the model is cropped and scaled to determine the image of the entire 3D model on the screen.

  • Specify the color mode
    OpenGL applies some special functions to specify the color of a 3D model. Programmers can select two color modes: The rgba mode and the color table mode. In rgba mode, the color is directly specified by the RGB value. In the color table mode, the color value is specified by a color index value in the color table. Programmers can also choose the plane coloring and smooth coloring methods to color the entire 3D landscape.
  • Illumination Application
    3D models drawn using OpenGL must be illuminated to be more similar to objective objects. OpenGL provides four methods for managing light (Radiant light, ambient light, mirrored light, and diffuse light). In addition, it can also specify the reflection characteristics of the model surface.
  • Image Enhancement
    OpenGL provides a series of functions to enhance the effect of 3D images. These functions enhance the effect of images through reverse sampling, mixing, and atomization. The reverse walk sample is used to improve the sawtooth and smoother line chart in the image. It is used together to process the translucent effect of the model. The fog gradually fades the image from the viewpoint to the distance and is closer to the real image.
  • Bitmap and image processing
    OpenGL also provides functions dedicated to bitmap and image operations.
  • Texture ing
    3D scenes are not realistic due to the lack of specific details. OpenGL provides the texture ing function to show 3D scenes more realistically. OpenGL provides a series of texture ing functions that allow developers to easily paste real images to the polygon of the scenes, so that they can draw Realistic 3D landscapes in the windows.
  • Real-time Animation
    To achieve smooth animation, you must first generate the next image in the memory, and then copy the generated image from the memory to the screen, this is OpenGL's Double Buffer technology ). OpenGL provides a series of functions for dual-Cache Technology.
  • Interaction Technology
    Currently, there are many graphic applications that require human-computer interaction. OpenGL provides a convenient 3D graphic human-computer interaction interface, allowing you to modify objects in a 3D landscape.

3.3. OpenGL structure in Windows NT
The role of OpenGL is the Client/Server mechanism, that is, the client (the application that uses OpenGL to draw scenes) releases OpenGL commands to the server (that is, the OpenGL kernel, the server interprets these commands. In most cases, the customer and the server run on the same machine. This is exactly the Client/Server mechanism of OpenGL, which can be conveniently used in the network environment. Therefore, OpenGL in Windows NT is network-transparent. Just as the graphic device interface (GDI) of Windows encapsulates the graphic function library in a dynamic link library (gdi32.dll under Windows NT, the OpenGL graphics library is also encapsulated in a dynamic link library (opengl32.dll ). The OpenGL functions called by the client application are processed in opengl32.dll and then transmitted to winsrv. dll. The OpenGL command is processed again and directly sent to the device drive interface (DDI) of Win32. In this way, the processed graphic command is sent to the video display driver. Briefly describe the process:
 
Figure 3-1 OpenGL Running Mechanism in Windows NT

With the acceleration of the glint graphics accelerator chip of the 3D Graphics Accelerator card, two additional drivers are added to this process. An OpenGL installable client Driver (ICD) is added to the client side, and a hardware-specified DDI (hardware-specific DDI) is added to the server side, this driver is at the same level as wind32 DDI.


Figure 3-2 OpenGL Running Mechanism Under 3D graphics Acceleration

Related Article

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.