help about VBO's

Apprentice
Posts: 9
Joined: 2010.02
Post: #1
i like to use VBO's for rendering. i int this with:
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 ??
Quote this message in a reply
Member
Posts: 157
Joined: 2002.12
Post: #2
the last parameter of this call:
Code:
glDrawElements( GL_TRIANGLES, numIndexes*3, GL_UNSIGNED_SHORT, 0 );
should be the address of the triangle vertex indexes.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #3
mh,
dont work too
Quote this message in a reply
Member
Posts: 157
Joined: 2002.12
Post: #4
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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
With VBOs, the last parameter to gl*Pointer is the offset into the buffer that the data begins, not a pointer to the data.
Quote this message in a reply
Apprentice
Posts: 9
Joined: 2010.02
Post: #6
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
Code:
    glVertexPointer(   3, GL_FLOAT, 8*sizeof(GLfloat), 0);

    glTexCoordPointer( 2, GL_FLOAT, 8*sizeof(GLfloat), 0 );
    glNormalPointer(      GL_FLOAT, 8*sizeof(GLfloat), 0 );
the last parameter should be 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...
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Unbinding VBO's Bersaelor 2 4,576 Aug 2, 2010 08:29 AM
Last Post: Bersaelor
  N-Body with GLSL and VBO's (how to approach)? mcMike 4 6,007 May 24, 2008 11:06 AM
Last Post: mcMike
  Use of VBO's with frame animation MD2's/MD3's (etc) = benefits? Jones 22 9,099 Oct 28, 2006 01:25 AM
Last Post: OneSadCookie