OpenGL (1)

Source: Internet
Author: User

Note: In this article, the full angle brackets "()" are used to indicate escape or annotation. The original brackets use the full angle brackets "()".

In the new stage, the development direction is from computer vision to graphics processing, and OpenGL-related development technologies need to be learned. At mentor's suggestion, I used the classic Redbook-OpenGL programming guide (originally book OpenGL programming guide, author Dave shreiner) as the Learning Guide. In the OpenGL getting started series, I plan to write some of my own experiences based on some important points in the book and examples.

Redbook mentioned at the beginning that "OpenGL (Open graphics library, GL graphics library) is a software interface of graphics hardware." First, OpenGL is based on graphics hardware, for example, NVIDIA or amd gpu, followed by a software interface, enables us to call interface functions through software programs to achieve brilliant graphic presentation. The book also mentions that "OpenGL is actually a program interface specification independent of hardware. A specific implementation of a specific type of hardware is used ". I understand that OpenGL is a platform-independent abstract interface specification, which has different implementations under different circumstances, specific implementations are implemented based on specific hardware.

In Chapter 1st, Redbook mentions several concepts and points to be mastered: the basic structure, function syntax, Operation Sequence of OpenGL rendering pipeline, rendering complexity, OpenGL is a state machine, OpenGL rendering pipeline, and glut (GL utility Toolkit ).

1.1 What is OpenGL

OpenGL is a "streamlined" interface specification. To be implemented on different hardware platforms, OpenGL does not include functions used to execute window tasks or obtain user input. You need to use the window system to control the specific hardware used by the program. In OpenGL, complex object models are created through basic geometric elements (such as points, straight lines, and polygon.

Redbook introduces the OpenGL rendering process by listing a series of cover pictures. In this example, a wireframe model is used to display a scenario. The atmospheric effect (collectively referred to as "fog") is used to add a depth prompt (depth-cue) and an antialiased effect, perform flat-shading and smoth-shading respectively, and add shadow and texture effects to the scene) A 2D image can be projected onto a 3D object, followed by motion-blurred, angle conversion, depth of field effect (depth-of-field ).
Effect. This is a specific example. We can summarize the main graphic operations of OpenGL when rendering images in scenes:

(1) create shapes based on geometric elements and create mathematical descriptions of objects;

(2) Arrange objects in 3D space and select the angle of view;

(3). Calculate the color;

(4). converts the mathematical description and color information of an object into pixels on the screen, that is, Rasterization ).

In some OpenGL implementations, the computers that display the created graphics can be different from those that run the graphics program. The computers that run the graphics program and run the drawing command are called clients ), the computer that receives these commands and executes the drawing task is called the server ). The transmission format (Protocol) of commands sent from the client to the server is always the same, so OpenGL programs can run through the network.

A series of related processing stages of OpenGL are called OpenGL rendering pipelines ). Pipelines are divided into fixed pipelines and programmable pipelines ). When you use a fixed pipeline, you can set various OpenGL states and make them take effect until they are modified again. Therefore, OpenGL is actually a state machine. If the shader of a programmable pipeline is used, the number of States that shader can recognize varies with different versions.

1.2 OpenGL-related library functions: tool function library, function prefix gluglx: Use the extension of X Window System, function prefix Glx-WGL: Extended Interface of MS Windows system, function prefix WGL-AGL: extended interfaces of Mac OS, with the function prefix AGL-CGL: Extended interfaces of Mac OS. The function prefix cgl1.2.1 contains files OpenGL # include <Gl/GL. h> (usually put in the system header file directory, such as UNIX in/usr/include/) provide the operating system and window system # include <Gl/Glu. h> extension # include "glext. H "window interface library # include <X11/xlib. h> # include <Gl/Glx. h> Windows contains the following access to WGL functions # include <windows. h> glut # include <freeglut. h> (glut. H and freeglut. h already contains GL. H and Glu. h. It is also guaranteed to include GL. H and Glu. h Previously, all internal macros dependent on the operating system were correctly defined.) opengl3.1

# Include <gl3/gl3.h> # include <gl3/gl3ext. h>

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.