Resource Managment

I’ve run into a “performance” related problem, but I believe it’s more of a technique issue than anything else. My game programming experience is limited to non-existant so I have a question relating to some general methodology in resource management.



Here is the scenario:



I want to have a “blast” effect triggered whenever a projectile comes into contact with a surface. I have this effect working, and I’ve tried both a ParticleSystem and a Quad with a texture. Both have caused a hiccup in fps. I think it is related to the fact that, in an effort to remain object oriented, I have created a Blast class that creates its own texture states, particle manager, alpha states, etc. I think the slowdown is because of this somewhat large overhead for each blast effect.



My question is this: how do you guys manage a somewhat complex, but frequent effects like this?



These are my ideas:


  1. I have tried to create a ResourcePool class that will hold the states, textures, and sounds that will be used over and over again so that the only thing that needs to be created is the quad/system (I can apply these “global” states to the object). This didn’t seem to help much, but there is some more work I can do before I give up on this.


  2. Have some type of array of pre-set blasts that are either active or not. A rolling index would keep track of which blast to activate. For a blast, just update the location at that index and activate. This limits the number of on-screen blasts to the size of my array. I don’t really like this idea, but it seems like it might be fast.



    Do you guys have any others? Am I missing an easier way?



    Thanks in advance.

how can 4 vertices of a quad cause a hickup?



Particle systems are used most of the time, but the particle number is small (10 - 20 perhaps). But your use of them depends on the type of blast your looking for.



If its a bullet, then a simple 5 particle ParticleSystem is sufficient. If its a missile, then your better off with your own textured quad stuff.



What your looking for is considered IMO, microscopic parts of a game, so its removal (if its a bullet) isn’t a big no no.



Hope that helps.

DP

The quad itself is not causing the hiccup. I believe it is the instantiation of the ‘Blast’ (with all of it’s texture states and such) that is causing it. We’re also talking about a hiccup less than a tenth of a second, but it is noticeable.



I will try scaling back the number of particles and see if that helps.



Thanks.

Object creation can be somewhat expensive, especially when reading in images and sending textures to opengl for the first time. Try reusing one Texture object every time just as a test to see if that’s where the hiccup lies (test after it has been used at least once.)