NeHe OpenGL Lesson11 – Flag Effect (Waving Texture)

本文介绍了一种通过改变顶点位置而非纹理坐标来实现纹理波动效果的方法。这种方法虽然酷炫,但效率不高,因为每次更新顶点位置都需要在显存和主存间传输数据。文章还讨论了使用顶点着色器更新顶点位置以提高性能的可能性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

screen_shot4-300x238 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.

转载于:https://www.cnblogs.com/open-coder/archive/2012/08/23/2653382.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值