Hello everyone.

I am fairly new to opengl and I've used it so with far with C for rendering 2D sprites in immediate mode. I have looked over VBOs
a bit and it appears that everything in the VBO is drawn at once (possibly in parallel by all available graphics cores). It seems
to me that this is exponentially more efficient than anything I'm doing.

My questions are:
  1. Can individual elements in a VBO (like the nth 'rotation' float in the VBO) be modified in my 'animate' and 'detect_collisions' functions or are all of these changed at once. (see below).
  2. How should I set up my structs to easily fill in the VBO in say a create_VBO_from_sprites(sprite_Array) function.


Here's the basic setup I'm using which works well so far on even weaker laptops with integrated GPUs:

a sprite is defined:

Code :
typdef struct
{
   Texture* image;
 
   GLfloat width;
   GLfloat height;
   GLfloat xcoords[4];  // x vertices
   GLfloat ycoords[4];  // y vertices
   GLfloat rotation;      // in degrees
   GLfloat xdir;            // direction of travel x
   GLfloat ydir;            // direction of travel y
}
Sprite;

In my idle function, I go through all sprites and do
Code :
//get start time 't0'
 
animate(sprite_Array);
detect_collisions(sprite_Array);
glutPostRedisplay();
 
// get time 't1' = time since 't0'
// get difference 'gap' between 't1' and wanted refresh of 16.667 mlsec (60 frames per second)
 
Sleep(gap);

This basically just updates the vertices 'xcoords', 'ycoords' based on new values of 'rotation', 'xdir' and 'ydir'. If a
collision is detected, the values of 'rotation', 'xdir', and 'ydir' are all changed based on some physics I will not write
here.

My display function simply draws the textures based on the 'xcoords' and 'ycoords' settings

Code :
for(GLuint i=0; i<sizeof(sprite_Array); i++)
{
   Sprite* sp = sprite_Array[i];
 
   glEnable(GL_TEXTURE_2D);
   glBindTexture(GL_TEXTURE_2D, sp->image->ID);
   glBegin(GL_POLYGON);
   glColor4f(1, 1, 1, sp->alpha);
   glTexCoord2i(0, 0); glVertex2f(sp->xcoords[0], sp->ycoords[0]);
   glTexCoord2i(1, 0); glVertex2f(sp->xcoords[1], sp->ycoords[1]);
   glTexCoord2i(1, 1); glVertex2f(sp->xcoords[2], sp->ycoords[2]);
   glTexCoord2i(0, 1); glVertex2f(sp->xcoords[3], sp->ycoords[3]);
   glEnd();
   glDisable(GL_TEXTURE_2D);
}