First of all, no offense but if your game requires the video to
run at
a precise refresh rate to work correctly, then your game is
broken.
Not to mention SDL has no way to know if vertical retrace sync is
used
or not (much less select it manually from code), so you really
shouldn’t depend on the refresh rate for anything.
No offense taken. However, I do not think that a game being locked
to a refresh rate is as broken as you are implying. I intend to make
a high-speed racing game where response time and timing are
critical. As such, it would be bad for a frame to be displayed twice
in a row, for example, or any other imprecision in timing that makes
the animation less smooth.
That’s exactly why you should make sure the rendering loop is locked
to the refresh rate (by means of retrace sync) if at all possible.
Now, what do you do if you can’t reliably/safely select a refresh
rate? What do you do if you’re not on a hard real time OS with an
oversized 3D accelerator?
You have the game logic adapt to whatever refresh rate you get - one
way or another.
[…]
Linear interpolation of positions between the physics steps for
rendering could be used, but I think that is more complicated and
less elegant of a solution than just setting a refresh rate and
having everything “just work.”
The bad news is that it won’t Just Work™, unless you’re on custom
hardware, or somehow can rely on having full control over the display
hardware. On personal computers, you shouldn’t even try it, as, if
if/when it actually works, it’s more likely to cause trouble than
solve your problem. (See other posts on monitors with limited refresh
rate support, users not being able to/wanting to use low refresh
rates etc.)
Interpolation isn’t particularly hard to do, it has minimal impact on
game logic CPU usage with high rendering frame rate, it delivers
smooth animation, and it works. If your game logic is too heavy,
too sensitive (replays and the like) or doesn’t lend itself very well
to variable timing, interpolation is the second best solution.
If I understand correctly, it is very
common on consoles to go in lock step with the screen refresh.
Yes, and that’s how it was usually done on arcade machines and the
C64, Amiga etc back in the good old days.
However, all of those systems have/had integrated and/or fixed refresh
rate display hardware, so the refresh rate was fixed and well known.
(Well, almost. Noticed that some games are smooth in the NTSC version
but not in the PAL version, or vice versa? Lazy conversions from one
system to the other…)
To answer your question, sadly there is no mechanism to select
video mode. My guess is it’s one of those "will be in 1.3"
features but I’m no SDL developper.
That is unfortunate, because I believe that setting the refresh rate
is an important function.
It’s an easy way out, that only works for some end users, and it’s not
even possible to do on some platforms and backends.
60 Hz is way too low for most CRT users (stroboscope), whereas many
LCDs won’t go any higher than 60 Hz. CRTs, LCDs and video cards
nearly always have a resolution dependent maximum refresh rate. So,
there’s no safe value that will work everywhere, unless you plan on
supporting only very specific hardware configurations.
//David Olofson - Programmer, Composer, Open Source Advocate
.- Audiality -----------------------------------------------.
| Free/Open Source audio engine for games and multimedia. |
| MIDI, modular synthesis, real time effects, scripting,… |
`-----------------------------------> http://audiality.org -’
— http://olofson.net — http://www.reologica.se —On Wednesday 21 December 2005 21:51, Josiah Manson wrote: