Original Post
I have a huge problem I can not solve myself. It appears like event queue is not filled on every SDL_PumpEvents() or SDL_PoolEvent() function call. Keydown events appear on queue about 1 or 2 seconds after key was pressed. Like events were buffered somewhere, but when in main loop program sleeps for a short period of time, for example SDL_Delay(50), everything is OK. Maybe someone could tell me why is that? How can I prevent this? Maybe thread responsible for input gets no time for computations, because it is starved by rendering? How can I force event queue to be filled? I've written simple code in C++ using OpenGL and SDL on linux. Please see here: http://skowron.no-ip.org/kuba/gl/ There is a short source code, Makefile and linux binary. When you run this program one triangle should constantly rotate, and another triangle should rotate on mouse move. Mouse moves and keydowns appears late, unless you add SDL_Delay() in main loop. Thanks.
while( !quit )
{
//do scene rendering
...
SDL_Delay(50); //why?
while( SDL_PollEvent( &event ) )
{
switch( event.type )
{
//manage events
...
}
}
}