(Source code introduction:
This is the source code of flag floating effect drawn by OpenGL on Android platform. You can download and learn it. I hope it can help you.
Implementation steps
1. Firstly, the whole picture must be divided into several parts by segmentation method and drawn in a rectangle composed of grid
2. Draw n * n squares
3. Paste the flag pattern into this grid
1》 Calculate the coordinates of each vertex of the mesh vertex
Calculate the texture coordinate textcoord corresponding to each vertex
Calculate the vertex normal vector corresponding to each vertex normal
Calculate the order of vertices to be drawn
Paint flutter effect
According to the sine curve, calculate the depth value zdepth corresponding to each vertex
Calculate the fluctuation of sine wave
Coordinate change
Change of vertex normal vector coordinate value
Add light effects
Add material effects)