View Full Version : basic scene changing
12-26-2003, 08:17 PM
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! http://www.opengl.org/discussion_boards/ubb/frown.gif
- Thanks in advance~
12-26-2003, 11:12 PM
That's best done with a finite state machine, that goes something like this (bit of Pascal, but should be easy to read http://www.opengl.org/discussion_boards/ubb/wink.gif ) :
StateFirstScene = $01;
StateSecondScene = $02;
CurrentState : Word;
case CurrentState of
StateFirstScene : DrawFirstScene;
StateSecondScene : DrawSecondScene;
At least that's the most obivious and easiest way to show two totally different scenes in one app.
12-26-2003, 11:24 PM
What PanzerSchreck said http://www.opengl.org/discussion_boards/ubb/smile.gif
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
//still playing ...
//free scene 0's data
//transition to scene 1
12-27-2003, 04:38 AM
There are many way's in which you can do this, all require some type of timmer to tell when to change scenes.
1. Using diffrent routines:
if (time <= 1 ) draw_scene_1();
if (time > 1 ) draw_scene_2();
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.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.