Commit Graph

11 Commits

Author SHA1 Message Date
Jonas Kulla 58bd60a70f Graphics: Attempt to provide more consistent frame timings
We now actively track how far behind / in front of an
ideal timestep we are during each frame, and try to
catch up / delay approximate this timing.

Therefore we use more precise timers and sleep functions
(nanosleep if available). We also delay **before** the
final buffer swap so the frame displays at more consistent
points in time.

Not only should this provide a somewhat more consistent
looking map scrolling at lower frame rates, it also
guarantees that we don't fall out of sync eg. with the
Audio during longer cutscenes.

'Graphics.frameReset()' now finally has a function, in
that it resets the ideal timestep approximation, which I
beliefe was also its job in the original RMXP engine.

I'm not sure how well this will work when the frame rate
is set to the monitor refresh rate and vsync is turned on.
Very likely unnecessary frame skips will occur here and there
due to imprecise timers. In the future we should probably
check if the frame rate is equal to or higher than the
monitor rate, and disable frame skip accordingly.

These changes currently break the F2 FPS display (it shows
a value that's slightly too high).
2013-10-22 17:05:46 +02:00
Jonas Kulla 39436ad231 Fix up SDL2 include paths
Using "SDL2/SDL_xxx.h" instead of "SDL_xxx.h" caused
the include paths provided by pkg-config to be ignored,
and headers from a standard include path to be used instead.
2013-10-13 23:21:34 +02:00
Jonas Kulla cb6f73f7df Rename 'GlobalState' to 'SharedState' to avoid confusion with GLState
This was particularly nasty with the shorthand macros
'gState' and 'glState'. The former is now 'shState'.
2013-10-09 12:30:33 +02:00
Jonas Kulla 26843f2e51 Implement FPS display (F2 to toggle ON/OFF) 2013-10-06 07:05:01 +02:00
Jonas Kulla 35521c25c0 Don't hide cursor when window isn't focused 2013-09-25 20:35:00 +02:00
Jonas Kulla fe557bca1d Implement "show_cursor" attribute in Graphics module
If false (the default), the system cursor is hidden
inside the game window.
2013-09-24 22:56:25 +02:00
Jonas Kulla 6f711184ac Spacing 2013-09-09 21:32:34 +02:00
Jonas Kulla 39233a036b Rename constant 2013-09-09 21:23:56 +02:00
Jonas Kulla a66b15bd08 Pack REQUEST event codes into enum 2013-09-09 21:22:31 +02:00
Jonas Kulla a75dea3ffe Rename 'resetInput' to 'resetInputStates' 2013-09-04 13:28:05 +02:00
Jonas Kulla ff25887f41 Initial commit 2013-09-01 16:27:21 +02:00