Jump to content
  • Advertisement
Sign in to follow this  
gatofedorento

Problem with multiple VBOs

This topic is 2462 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey threre!

I'm having problems drawing with multiple VBOs, everytime i create a two VBOs only the last one can be drawn, the other VBO is not drawn or is draw with an incorrect shape

here is the code I'm using to create the VBOs

static void setupParticleModel(ParticleEffect* pe, float particleSize){
float value = particleSize/2;
BufferVertex tmp0 = {-value , -value, 0.0f ,
0.0f , 0.0f , -1.0f,
0.0f , 0.0f , 0.0f};
pe->vertexes[0] = tmp0;
BufferVertex tmp1 = {value , -value , 0.0f ,
0.0f , 0.0f , -1.0f,
1.0f , 0.0f , 0.0f};
pe->vertexes[1] = tmp1;
BufferVertex tmp2 = {value , value , 0.0f ,
0.0f , 0.0f , -1.0f,
1.0f , 1.0f , 0.0f};
pe->vertexes[2] = tmp2;
BufferVertex tmp3 = {-value , value , 0.0f ,
0.0f , 0.0f , -1.0f,
0.0f , 1.0f , 0.0f};
pe->vertexes[3] = tmp3;
pe->indices[0] = 0;
pe->indices[1] = 1;
pe->indices[2] = 2;
pe->indices[3] = 3;

pe->particleModelID = generateBuffer(GL_ARRAY_BUFFER, sizeof(BufferVertex)*4,pe->vertexes,GL_STATIC_DRAW);
glTexCoordPointer(3, GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(24));
glNormalPointer(GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(12));
glVertexPointer(3, GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(0));
pe->indicesID = generateBuffer(GL_ELEMENT_ARRAY_BUFFER, sizeof(int)*4, pe->indices,GL_STATIC_DRAW);


the generateBuffer function:
GLuint generateBuffer(GLenum target, GLsizeiptr size, GLvoid* data, GLenum usage){
GLuint ret;
glGenBuffers(1, &ret);

glBindBuffer(target, ret);
glBufferData(target, size, data, usage);
return ret;
}


and this is the code I'm using for each draw call:
void draw(ParticleEffect* pe){

glBindBuffer(GL_ARRAY_BUFFER, pe->particleModelID);
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, pe->indicesID);

glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_VERTEX_ARRAY);


glColor3f(0.0f,0.0f,0.0f);
glDrawElements(GL_QUADS,4,GL_UNSIGNED_INT,0);


glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}


If I create two VBOs of the ParticleEffect type it draws both the size of the last one create, but if I create two VBOs from different types only the last one is drawn, am I forgetting something?

Share this post


Link to post
Share on other sites
Advertisement
try calling these
glTexCoordPointer(3, GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(24));
glNormalPointer(GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(12));
glVertexPointer(3, GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(0));

during draw instead of at init

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3, GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(0));
glEnableClientState(GL_NORMAL_ARRAY);
glNormalPointer(GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(12));
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(3, GL_FLOAT, sizeof(BufferVertex), BUFFER_OFFSET(24));

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!