How to design my program


I’m starting with OPENGL but I got experience with c++. I understand well how coding objects in OPENGL but I’m confused on how to design my OPENGL program. Basically, I would like to create an animation as a movie, with no input interaction (keyboard, mouse) from the viewer, but only scenes drawn as a function of the time elapsed.

I’m using GLUT and what confuse me is that in all examples I saw, there is always only one scene to draw which is called by the function glutDisplayFunc. You can make rotation or translation operations on this scene but you can’t switch between different scenes. For example, let say an animation which consist of a person (or a camera) entering into a home and moving from one room to another. It doesn’t seem optimal to have a unique function called by glutDisplayFunc to describe the whole home, (the kitchen, bedrooms …) because it will take huge resources to render the scene. It seems to me more logical to create multiple scenes to describe each room of the home and then call the appropriate scene when the person (camera) is entering to a specific room. How can I decide to render the scene “kitchen” with glutDisplayFunc at the time t for example?

A simpler example could be like this: let say I’ve a scene which is static for a period of time and then, at time t, I decide to make appear an object. How should I design my code for doing this?

Thank you very much for your help

Often engines are event driven and you can use real time clock as a source of a time based event or perhaps a scripting language to generate events in response to a timer or time based event.
You say you can’t switch between scenes but it really depends upon how you separate different parts of the scene. Perhaps a scenegraph could help you or a partitioning scene manager to break up a large complex scene into smaller chunks to make rendering more efficient.

See NeHe Tutorial #4