Thread: A quick GLUT question

  1. #1
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426

    A quick GLUT question

    I'm getting into GL/GLUT now - I've been using SDL and Allegro for a while and I thought "hey, why not make my own game engine?" I know what you're thinking... what a tool, why doesn't he just stick with SDL. Well, it's a learning experience, ok? So don't give me any lip about that.

    But I did have a question concerning something I found I could do easily in SDL, and that is giving me some difficulty right now. I'm trying to get the window to update and redraw every 60 frames per second (or every vsync, at least). How does one go about doing that within glutMainLoop()?
    Consider this post signed

  2. #2
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    I'd have to double check to be sure, but I thought you just registered a draw function and that got called every go-round of the mainLoop.

  3. #3
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    There's the display callback but that is only called when the window manager says the screen needs to be redrawn, like on a resize or when you move the window. And the idle callback is called every go-round but I'm looking for a smooth framerate and not let's-go-as-fast-as-we-can. Snake would be a very difficult game to play at 400 fps.
    Consider this post signed

  4. #4
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Some searching led to the manual here which suggests glutTimerFunc.

    (EDIT: I suppose I should say I suggest glutTimerFunc, since the manual isn't necessarily suggesting anything.)
    Last edited by tabstop; 05-17-2010 at 04:35 PM.

  5. #5
    Just a pushpin. bernt's Avatar
    Join Date
    May 2009
    Posts
    426
    Oh, neat, thanks.

    So I'll call a glutPostRedisplay in the timer and set the timer again to 1000/60.
    Or rather set the timer first, then call for a redisplay.
    Consider this post signed

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Very quick math question
    By jverkoey in forum A Brief History of Cprogramming.com
    Replies: 8
    Last Post: 10-26-2005, 11:05 PM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 03:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 04:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 11:04 AM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 05:46 PM