Move event polling to after framedraw only
Jeffrey Pfau jeffrey@endrift.com
Sat, 04 May 2013 14:49:04 -0700
1 files changed,
13 insertions(+),
12 deletions(-)
jump to
M
src/main.c
→
src/main.c
@@ -127,6 +127,19 @@ glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 256, 256, 0, GL_RGBA, GL_UNSIGNED_BYTE, renderer->d.outputBuffer);
glDrawArrays(GL_TRIANGLE_FAN, 0, 4); SDL_GL_SwapBuffers(); + + while (SDL_PollEvent(&event)) { + switch (event.type) { + case SDL_QUIT: + // FIXME: this isn't thread-safe + context->debugger->state = DEBUGGER_EXITING; + break; + case SDL_KEYDOWN: + case SDL_KEYUP: + _GBASDLHandleKeypress(context, &event.key); + break; + } + } pthread_mutex_lock(&renderer->d.mutex); pthread_cond_broadcast(&renderer->d.downCond); pthread_mutex_unlock(&renderer->d.mutex);@@ -143,18 +156,6 @@ break;
} } pthread_mutex_unlock(&renderer->d.mutex); - } - while (SDL_PollEvent(&event)) { - switch (event.type) { - case SDL_QUIT: - // FIXME: this isn't thread-safe - context->debugger->state = DEBUGGER_EXITING; - break; - case SDL_KEYDOWN: - case SDL_KEYUP: - _GBASDLHandleKeypress(context, &event.key); - break; - } } } }