• Advertisement
Sign in to follow this  

How good are SDL event timestamps?

This topic is 566 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm currently using SDL contrary to specification and collecting events "asynchronously" on the main thread and rendering with OpenGL (vsync) in another thread. It seems to work fine. It may be internally that SDL is still blocking input collection on vsync, but it allows me to decouple input from rendering at least code-wise. Assuming input really is asynchronous, are SDL timestamps good enough to be used in a case such as this?:

 

http://www.gamedev.net/page/resources/_/technical/general-programming/asynchronous-keyboard-input-for-fixed-time-step-games-r3959

 

or should I be doing my own time-stamping?

Share this post


Link to post
Share on other sites
Advertisement

My understanding is that SDL events all use SDL_GetTicks, which is millisecond accurate, and which is only calculated at the point where the event loop receives the event. Millisecond precision is probably enough for most purposes, although whether the system actually has 1 millisecond resolution, I don't know. (But I doubt it.)

 

'Asynchronous' is a pretty vague term but I doubt it's relevant here.

Share this post


Link to post
Share on other sites

i use "asynchronous" in two senses:

 

1. the input thread is waiting on events (SDL_WaitEvent) instead of pumping at a fixed frequency

2. the input thread sends commands to the renderer via an asynchronous channel (since I"m using OpenGL i guess this is kind of like simulating multi-threaded rendering via command buffers)

 

#2. ensure that when the renderer is waiting on VSync, input processing still happens. #1. maybe isn't necessary if events received from SDL are already properly timestamped

Edited by PrestoChung

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement