View Full Version : Demo structure
03-25-2001, 08:03 AM
I have learnt a bit about OpenGL now and I want to make a demo to show my friends what I am able to do.
But I do not know what is the best (the best doesn't exist here, it should be "a good") structure for a demo.
I can make 1 big render function that does if (time > 291) ... for the whole demo, or I could make different sub-render functions. This does make it a little more readable, but it's basically the same thing as 1 big render function.
Are there any other (better) ways to do this?
03-25-2001, 08:15 AM
I've done it like this:
you have one main-render function called on an idle-event (glutIdleFunc or something else...).
in this function a timer-variable is calculated (easiest: iTimer++; http://www.opengl.org/discussion_boards/ubb/smile.gif or by retrieving timer-ticks or so from the system, thats good if you want, that your demo run's at the same speed on different systems...). then, a variable exists, which holds the number of the scene I want to draw. the main render functionb calls some sub-functions and give the timer to them. the sub-function returns with "0" if the scene isn't finished and with "1" if finished, and then the next scene is processed. some examplecode
case 0: b=scene_no1(timer);
if (b==1) scene++;
case 1: .
.and so on..
int scene_no1(int timer)
//bla...render stuff here
if (scene_is_finished==true) return 1; else return 0;
hope this helps a bit. It makes your code more readable, and is MUCH better for debugging... http://www.opengl.org/discussion_boards/ubb/smile.gif believe me ;> it could save a lot of time...
03-25-2001, 10:22 AM
What I had in mind was something like this:
A main render function, which is called every frame which calls sub-render functions.
if (time >= 10 && time < 20)
if (time >= 20 && time < 30)
03-27-2001, 04:40 AM
Thats nearly similar to my description. the better thing in my system is, that every scene tells the main function when it's finished...
Powered by vBulletin® Version 4.2.3 Copyright © 2017 vBulletin Solutions, Inc. All rights reserved.