I’m pretty new to OpenGL, but I’ve gone through most of NeHe’s tutorials. I am attempting to work on my first project, and I had a question.
For example: I want to make a short movie that is composed of two scenes. The first scene shows the title of the movie, and the second scene shows a rotating cube.
Is there a tutorial that explains how to do this? I know how to do the different things in 2 separate executables, but what is the standard procedure for doing something like that in 1?
Do I set up each ‘scene’ in it’s own function and call them according to a certain counter? Confusion!
I just wanted to add that you must of course provide for some transition between states. Eg if your “intro” is supposed to play for ten seconds, you must change the state when it has finished playing.
I usually tackle this by making scene rendering functions return a boolean that indicates whether they are finished or not.
“Main loop” code would look something like this
switch (current_scene)
{
case(0):
if (render_scene_0())
{
//still playing ...
}
else
{
//finished
//free scene 0's data
//transition to scene 1
current_scene=1;
}
break;
case(1):
if (render_scene_1())
.
.
.
break;
}
There are many way’s in which you can do this, all require some type of timmer to tell when to change scenes.
Using diffrent routines:
void display(void)
{
if (time <= 1 ) draw_scene_1();
if (time > 1 ) draw_scene_2();
}
You can also create a simple script in which to tell your program what to display at what time in the program. And track some type of frame or time variable.