目前在我的渲染函数中,我使用一个 VAO(顶点数组对象)和四个与这个 VAO 绑定的 VBO(顶点缓冲区对象)。
对于每个 VBO,我绑定到 vao
glGenVertexArrays (1, & vaoID [0]); // Create our Vertex Array Object
glBindVertexArray (vaoID [0]); // Bind our Vertex Array Object so we can use it
int i = 0;
for (i = 0; i <4, ++i)
{
glGenBuffers (1,vboID [i]); // Generate Vertex Buffer Object
glBindBuffer (GL_ARRAY_BUFFER, vboID [i]); // Bind Vertex Buffer Object
glBufferData (GL_ARRAY_BUFFER, 18 * sizeof (GLfloat) vertices, GL_STATIC_DRAW);
glVertexAttribPointer ((GLuint) 0, 3, GL_FLOAT, GL_FALSE, 0, 0);
}
glEnableVertexAttribArray (0); // Disable Vertex Array Object
glBindVertexArray (0); // Disable Vertex Buffer Object
然后在我的渲染函数(伪代码)中,对于每一帧:
glBindVertexArray (vaoID [0]);
// here, I need to draw the four VBO, but only draws the first
glBindVertexArray (0);
我知道我可以将所有几何图形放在一个 VBO 中,但在某些情况下它的大小超过 5Mb,这导致(可能)它没有放在 GPU 上。
我如何切换所有绑定的 VBO 来绘制它们?