I'm creating a particle simulator using SDL, and I'm rendering rects from a dynamic array/vector. When the simulator reaches 500 particles, I start popping the particles in the vector. at 500 particles, the memory used is at 16 MB. However, SDL is having the worst time trying to render all 500 particles, even though they are 1 pixel in length and width. The framerate goes from 60 fps at 200 particles to 10 fps at 500.
How can I ease the tax on RenderCopy? Here's a snippet:
for (int i = 0; i < DynamicParticles.size(); i++)
{
//make particles fall 1 pixel each frame
DynamicParticles.at(i).Advance();
SDL_RenderCopy(Main_Renderer,
DynamicParticles.at(i).particle_texture,
NULL, &DynamicParticles.at(i).location);
}
Here DynamicParticles
is a vector holding a class Particles
. This class takes up about 15 MB when 500 items are present, and RenderCopy
only takes the texture member and dstrect member.