NeHe OpenGL Lesson11 – Flag Effect (Waving Texture)
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.
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 记一次.NET内存居高不下排查解决与启示
· DeepSeek 开源周回顾「GitHub 热点速览」
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了