NeHe OpenGL Lesson11 – Flag Effect (Waving Texture)
2012-08-23 22:27
204 查看
![](http://images.cnblogs.com/cnblogs_com/open-coder/201208/201208232227296701.png)
This demo shows us how to wave texture though vertex position changing at the running time instead of moving texture coordinated. You could get such cool effect with the method used here. But obviously, this is not the most efficient way to do that. Because every time you want to update the vertex position, you need to update the access vertex buffer data. You need to transfer those data from display card memory to main memory, then transfer those data back to display card memory again after you finish the updating process. The whole process will take some bandwidth of data transferring between display card memory and main Memory. On possible way to improve the performance is to update the vertex position in the vertex shader part. This way you do not need data transfer and access vertex data with CPU.
Well, let focus other part of this demo. The following are some points that need to mention:
glPolygonMode(GL_BACK,GL_FILL ); glPolygonMode(GL_FRONT,GL_LINE );
The above code used set different shade mode for back surfaces and front surfaces. The back one use solid and the front one use wireframe mode. To fully understand what’s going on here, you need to know: left hand coordinates and right hand coordinates, the order that used in the triangles, how the 3D API define clockwise order. The above thig will make you understand those triangles you submit to 3D API are front surfaces or back surfaces. Most of the time, only front surfaces will be draw, and back surfaces will be discarded.
The full source code could be found here.
相关文章推荐
- NeHe OpenGL Lesson28 – Bezier Patches(贝叶茨曲面) / Fullscreen Fix
- NeHe OpenGL Lesson12 – Display Lists
- NeHe OpenGL Lesson27 – Volume Shadows(体积阴影)
- NeHe OpenGL Lesson 10 – Loading And Moving Through A 3D World
- NeHe OpenGL Lesson26 – Clipping & Reflections Using The Stencil Buffer
- NeHe OpenGL Lesson25 – Morphing & Loading Objects From A File
- NeHe OpenGL Lesson24 – Tokens, Extensions, Scissor Testing And TGA Loading
- NeHe OpenGL Lesson39 – Introduction to Physical Simulations
- NeHe OpenGL Lesson23 – Sphere Mapping Quadrics In OpenGL
- NeHe OpenGL Lesson38 – Loading Textures From A Resource File
- NeHe OpenGL Lesson22 – Bump-Mapping, Multi-Texturing & Extensions
- NeHe OpenGL Lesson37 – Cel-Shading(卡通渲染)
- NeHe OpenGL Lesson21 – Lines, Antialiasing, Timing, Ortho View And Simple Sounds
- NeHe OpenGL Lesson36 – Radial Blur(径向模糊)
- NeHe OpenGL Lesson20 – Masking
- NeHe OpenGL Lesson35 – Playing AVI Files In OpenGL
- NeHe OpenGL Lesson19 – Particle Engine Using Triangle Strips(粒子引擎)
- NeHe OpenGL Lesson34 – Beautiful Landscapes By Means Of Height Mapping
- NeHe OpenGL Lesson18 – Quadrics (二次曲面)
- NeHe OpenGL Lesson33 – Loading Compressed And Uncompressed TGA’s