PDA

View Full Version : Regarding VBOs



Howbizarre
04-29-2005, 12:09 AM
I am using VBOs to render a huge model. I create a VBO for both my Vertex Pointer and the Color Pointer using a structure of sort
struct sVertex
{
Vector3 m_vVertexCoordinates;
char m_bColor[3];
};

During creation of VBO I pass in the Vertex Data as.

glBufferDataARB(GL_ARRAY_BUFFER_ARB, iVertexListSize * sizeof(sVertex),vVertexList , GL_STATIC_DRAW_ARB);

where vVertexList is the pointer to my sVertex. While rendering the scene I make following calls.
a) For Vertex Pointer

glVertexPointer(3,GL_FLOAT,sizeof(sVertex),NULL);

b) For Color Pointer

glColorPointer(3,GL_UNSIGNED_BYTE,sizeof(sVertex), (void *)(NULL+3*sizeof(float)));

Now if I have my ClientState for Color Pointer turned on I get 6 FPS, while if I turn it off I get above 100 FPS. Please can someone tell me as to what am I doing wrong with the Color Pointer.

def
04-29-2005, 12:21 AM
Are the colors displayed correctly?
Are you sure Vector3 is the size of 3 floats?
What platform are you working on? Structures are not stored the same way under linux and windows. I don't remember exactly but sometimes bytes are padded in structures.
Is using structures with VBOs a good idea? Try a (guaranteed packed) array instead of the struct...

Howbizarre
04-29-2005, 12:33 AM
Are the colors displayed correctly?

Yes they are :)

Are you sure Vector3 is the size of 3 floats?

Yes float X, float Y and float Z. Also if this wasnt correct I wouldn't be able to get the model displayed correctly.

I am using Windows. And I am pretty confident that the structure does represent packed data :(

Howbizarre
04-29-2005, 12:49 AM
Are the colors displayed correctly?

Yes they are :)

Are you sure Vector3 is the size of 3 floats?

Yes float X, float Y and float Z. Also if this wasnt correct I wouldn't be able to get the model displayed correctly.

I am using Windows. And I am pretty confident that the structure does represent packed data :(
but yeah can try using an array

Relic
04-29-2005, 12:52 AM
If the data is tightly packed most of your floats are not on 4 byte boundaries and half of it are on odd addresses inside the array buffer.
I'm impressed that this is working at all. You should at least add a fourth pad byte to the colors.
What's huge for you? I.e. what is iVertexListSize?
You might want to split it to more digestable chunks. Maybe there was not enough space in fast memory to put all into it at once.
Which hardware are you using? Maybe it doesn't support unsigned byte colors natively. Try floats. Tried newer drivers?

Howbizarre
04-29-2005, 01:05 AM
Hey Relic !
Thank you so much. Yeah that was the problem. I added the padding Byte and now the thing is alive now :) .
The model has more than 10 Million Polygons, but the VBOs are being created for around every 40,000 Polygon Data.