Advertisement

Function Pointers within Classes

Started by September 23, 2000 10:09 PM
12 comments, last by Cel 24 years, 3 months ago
So are you calling a RenderFuncptr() for each particle in your system?
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
In relation to Mikes code I would be using Render() which in turn calls the pRender instance of a RenderFuncPtr()

Obviously my code is different but I am going to adapt what I have now (function pointers with functions being static members)to use his method.

Cel
Cel aka Razehttp://chopper2k.qgl.org
Advertisement
um oh yeh but basically yes I am calling a render function pointer for each particle.

Its faster than how I had it before, with a conditional loop to check what sort of particle it is.

Cel
Cel aka Razehttp://chopper2k.qgl.org
Magmai:

For particle systems, you''re right, the most efficient method is to seperate all the types into their own arrays and render a type at a time. However, do you have performance data to clarify the gain achieved by this method? Particle systems are one of the few areas that I think this optimization is worth it -- ie, when you have thousands or tens of thousands of particles floating around.

For a general-case, particularily in an OOP game engine, virtual funcs or function pointers for draw/move/etc is the way to go IMHO.

This topic is closed to new replies.

Advertisement