We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2405 - SDL_SetRelativeMouseMode is slow
Summary: SDL_SetRelativeMouseMode is slow
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: 2.0.1
Hardware: x86_64 Windows 8
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-02-19 00:45 UTC by Guillaume Payet
Modified: 2014-02-19 20:43 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Guillaume Payet 2014-02-19 00:45:26 UTC
When I set SDL_SetRelativeMouseMode(SDL_TRUE), The events lag behind (as if the event queue was not processed fast enought or the events take time to be generated).
I removed all kinds of processing in my main loop to test the performance but it still lags.
Also, if I use SDL_PollEvent (instead of SDL_WaitEvent), I keep receiving relative mouse motion events of 1px when I stop moving the mouse (the events sort of "drift").
Comment 1 Gabriel Jacobo 2014-02-19 13:58:29 UTC
Can you show us what your main loop looks like?
Comment 2 Guillaume Payet 2014-02-19 20:33:22 UTC
If I comment out all drawings and processing, the minimal loop where I can still experience lag is:

do
{
    SDL_PollEvent(event);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    glFlush();

    SDL_GL_SwapWindow(SDL_GL_GetCurrentWindow());
}
while (event->type == SDL_KEYDOWN && event->key.keysym.sym == SDLK_ESCAPE);
Comment 3 Gabriel Jacobo 2014-02-19 20:37:37 UTC
You should poll all events until the queue is empty, then run your render code (specially SDL_GL_SwapWindow, since it can get "stuck" waiting for the vertical retrace).
If after making this change you still get laggy behavior, feel free to reopen.
Comment 4 Guillaume Payet 2014-02-19 20:43:35 UTC
It works. Thanks