glDrawArrays fails with btVector3/btVector4

vexator
Posts: 10
Joined: Thu Nov 01, 2007 11:12 am

glDrawArrays fails with btVector3/btVector4

Post by vexator »

I have been using glm for maths, but i'd like to switch to bullet, because i'll need it anyways for physics simulation. problem is, if I use btVector3 or btVector4 to fill my vertex buffer objects in OGL, nothing is being drawn.. i know that even a btVector3 is four floats long, but that shouldn't matter.. any idea what's going wrong here? thank you!

Code: Select all

struct Vertex
{
	btVector3 kPosition;
	btVector3 kUVCoords;
};

glBindBuffer( GL_ARRAY_BUFFER, pkVertexbuffer->uiId );

glVertexPointer( 3, GL_FLOAT, sizeof(Vertex), (void *)0 );
glTexCoordPointer( 2, GL_FLOAT, sizeof(Vertex), (void *)(sizeof(btVector3)) );

uint uiVertexCount = (uiCount > 0) ? uiCount : pkVertexbuffer->uiSize-uiFirst;
glDrawArrays( Topologies[pkVertexbuffer->uiTopology], uiFirst, uiVertexCount );
Spaddlewit
Posts: 28
Joined: Fri Sep 04, 2009 8:23 pm

Re: glDrawArrays fails with btVector3/btVector4

Post by Spaddlewit »

I think this is actually more of a GL question.

You don't have your stride set properly (3rd parameter in gl*Pointer).

The 'stride' value is how much to 'skip' inbetween each element. It should be the size of the .w coordinate in btVector3, plus the size of kUVCoords.

With the way you have your vertex data packed, don't you think it would be easier to use glInterleavedArrays???
vexator
Posts: 10
Joined: Thu Nov 01, 2007 11:12 am

Re: glDrawArrays fails with btVector3/btVector4

Post by vexator »

you mean like this?

Code: Select all

glVertexPointer( 3, GL_FLOAT, sizeof(float)*5, (void *)0 );
glTexCoordPointer( 2, GL_FLOAT, sizeof(float)*2, (void *)0 );
this results in completely messed up geometry, even with glm vectors. fact is, it's working fine with glm's 4-component vectors, but as soon as I switch to btVector4 for the vertex buffers, nothing is being rendered on screen.

glInterleavedArrays will be depreciated.