I am trying to do particles system with VBO (i am just started learning VBO), but i have some performance issues.
First, i created particle system using immediate mode, and i get about 60 fps with 40000 particles, but when i rewrited it using VBO my performance drop dramatically, now i am getting only 5000 particles with 60 fps.
Here some my code:
CREATING PARTICLE:
public Particle(){
FloatBuffer vertices = BufferUtils.createFloatBuffer(2*4);
vertices.put(new float[]
{
0, 0,
5, 0,
5, 5,
0, 5
});
vertices.rewind();
vboVertexID = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboVertexID);
glBufferData(GL_ARRAY_BUFFER, vertices, GL_STATIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
}
DRAWING PARTICLES:
public void renderGL() {
glClear(GL_COLOR_BUFFER_BIT);
// Bind the vertex buffer
glBindBuffer(GL_ARRAY_BUFFER, vboVertexID);
glVertexPointer(2, GL_FLOAT, 0, 0);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
for(int i = 0;i < particles.size();i++){
particles.get(i).render();
}
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
}
public void render(){
glBindBuffer(GL_ARRAY_BUFFER, vboVertexID);
glVertexPointer(2, GL_FLOAT, 0, 0);
GL11.glTranslatef(x, y, 0);
glDrawArrays(GL_QUADS, 0, 4);
GL11.glTranslatef(-x, -y, 0);
}
I am clearly doing something wrong, please help me.