Sign in to follow this  
Ahl

A few questions on binding VBOs...

Recommended Posts

Ahl    170

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.

Share this post


Link to post
Share on other sites
Brother Bob    10344

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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this