   A theoretical question about VBO's
  Hi everyone,My knowledge of OpenGL is limited to immediate mode rendering and the 1.0/1.1 API. I'm attempting to update my knowledge so that I can be on board with the 3.2/4.0 update.I've written a small program with displays several hundred randomly placed quads all with the same texture. Here's the part of my code I'm most interested in:    glGenBuffersARB(1, &vertexBuffer);    glGenBuffersARB(1, &texBuffer);    glBindBufferARB(GL_ARRAY_BUFFER_ARB, texBuffer);    glBufferDataARB(GL_ARRAY_BUFFER_ARB, texSize, texArray, GL_STATIC_DRAW_ARB);   glTexCoordPointer(2, GL_FLOAT, 0, 0);   glBindBufferARB(GL_ARRAY_BUFFER_ARB, vertexBuffer);    glBufferDataARB(GL_ARRAY_BUFFER_ARB, vertexSize, vertexArray, GL_STATIC_DRAW_ARB);    glVertexPointer(3, GL_FLOAT, 0, 0);followed by my drawing code:    glBindTexture(GL_TEXTURE_2D, texture_manager->texture[0]);   glEnableClientState(GL_VERTEX_ARRAY);    glEnableClientState(GL_TEXTURE_COORD_ARRAY);    glEnable(GL_TEXTURE_2D);    glDrawArrays(GL_QUADS, 0, vertexSize * 4);    glDisable(GL_TEXTURE_2D);    glDisableClientState(GL_VERTEX_ARRAY);    glDisableClientState(GL_TEXTURE_COORD_ARRAY);This code is incredibly fast, but it doesn't make much sense semantically. What happens when I need 50 different textures with 100 different sets of vertices? All of the vertex and texture coordinate data for this single quad-type seems to be shoved into the same buffer on the video card. Does this mean that all vertex and texture coordinate data for a scene needs to be placed into a single buffer?Also, a slightly tangential question: I know immediate mode is bad bad bad. However, I want my game engine to be compatible with older cards that only support opengl 2.1 (ie, geforce 7xxx). How should I be rendering my data? Vertex arrays, vertex buffer objects, display lists, vertex array objects? It's all a bit difficult to suss out. To make matters worse, I'm using SDL as my window manager.Thank you for all your help.edit: just ranting. Why the hell does current opengl literature even mention glBegin()/glEnd(). These calls are depreciated, and only do a disservice to people trying to learn the api![Edited by - Optimus Prime on April 23, 2010 10:42:13 PM]
Quote:This code is incredibly fast, but it doesn't make much sense semantically. What happens when I need 50 different textures with 100 different sets of vertices? All of the vertex and texture coordinate data for this single quad-type seems to be shoved into the same buffer on the video card. Does this mean that all vertex and texture coordinate data for a scene needs to be placed into a single buffer?Why do you feel this is the case? You can create/render as many different buffers as you want. I'm really not sure what you're getting at, maybe you can explain a little bit more what you mean.Quote:How should I be rendering my data? Vertex arrays, vertex buffer objects, display lists, vertex array objects? It's all a bit difficult to suss out. Go with VBO's. If you want to see which hardware supports this feature, you can download the OpenGL Extensions Viewer, which will show you all extensions supported for about 600 different graphics cards. A quick glance reveals ARB_vertex_burrer_object extension available as early as GeForce 256 or Radeon 7500, both released back in 1999/2000 I think, so you shouldn't have any problem there :)Quote:To make matters worse, I'm using SDL as my window manager. I don't think this matters.   ;Quote:I'm really not sure what you're getting at, maybe you can explain a little bit more what you mean.Sorry, I think I understand VBOs a bit better now after doing some more reading. I didn't know that multiple VBOs could be allocated. In fact, I didn't realize that I was indeed defining two VBOs in my code above.;  edit: I've moved my post here:http://www.gamedev.net/community/forums/topic.asp?topic_id=569279[Edited by - Optimus Prime on April 24, 2010 3:12:41 PM]