Professional terms at the entry to resolve the OpenGL ES trip --OpenGL

More to the concept of noun and personal understanding based

Quickly understand graphics API

OpenGL

OpenGL (Open Graphics Library, Open Graphics Library) is used to render 2D, 3D cross-language applications for vector graphics, cross-platform programming interface. Abstract computer resources will be referred to an OpenGL object abstraction of the operation of these resources is a OpenGL instruction. OpenGL is designed to output only, so it provides only rendering functions. OpenGL commonly used in CAD, virtual reality, scientific visualization programs and video game development.

OpenGL ES

OpenGL ES (OpenGL for Embedded Systems) is a subset of the OpenGL 3D graphics API, OpenGL is cut from the custom comes, it is for mobile phone, PDA and game consoles and other embedded devices are designed.

DirectX

DirectX, (Direct eXtension) is a multimedia programming interfaces created by Microsoft. DirectX is not a simple API, which is composed of a number of API, and can only support Windows platform. (As can be understood as an iOS developer)

Metal

Metal is a low-level rendering application programming interface that provides the lowest level of software required to ensure that the software can run on different graphics chips. Is the new platform for technology companies in the 2014 Apple WWDC provides for game developers, the technology can improve performance for 10 times rendering 3D images. Metal advantage lies in the integration of heterogeneous computing and rendering (and take advantage of OpenGL GPU accelerated rendering has the same functionality and can take advantage of, like OpenCL and GPU do heterogeneous computing) offers a variety of needs in a unified framework. Although Apple announced on 2018WWDC will abandon the use of OpenGL, so most of the applications currently on the market or use of OpenGL, will not switch to the Metal in a short time, so learning OpenGL is very necessary and important, Metal more important! ! !

OpenGL professional terms

OpenGL context (context)

Before the application calls OpenGL command, you need to create an OpenGL context which is a huge state machine holds various states in OpenGL, which is the basis for OpenGL instruction execution. Using OpenGL client - server model, we can say that each GPU is a hardware server, each corresponding to a drawing context to a client application, a client maintains a state machine, if two windows each corresponding to two different drawing context, the two window states independently of each other.

Since a large OpenGL state machine context, context switching may produce a larger system resource overhead, but different rendering module, may need to use a completely separate state, can create multiple contexts in the application, in different threads used in different contexts, sharing textures, buffers and other resources between contexts.

OpenGL state machine

The state machine is a kind of machine exist in theory, it has the following characteristics:. A It has a memory capacity to be able to remember their current status. B. It may receive input, the input content in accordance with their own state and, modify their own state, and the output can be obtained. c. When the time it enters a particular state (off state), it no longer receives input operation is stopped.

So essentially, our computers are not also be seen as one state machine:

  1. Computer memory (memory, hard disk, etc.), the computer can remember their current status (currently installed software on your computer, the data stored in the computer, in fact, are binary values, they belong to the current state).
  2. Computer input device receives an input (keyboard input, mouse input, file input), (mainly refers to program code may run), modify their status (modified value in memory), and may be obtained according to the contents of the input and the own state the output (the results are displayed to the screen).
  3. When it enters a particular state (off state), which no longer receives input stop working. The following OpenGL may be viewed as such a machine: (. 1) can be recorded OpenGL own state (for example: the currently used color glClearColor (1.0f, 1.0f, 0.0f, 0.0f) ;, is turned depth test function glEnable (GL_DEPTH_TEST) ;, etc. these are to be recorded) (2) OpenGL can receive input (when we call the function of OpenGL, OpenGL actually can be seen as receiving our input), based on the contents of the input and their status, modify their own state, and can obtain output (for example, we call glColor3f, the OpenGL received modify their "current color" the state of this input; we call glRectf, the OpenGL outputs a rectangle) ( 3) OpenGL may be brought to a standstill, no longer receives input. This may behave less obvious in our program, but before the program exits, OpenGL always stop working. ##### Rendering (Rendering) and converts the image data into a graphic image called the operation of the 3D spatial rendering (to be understood as being drawn to 3-D graphics, when an internal configuration drawing of the texture in terms of material, etc. according to the external ambient light, etc., generate more realistic three-dimensional effect) here's another interesting is: "draw," I understand the draw should just draw basic graphic elements, but should be a little more advanced rendering, plus the draw graphical elements on the basis of some of the effects it show.

Vertex array (the VertexArray) and vertex buffers (the VertexBuffer)

Vertices: when we refer to draw a pattern, and its vertex position data, and this data may be stored in the array or its cache memory to the GPU. Vertex array: that is to save a number of vertex data stored in the array, the data comprising: vertex coordinates, surface normals, the RGBA color, secondary color, color index, texture coordinates and the polygon boundary flag. This can only be done through a function called draw, greatly reducing the number of function calls, but also avoid sharing redundant vertex processing, improved application performance. Vertex buffer: Since OpenGL is a client - server model structure, sometimes the transmission data from the customer terminal to the server may be slow, so addition of a buffer object, the display can be directly specify which data stored in the graphics server .

Pipeline

Pipeline can be understood as rendering pipeline. OpenGL rendering graphics at the time, when the graphics data is processed in accordance with a fixed order, as similar to the assembly line, one after another in the order of execution. And must be strictly in accordance with this order, it can not be broken. (Pipelines, actually it refers to a bunch of original graphic data via a pipeline, through a variety of changes occur in the processing of final management process screen during.)

Fixed line (memory shader)

In the early days OpenGL encapsulated shader variety of block period contains a built-in light, coordinate conversion, clipping, etc. functions to complete the fixing Shader programs to help developers complete rendering graphics. OpenGL ##### programmable pipeline during use, the fixed line may not be completed for each service, it is possible to open into the associated programmable portion. (For individuals understanding chestnut: for example soap production line, i.e. line, from the raw material in a pipelined steps, the last step by step to produce a square, white soap bars, soap single color, shape of a single, less freedom, this is the fixed line. If the soap production process, you can customize the shape of soap, the soap's colors, in the end we can produce a variety of shapes, colors soap) ##### shader program shader coloring device (Shader) is used to achieve image rendering, editing programs can be used to replace fixed rendering pipeline, i.e., a programmable rendering pipeline. Thus, OpenGL draw before actually invoked, also need to specify a shader into edited by shader program. Common shaders are: vertex shader (VertexShader), the fragment shader (FragmentShader) / pixel shader (PixelShader), geometry shader (GeometryShader), tessellation shader (TessellationShader). The most important is the vertex shader and fragment shader. When processing the shader OpenGL, compile, link, etc. step of generating shader program (glProgram), Shader program contains both an arithmetic logic vertex shader and fragment shader. When the OpenGL rendering, first by the vertex shader vertex data into the calculation, then through the primitive assembled vertex is converted to the primitive, and then rasterized, converts primitives into raster data, and finally , the calculated data into rasterized fragment shader, fragment shader be rasterized data for each pixel is calculated, and determines the color of the pixel. ##### vertex shader (VertexShader) vertex shader typically is used to transform each vertex processing pattern (rotation / translation / projection) implements a generic method for operating a programmable vertex. A vertex-by-vertex shader program operation, that is, data for each vertex the vertex shader is executed once (in parallel). If each piece of merchandise to go through quality inspection departments, stamped qualified chapter before leaving the factory. ##### fragment shader (FragmentShader) fragment shader: General process for filling and computing the color of each pixel in the pattern. OpenGL is a program for calculating color segments, and calculates (in parallel) pixel by pixel, any pattern will have a number of pixels, it will perform a lot of calculations, the CPU can not be completed at this time a large number of these calculated, then we need to do auxiliary GPU. ##### GLSL (OpenGL Shading Language) is used for coloring in OpenGL programming language, a procedure-oriented language, the basic syntax and C / C ++ is substantially the same, they are in the graphics card GPU (Graphic Processor performed on a) a graphics processing unit unit, instead of a fixed portion of the rendering pipeline, so that the rendering pipeline having different levels of programmability. For example: view conversion, projection transformation and the like. GLSL shader code is divided into two parts: the vertex shader and fragment shader. ##### GLSL (OpenGL Shading Language) is used for coloring in OpenGL programming language, a procedure-oriented language, the basic syntax and C / C ++ is substantially the same, they are in the graphics card GPU (Graphic Processor performed on a) a graphics processing unit unit, instead of a fixed portion of the rendering pipeline, so that the rendering pipeline having different levels of programmability. For example: view conversion, projection transformation and the like. GLSL shader code is divided into two parts: the vertex shader and fragment shader. ##### GLSL (OpenGL Shading Language) is used for coloring in OpenGL programming language, a procedure-oriented language, the basic syntax and C / C ++ is substantially the same, they are in the graphics card GPU (Graphic Processor performed on a) a graphics processing unit unit, instead of a fixed portion of the rendering pipeline, so that the rendering pipeline having different levels of programmability. For example: view conversion, projection transformation and the like. GLSL shader code is divided into two parts: the vertex shader and fragment shader.

Rasterization Rasterization

1. The vertex data converting means to fragment the process, each of the tile elements corresponds to a pixel buffer. 2. A geometry is converted into a two-dimensional image of the process, the process involves two parts: an integer raster area of ​​the window determines which coordinates base primitive is occupied, 2 assigned a color value. and a depth value to each region, rasterization process is to generate fragments.

Grain

Is used to store a texture cache element OpenGL ES image color value, can be understood as image / images, which requires filling picture coding, in order to make more realistic scenario, where texture when rendering graphics.

Mixing (Blending)

In OpenGL, the mixing is generally a technique of transparency of an object, transparent object that is not a solid color, its color is a combination of different degrees of its color and the color of the object itself other objects behind it. For example, we can mix more color to a color, the three primary colors red, green, blue and black together after that. After the testing phase, if the pixel is still not removed, then the color of the pixel in the frame buffer and will color on the color mixing attachment.

Transformation matrix (Transformation)

In the graphics rendering process, there are three kinds of conversion, respectively, panning, zooming, rotation. We need to use the transformation matrix.

Matrix Projection (Projection)

3D coordinates for converting two-dimensional screen coordinates, the actual lines are drawn in two-dimensional coordinates.

On-screen rendering / exchange buffer (SwapBuffer)

Renderbuffer general mapping system resources such as windows. If the image is rendered directly to the rendering buffer corresponding to the window, the image may be displayed on the screen. Note that, if each window is only a buffer, then in the process of drawing a screen refresh, the window may not show the full picture. To solve this problem, the conventional OpenGL program, there will be at least two buffers. Displayed on the screen is called the screen buffer, does not show is called off-screen buffer. After a buffer rendering is complete, the screen buffer and the offscreen buffer exchange, the image display on the screen. Due to refresh the display is generally carried out line by line, in order to prevent an image swap buffer when the upper and lower regions of the screen belonging to two different sub-frames, and therefore the exchange will generally wait signal display refresh is completed, the display refresh interval of two in exchange, this signal is called a vertical synchronization signal, this technique is called the vertical sync.

Reproduced in: https: //juejin.im/post/5d0ae1d06fb9a07ead5a0040

Guess you like

Origin blog.csdn.net/weixin_34187822/article/details/93182334