Jump to content
  • Advertisement
Sign in to follow this  
enesm

glDrawArrays()

This topic is 3728 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

I am having a problem drawing multiple VBOs. I have an array of objects (each of the same class) with the same Draw() routine. However, only the first object in the array seems to be drawn and all the others are not visible. The main drawing loop looks something like this:
QVector<Object*> things;  // vector of things to draw

// loop through the vector and draw each thing
foreach(Object *obj, things)
    obj->Draw();  

The Draw() routine for each object is the same and looks as follows:
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_NORMAL_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);

glBindBuffer(GL_ARRAY_BUFFER, normalVBO);        
glNormalPointer(GL_FLOAT, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, vertexVBO);
glVertexPointer(3, GL_FLOAT, 0, NULL);
glBindBuffer(GL_ARRAY_BUFFER, texCoordVBO);
glTexCoordPointer(2, GL_FLOAT, 0, NULL);    
    
// Render the triangles
glDrawArrays(GL_TRIANGLES, 0, totalFaces * 3);
    
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_NORMAL_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);

where normalVBO, vertexVBO and texCoordVBO are set for each object when the object is created. Any permutation of the array results in the same phenomenon: only the first object is drawn, and the rest are not shown. Any idea why the other objects are not being drawn? Cheers, EM

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!