I have written some basic OpenGL applications with XCB as the backend(xlib for GLX, of course) and in every test I have written when I move my mouse over the window it causes all input to get sort of "buffered" and only responds to the events after a period of time(varies depending on how many inputs).
I'm calling xcb_poll_events and getting the event information that way then loading it into a custom event class, but this was never slow on my old xlib implementation.
What could be causing this lag?
The event polling:
Event_c system_class::poll_for_event(){
Event_c temp;
xcb_generic_event_t *event;
event = xcb_poll_for_event(this->connection_xcb);
if(!event)
return temp;
switch(event->response_type){
handle events...
}
free(event);
return temp;
}
and the event loop in the test app:
int main(int argc, char *argv[]){
init stuff...
system_class app;
window_class window;
Event_c event;
while(running){
event = app.poll_for_event();
if(event.detail){
handle user input...
}
window.swap_buffers(); // just calls glXSwapBuffers
}
return 0;
}
Your problem is, that you are calling glXSwapBuffers between two calls of xcb_poll_for_event. Therefore you only can handle one message per screen refresh.
Apart from your multithreading solution you could simply process events until xcb_poll_for_event would return zero. When you are finished with handling all pending events, you could return to rendering.