关于OpenGL中VAO(Vertex Array Object)的理解

本文探讨了顶点数组对象(VAO)在图形渲染中的作用及其性能优势。通过减少重复设置缓冲区对象状态的需求,使用VAO可以显著提高渲染效率。

以下问答来自于http://stackoverflow.com/questions/5970087/understanding-vertex-array-objects-glgenvertexarrays


I am confused with the point in generating/creating a Vertex Array Object (VAO) with:


glGenVertexArrays(GLsizei n, GLuint *arrays);

and

glBindVertexArray(GLuint);

Because I can still create a buffer object, say for vertices, and describe that buffer object with glVertexAttribPointer and glEnableVertexAttribArraywithout ever creating a VAO.

My question is if you do not have to actually create the VAO to describe the data in a buffer object, why would such sources as the OpenGL SuperBible 5ed include a call to create a VAO when creating VBOs? Are they only used for more advanced topics I have yet to discover, am I totally confused?

Also I first encountered this question when reading wikipedias entry on VBOs and their sample code includes no calls to glGenVertexArrays() but they still describe the data with glVertexAttribPointer().Wiki VBO entry -- Example where VAOs are created for what reason?



Performance improvements.
In many cases, setting up your attributes on the host require a high number of API calls, and an important amount of validation inside the implementation.
Doing all those once, and using the VAO allow that work to be amortized.
See, for example, Graham Sellers' analysis for actual data.


Say you are building an object that needs three VBOs (different data for shading, maybe positions, normals and some fancy effect parameter). Each time you would draw this object, you would have to bind all these VBOs and set any additional parameters. If you use a VAO, you only have to use one call (binding the vertex array), this will set up the entire environment for the specific object.

评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值