Results 1 to 4 of 4

Thread: Demo structure

  1. #1
    Junior Member Newbie
    Join Date
    Feb 2001
    Posts
    5

    Demo structure

    Hi,

    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?

    Thx,
    Steve_

  2. #2
    Member Contributor
    Join Date
    Nov 2000
    Location
    Thuringia, Germany
    Posts
    85

    Re: Demo structure

    Hi steve!

    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++; 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

    int timer=0;
    int scene=0;
    void display()
    {
    int b;
    timer++;
    switch(scene)
    case 0: b=scene_no1(timer);
    if (b==1) scene++;
    break
    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... believe me ;> it could save a lot of time...


    Bastian

  3. #3
    Junior Member Newbie
    Join Date
    Feb 2001
    Posts
    5

    Re: Demo structure

    What I had in mind was something like this:

    A main render function, which is called every frame which calls sub-render functions.

    void main_render()
    {
    if (time >= 10 && time < 20)
    render1();
    if (time >= 20 && time < 30)
    render2();
    ..
    ..
    }

  4. #4
    Member Contributor
    Join Date
    Nov 2000
    Location
    Thuringia, Germany
    Posts
    85

    Re: Demo structure

    Thats nearly similar to my description. the better thing in my system is, that every scene tells the main function when it's finished...

Similar Threads

  1. Can we use structure of structure in opencl?
    By MenkaMore in forum OpenCL
    Replies: 0
    Last Post: 05-11-2014, 06:00 AM
  2. can we use structure in opencl
    By prince in forum OpenCL
    Replies: 10
    Last Post: 12-24-2012, 07:13 PM
  3. multilayered structure
    By melis in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 08-04-2008, 06:54 AM
  4. aux bmp structure
    By Tim Stirling in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 02-23-2001, 11:55 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean