1. EGL
The OpenGL es command requires a rendering context and a drawing surface.
Rendering Context: Saves the current OpenGL ES state.
Drawing Surface: A surface that is a primitive (primitive) drawing. It specifies the type of buffer to render, such as: color buffer,depth buffer and stencil buffer, and it also specifies the bit depth (bit depth) for each buffer required.
EGL is the interface between the OpenGL ES API and the native Window system. Before OpenGL ES performs render, the following work is required for EGL:
? Query the available display devices on the device and initialize them.
? Create a rendering surface ( render surfaces ). EGL can create a surface on the screen (On-srceen surface) or an offline screen surface off-screen surface that is connected to the local window system, while the offline screen surface is not displayed but can be used to render the surface The pixel buffer (rendering surface).
? Create a rendering context ( render environment). Before you actually start drawing, you need to connect the rendering environment to the render surface.
1.1 EGL Data type
Data Type |
P align= "Center" > c-language Type |
EGL Type |
32-bit integer |
int |
eglint |
32- bit unsigned integer |
unsigned int |
eglboolean, Eglenum |
32-bit pointer |
void * |
eglconfig, Eglcontext, Egldisplay, Eglsurface, Eglclientbuffer |
2. Openggl es command suffix and parameter data type
Data Type Suffix |
Data Type |
C-language Type |
GL Type |
B |
8-bit signed integer |
Signed Char |
Glbyte |
Ub |
8-bit unsigned integer |
unsigned char |
Glubyte, Glboolean |
S |
16-bit signed integer |
Short |
Glshort |
us |
16-bit unsigned integer |
unsigned short |
Glushort |
I |
32-bit signed integer |
Int |
Glint |
Ui |
32-bit unsigned integer |
unsigned int |
Gluint, Glbitfield, Glenum |
X |
16.16 fixed point |
Int |
Glfixed |
F |
32-bit floating Point |
Float |
Glfloat, Glclampf |
glvoid is an acceptable pointer to the OpenGL ES command.
2.1 OpenGL ES Basic error code
The error code can be passed glenum glgeterror (void) function gets, if the value of the current error code is not gl_no_error, the newly generated error code cannot be saved.
Error Code |
Description |
Gl_no_error |
No error has been generated since, the last call to Glgeterror. |
Gl_invalid_enum |
A glenum argument is out of range. The command that generated the error is ignored. |
Gl_invalid_value |
A numeric argument is out of range. The command that generated the error is ignored. |
Gl_invalid_operation |
The specific command cannot is performed in the current OpenGL ES state. The command that generated the error is ignored. |
Gl_out_of_memory |
There is insufficient memory to execute the this command. The state of the OpenGL ES pipeline was considered to being undefined if this error was encountered except for the current Erro R code. |
3. Flush and finish
The OpenGL ES2.0 API inherits OpenGL's C-s (client-server) mode. Application (client) to publish the command, the server is responsible for performing the processing. And not every command issued by the application is sent to the server in a timely manner. The CPU in the device is responsible for running the game logic and sending the drawing instructions to the GPU (hardware graphics or software-emulated graphics cards). In this architecture, the CPU and the GPU act as client and server roles, respectively.
The Glflush command refreshes the commands in the current OpenGL ES environment and sends them to the server. Glflush just sends the command to the server, but does not wait for the execution to complete. If you need to wait until server execution is complete, you need to call glfinish, but it can severely affect performance.
Glflush was called in Eglswapbuffers.
4. Basic state Management
Each stage of the pipeline has its own state, and each state has a corresponding value, which can be modified by the following two functions:
void glenable (glenum cap)
void gldisable (glenum cap)
in the initial state, except Gl_dither (initial value is Gl_true) , the initial values for each of the other states are gl_false. These status values are saved in the Eglcontext. Its status value can be queried by glisenabled (Glboolean glisenabled (glenum cap)).
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
OpenGL ES2.0 BASIC Programming