I add rectangles (tried circles too) to arrays and draw them on screen (for bleeding effect) but FPS drops to half after certain amount of rectangles are added and drawn. Why is this happening? Is there any alternative way of doing similar thing?
Every rectangle is one draw call, and each draw call takes (relatively) long to process.
When you have lots of them, your framerate will suffer.
There's 2 ways to go about solving this:
1. Use a spritebatch. It's a buffer which takes a texture. Then you tell it where you want to "put" all the images, and then you render it with only one draw call.
2. Use a particlesystem. This seems to be more fit for your situation. It works similairly to the spritebatch. But instead of telling where you want to put the images, you instead define a "emitter" which spawns them, and define some rules for the transformation.
Tjakka5 wrote: ↑Tue Oct 24, 2017 9:31 pm
Every rectangle is one draw call, and each draw call takes (relatively) long to process.
When you have lots of them, your framerate will suffer.
There's 2 ways to go about solving this:
1. Use a spritebatch. It's a buffer which takes a texture. Then you tell it where you want to "put" all the images, and then you render it with only one draw call.
2. Use a particlesystem. This seems to be more fit for your situation. It works similairly to the spritebatch. But instead of telling where you want to put the images, you instead define a "emitter" which spawns them, and define some rules for the transformation.