Results 1 to 2 of 2

Thread: Do I need a new thread?

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2003
    Posts
    23

    Do I need a new thread?

    Hi,
    I am trying to write my first OpenGL app - a falling blocks tetris style game (using glut). I want the blocks to periodically descend the screen as the player positions them. What is the best way in OpenGl to perform this periodic adjustment?
    Thanks,
    Ben

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Jun 2000
    Location
    Gastonia, NC, USA
    Posts
    2,068

    Re: Do I need a new thread?

    This part is not a function of openGL, but of how you structure the program.

    Since you are using GLUT, I would use one of the GLUT timer functions.

    // Call in your startup code
    glutTimerFunc( 10, TimeEvent, 1); // Ourtime event

    static void TimeEvent(int te)
    {
    // animation and objects that are moving without user intervention.

    My_falling_blocks_que(); // Call routine to see if a block needs to start falling.

    My_falling_blocks_update(); // Call to update current falling blocks.

    glutPostRedisplay(); // Update screen with new falling blocks locations.
    glutTimerFunc( 100, TimeEvent, 1); // Reset our timmer, so that it is called again in 100ms.
    }

    void display(void)
    {


    Draw_blocks();
    }

    [This message has been edited by nexusone (edited 03-02-2004).]

    [This message has been edited by nexusone (edited 03-02-2004).]

Similar Threads

  1. SwapBuffers() in another thread
    By MalcolmB in forum OpenGL: Advanced Coding
    Replies: 10
    Last Post: 07-16-2013, 11:07 AM
  2. glutPostRedisplay() in another thread?
    By Shahzad in forum OpenGL: General
    Replies: 4
    Last Post: 09-18-2009, 02:13 PM
  3. do I need to render on a second thread?
    By mcsellski in forum OpenGL: Advanced Coding
    Replies: 3
    Last Post: 03-05-2005, 04:18 AM
  4. Yet another batching thread
    By SeskaPeel in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 11-09-2004, 07:38 AM
  5. is it possible to specify a thread for HRC? (WIN32)
    By Super13 in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 12-13-2003, 02:34 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