A few questions on binding VBOs...

Started by
0 comments, last by Brother Bob 11 years, 4 months ago

Hey all,

The question isn't so much how to do it, I've figured that out, it's how you unbind a VBO and why having a bound VBO seems to block the usage of Vertex Arrays?

I have the following code in my rendering function:


if (VBO_Support)
				{
					glVertexPointer(	3,	GL_FLOAT,	sizeof(MyVertex),	(GLvoid*) (*RenderListIT)->RenderMesh->VBO_Offset					);
					glNormalPointer(		GL_FLOAT,	sizeof(MyVertex),	(GLvoid*)((*RenderListIT)->RenderMesh->VBO_Offset+sizeof(float)*3)	);
					glTexCoordPointer(	2,	GL_FLOAT,	sizeof(MyVertex),	(GLvoid*)((*RenderListIT)->RenderMesh->VBO_Offset+sizeof(float)*6)	);
					glColorPointer(		3,	GL_FLOAT,	sizeof(MyVertex),	(GLvoid*)((*RenderListIT)->RenderMesh->VBO_Offset+sizeof(float)*8)	);
				}
				else
				{
					glVertexPointer(	3,	GL_FLOAT,	sizeof(MyVertex),	&(*RenderListIT)->RenderMesh->VertexData->x		);
					glNormalPointer(		GL_FLOAT,	sizeof(MyVertex),	&(*RenderListIT)->RenderMesh->VertexData->nx	);
					glTexCoordPointer(	2,	GL_FLOAT,	sizeof(MyVertex),	&(*RenderListIT)->RenderMesh->VertexData->u		);
					glColorPointer(		3,	GL_FLOAT,	sizeof(MyVertex),	&(*RenderListIT)->RenderMesh->VertexData->a		);
				}

And I have a toggle that changes VBO_Support back and forth. When I have a VBO bound (glBindBufferARB()) and VBO_Support = true everything runs fine but none of my objects display. Why is that?

Thanks in advance.

Advertisement

If you have a vertex buffer object bound, then the pointer passed to the vertex array functions is an offset into the bound vertex buffer object. If you don't have a vertex buffer object bound, then the pointer is a direct pointer to system memory.

In other words, you cannot mix buffer object bindings and system memory pointers. If you switch to vertex arrays stored in system memory, then you also have to unbind the buffer object by binding object ID 0.

This topic is closed to new replies.

Advertisement