[SDL] Input latency in OpenGL?

Sami Näätänen sn.ml at bayminer.com
Sat Jan 19 05:47:18 PST 2008


On Saturday 19 January 2008, Iori Branford wrote:
> I've found something that helps: disabling vsync.
>
> The next problem, then, is how to do something during the vsync
> waiting period.

Your problem then might be that you are not handling all the events that 
have happened this far, before you start to draw your scene.

You should have something like this:
Event loop taken from SDL Wiki->SDL_PollEvent

SDL_Event event; /* Event structure */

while(game_running) {
/* Check for events */
while(SDL_PollEvent(&event)) {  /* Loop until there are no events left 
on the queue */
  switch(event.type) { /* Process the appropiate event type */
    case SDL_KEYDOWN:  /* Handle a KEYDOWN event */
      printf("Oh! Key press\n");
      break;
    case SDL_MOUSEMOTION:
      .
      .
      .
    default: /* Report an unhandled event */
      printf("I don't know what this event is!\n");
  }
}
// Update positions etc according to the events that have been handled
// Draw next frame
// Swap buffers to show the new graphics
}


More information about the SDL mailing list