OpenGL + Timing

Hello all,
I’m new to SDL and I’ve been through a lot of the tutorials listed on
the tutorial page at libsdl.org. But I’m having issues figuring out
when to handle rendering. Should I use a SDL_AddTimer to add a timer
function or should I use the delay function and render every 30 or so
ms?

Thanks for helping,
Jim Tink

Both of those are valid options, and I think neither have any clear-
cut benefits over the other. Another option you may want to consider
is to have a second string running all the time (in the background) to
process your objects at a constant framerate, and then your rendering
thread either renders as fast as it can (you MAY end up with slightly
choppy movement if your processing thread is significantly slower than
your rendering thread); or you can put in a little extra work and have
the rendering thread interpolate the points between graphical
keyframes when determining where to draw your objects. (Hopefully
that made sense. There’s a really nice article out there that was
written as an argument for this approach and explains it both better
an in more detail than I just did.)

So basically, the choice is up to you. All of the choices end up
being useless if you go to low enough hardware specs, so whatever
works well for being straightforward enough for you (depending on your
experience making games) and working effectively for the game you’re
designing. The separate process thread is most ideal for games where
accurate jumping/timing is key to the experience/challenge of the
game, for instance. But if you’re making a turn-based strategy (or
even possibly a real-time strategy) game, then you may not need the
exact precision gained by doing it such.

– ScottOn Dec 26, 2007, at 12:16 PM, Jim Tink wrote:

Hello all,
I’m new to SDL and I’ve been through a lot of the tutorials listed on
the tutorial page at libsdl.org. But I’m having issues figuring out
when to handle rendering. Should I use a SDL_AddTimer to add a timer
function or should I use the delay function and render every 30 or so
ms?

Thanks for helping,
Jim Tink


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org