I have implemented a 2D Particle System based on the ideas and concepts outlined in "Bulding an Advanced Particle System" (John van der Burg, Game Developer Magazine, March 2000).
Now I am wondering what performance I should expect from this system. I am currently testing it within the context of my simple (unfinished) SDL/OpenGL platformer, where all particles are updated every frame. Drawing is done as follows
// Bind Texture glBindTexture(GL_TEXTURE_2D, *texture); // for all particles glBegin(GL_QUADS); glTexCoord2d(0,0); glVertex2f(x,y); glTexCoord2d(1,0); glVertex2f(x+w,y); glTexCoord2d(1,1); glVertex2f(x+w,y+h); glTexCoord2d(0,1); glVertex2f(x,y+h); glEnd(); where one texture is used for all particles.
It runs smoothly up to about 3000 particles. To be honest I was expecting a lot more, particularly since this is meant to be used with more than one system on screen. What number of particles should I expect to be displayed smoothly?
PS: I am relatively new to C++ and OpenGL likewise, so it might well be that I messed up somewhere!?
EDIT Using POINT_SPRITE
glEnable(GL_POINT_SPRITE); glBindTexture(GL_TEXTURE_2D, *texture); glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE); // for all particles glBegin(GL_POINTS); glPointSize(size); glVertex2f(x,y); glEnd(); glDisable( GL_POINT_SPRITE ); Can't see any performance difference to using GL_QUADS at all!?
EDIT Using VERTEX_ARRAY
// Setup glEnable (GL_POINT_SPRITE); glTexEnvi(GL_POINT_SPRITE, GL_COORD_REPLACE, GL_TRUE); glPointSize(20); // A big array to hold all the points const int NumPoints = 2000; Vector2 ArrayOfPoints[NumPoints]; for (int i = 0; i < NumPoints; i++) { ArrayOfPoints[i].x = 350 + rand()%201; ArrayOfPoints[i].y = 350 + rand()%201; } // Rendering glEnableClientState(GL_VERTEX_ARRAY); // Enable vertex arrays glVertexPointer(2, GL_FLOAT, 0, ArrayOfPoints); // Specify data glDrawArrays(GL_POINTS, 0, NumPoints); // ddraw with points, starting from the 0'th point in my array and draw exactly NumPoints Using VAs made a performance difference to the above. I've then tried VBOs, but don't really see a performance difference there?