A quick GLUT question

This is a discussion on A quick GLUT question within the Game Programming forums, part of the General Programming Boards category; I'm getting into GL/GLUT now - I've been using SDL and Allegro for a while and I thought "hey, why ...

  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,185
    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,185
    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 05: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-27-2005, 12:05 AM
  2. very quick question.
    By Unregistered in forum C++ Programming
    Replies: 7
    Last Post: 07-24-2002, 04:48 AM
  3. quick question
    By Unregistered in forum C++ Programming
    Replies: 5
    Last Post: 07-22-2002, 05:44 AM
  4. Quick Question Regarding Pointers
    By charash in forum C++ Programming
    Replies: 4
    Last Post: 05-04-2002, 12:04 PM
  5. Quick question: exit();
    By Cheeze-It in forum C Programming
    Replies: 6
    Last Post: 08-15-2001, 06:46 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21