Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Example Analysis of OpenGL ES rendering Pipeline

2025-04-11 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article mainly shows you the "OpenGL ES rendering pipeline example analysis", the content is simple and easy to understand, clear organization, I hope to help you solve doubts, let Xiaobian lead you to study and learn "OpenGL ES rendering pipeline example analysis" this article bar.

The rendering pipeline is generally composed of parallel processing units that process graphics signals inside the display chip GPU. These parallel processing units are independent. From another point of view, the rendering pipeline is actually a series of rendering processes. The input of this series of processes is the relevant description information of the object to be drawn, and the output is the image frame data to be displayed.

OpenGL ES pipeline mainly includes:

Read Vertex Data-> Vertex Shader-> Assemble Primitives-> Rasterize Primitives-> Fragment Shader-> Write to Frame Buffer-> Display to Screen

Reading vertex data refers to passing vertex data of the graph to be drawn to the rendering pipeline.

The vertex shader finally generates the final position of each vertex, performs various transformations on the vertices, it performs once for each vertex, and after determining the final position, OpenGL can assemble these vertex sets into points, lines, or triangles according to the given parameter type.

The primitive assembly stage includes two parts: primitive assembly and primitive processing. Primitive assembly refers to the combination of vertex data into complete primitives according to the set drawing mode parameters. For example, each primitive in point drawing mode contains only one point, and each drawing source in line drawing mode contains two points. Primitive processing mainly refers to clipping so that the part of primitives located inside the view volume is transferred to the next step, and the part outside the view volume is clipped. The concept of a view volume is related to projection.

Rasterizing primitives mainly refers to discretizing an primitive into displayable two-dimensional cell fragments, which are called fragments. A slice corresponds to one or more pixels on the screen. A slice contains information such as position, color, texture coordinates, etc. These values are interpolated from the vertex information of the primitive.

The fragment shader generates the final color for each fragment, once per fragment. Once the color of each fragment is determined, OpenGL writes them to the frame buffer.

The two main parts of OpenGL ES 2.0 are the programmable vertex shaders and fragment shaders above. Learning OpenGL ES is mainly to understand the rendering pipeline, understand the CPU rendering process, the main programming work lies in the vertex shader and fragment shader writing.

Draw a hexagon

The effect is as shown in the picture

hexagonal class

public class SixShape { private FloatBuffer mVertexBuffer; private FloatBuffer mColorBuffer; private int mProgram; private int mPositionHandle; private int mColorHandle; private int muMVPMatrixHandle; public SixShape(float r) { initVetexData(r); } public void initVetexData(float r) { //Initialize vertex anchor float[] vertexArray = new float[8*3];//initialize vertex color float[] colorArray=new float[8*4]; int j = 0, k = 0; vertexArray [j ++]= 0; vertexArray [j ++]= 0; colorArray [k ++]= 1; colorArray [k ++]= 1; colorArray[k++] = 0; for (int angle = 0; angle

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report