help about VBO's
i like to use VBO's for rendering. i int this with:
and render with this:
but i get no output.
when i render without VBO's (with vertex arrays) it works.
any suggestions ??
Code:
glGenBuffers(1, &vboId1);
glBindBuffer(GL_ARRAY_BUFFER, vboId1);
glBufferData(GL_ARRAY_BUFFER, [complete count] * sizeof(GLfloat), data, GL_STATIC_DRAW);
glGenBuffers(1, &vboId2);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId2);
glBufferData(GL_ELEMENT_ARRAY_BUFFER, numIndexes*3 * sizeof(GLushort), vertexIndicies, GL_STATIC_DRAW);and render with this:
Code:
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );
glEnableClientState(GL_NORMAL_ARRAY);
glBindBuffer(GL_ARRAY_BUFFER, vboId1);
glVertexPointer( 3, GL_FLOAT, 8*sizeof(GLfloat), data );
glTexCoordPointer( 2, GL_FLOAT, 8*sizeof(GLfloat), &data[3] );
glNormalPointer( GL_FLOAT, 8*sizeof(GLfloat), &data[5] );
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vboId2);
glDrawElements( GL_TRIANGLES, numIndexes*3, GL_UNSIGNED_SHORT, 0 );
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState( GL_TEXTURE_COORD_ARRAY );but i get no output.
when i render without VBO's (with vertex arrays) it works.
any suggestions ??
the last parameter of this call:
should be the address of the triangle vertex indexes.
Code:
glDrawElements( GL_TRIANGLES, numIndexes*3, GL_UNSIGNED_SHORT, 0 );
not sure that more than one buffer can be active at the same time.
try attaching the vertex buffer only (vboId1) to see what happens.
I use a single buffer for vertex, vertex indexes, normal, and tex coords.
try attaching the vertex buffer only (vboId1) to see what happens.
I use a single buffer for vertex, vertex indexes, normal, and tex coords.
With VBOs, the last parameter to gl*Pointer is the offset into the buffer that the data begins, not a pointer to the data.
i have read several times its better to use one array for all informations, and use a stride value. than use a indexarray to render.
i cant find any error, without vbo's, that works well.
arghhhhh....
btw. you can activate more than one buffer
edit
the last parameter should be 0. ????
ok works better but, the texturecoordinates looks strange
edit2
works well.
thanks...
i cant find any error, without vbo's, that works well.
arghhhhh....
btw. you can activate more than one buffer
edit
Code:
glVertexPointer( 3, GL_FLOAT, 8*sizeof(GLfloat), 0);
glTexCoordPointer( 2, GL_FLOAT, 8*sizeof(GLfloat), 0 );
glNormalPointer( GL_FLOAT, 8*sizeof(GLfloat), 0 );ok works better but, the texturecoordinates looks strange
edit2
Code:
#define BUFFER_OFFSET(i) ((char *)NULL+(i))
glVertexPointer( 3, GL_FLOAT, 8*sizeof(GLfloat), 0);
glTexCoordPointer( 2, GL_FLOAT, 8*sizeof(GLfloat), BUFFER_OFFSET(3*sizeof(GLfloat) ));
glNormalPointer( GL_FLOAT, 8*sizeof(GLfloat), BUFFER_OFFSET(5*sizeof(GLfloat)) );works well.
thanks...
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Unbinding VBO's | Bersaelor | 2 | 3,460 |
Aug 2, 2010 08:29 AM Last Post: Bersaelor |
|
| N-Body with GLSL and VBO's (how to approach)? | mcMike | 4 | 5,344 |
May 24, 2008 11:06 AM Last Post: mcMike |
|
| Use of VBO's with frame animation MD2's/MD3's (etc) = benefits? | Jones | 22 | 7,815 |
Oct 28, 2006 01:25 AM Last Post: OneSadCookie |
|

