Results 1 to 6 of 6

Thread: change display for 10 seconds

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2009
    Posts
    13

    change display for 10 seconds

    hi, im wondering how i can change something in the display, and make that change for 10 seconds, then go back to the default.

    i thought this would work, but it doesnt. it just freezes up my computer:

    if ( key == 'b' || key == 'B' )
    {
    top = 0.2;
    sleep(20);
    top = 0.0;
    }

  2. #2
    Senior Member Frequent Contributor scratt's Avatar
    Join Date
    May 2008
    Location
    Thailand
    Posts
    555

    Re: change display for 10 seconds

    What is key? Where is it set? How is it cleared?

    Does it ever get 'b' or 'B' cleared from it after entering your if statement?

    I am assuming what you have is a loop to read the keyboard.

    This is not really OpenGL stuff, and you've really not provided enough info for anyone to help you constructively.

  3. #3
    Junior Member Newbie
    Join Date
    Apr 2009
    Posts
    13

    Re: change display for 10 seconds

    sorry,

    yeah its inside of a keyboard method which is called by
    glutKeyboardFunc( keyboard );

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2009
    Posts
    13

    Re: change display for 10 seconds

    void keyboard( const unsigned char key, const int h, const int v )
    {
    top = 0.0;
    if ( key == 'b' || key == 'B' )
    {
    top = 0.2;
    sleep(20);
    top = 0.0;
    }

  5. #5
    Senior Member OpenGL Guru
    Join Date
    Dec 2000
    Location
    Reutlingen, Germany
    Posts
    2,042

    Re: change display for 10 seconds

    {
    top = 0.2;
    sleep(20);
    top = 0.0;
    }

    This code does not do any rendering. You just set a variable, wait and set it back. You need a bit more complex logic to achieve your goal.

    Jan.
    GLIM - Immediate Mode Emulation for GL3

  6. #6
    Senior Member Regular Contributor
    Join Date
    Mar 2003
    Location
    Los Angeles
    Posts
    374

    Re: change display for 10 seconds

    What you are really asking is how to do animation in OpenGL. In other words, how does one make OpenGL do computations and update the display automatically instead of in response to a key being pressed? In your case you want OpenGL to change the color of an object, count to 10 seconds, then change the color back. This is the same thing as asking OpenGL to rotate a teapot automatically instead of in response to a key being held down on the keyboard. For OpenGL animation (using GLUT) look up glutIdleFunc. For keeping track of when 10 seconds has elapsed see glutGet(GLUT_ELAPSED_TIME).
    Am I doing your homework for you?

Similar Threads

  1. Change context inside a display list
    By Ignasi in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-21-2011, 06:26 AM
  2. change camera view in a display list
    By Mirkowhat in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 01-24-2011, 11:42 AM
  3. Change screen display
    By Nikki Joe in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 01-28-2007, 12:46 AM
  4. Regarding textures on display mode change...
    By uday in forum OpenGL: Advanced Coding
    Replies: 1
    Last Post: 12-11-2003, 06:40 AM
  5. How to change display mode?
    By adun in forum OpenGL: Basic Coding
    Replies: 3
    Last Post: 03-11-2003, 07:46 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