I am relatively new to OpenGL but it has become clear that the OpenGL framework along with the GLUT package can be useful for me to create realistic microscopic physics visualization (nuclear interactions, molecules, particle physics etc).
I have written a very simple class built on OpenGL and GLUT functions for generalized management of these sorts of animations. There is simply a “particle class,” which contains all rendering information and a “world class” which is more-or-less a container for some number of particles. Each particle or object contains member functions noting how to render itself and the entire vector of particles is rendered by the world. (NB: I am sure something like this already exists but I am creating it not only for its use but also so that I gain experience and I can make it plug into several other physics libraries I have).
Anyway, I have recently completed a simulation beginning with N bodies all which can spawn 2 new bodies (nuclear decay). While I previously had no trouble rendering ~600 individual bodies my rendering now slows down very substantially and I have 2 Ideas why:
1. After the decay there are a 2 more moving bodies which need to be kept track of. These often move out of the viewable area but I believe they are still being computed and rendered. Is there any GL function I can use to test if they are in the visible area before calculating/rendering? 2. Since I want the simulation to be as realistic as possible I end up generating quite a few (3 per body per render) random numbers. I also do several geometric calculations in each render which has a spawning of new objects. Is there a straightforward way to buffer these or some kind of common practice that allows me to calculate them for the NEXT render without affecting the frame rate?
I suspect my simulation is slowed greatly do to these computations.