Перекрывающиеся кадры при использовании XB для создания окон и обработки событий. ⇐ C++
-
Anonymous
Перекрывающиеся кадры при использовании XB для создания окон и обработки событий.
I working on my game engine with both support of Windows and Linux. And for Linux i added support for Xlib and XCB libraries that help me to create window and handling events in it. With Xlib all working good, but when i turn off vsync in XCB and geting mush FPS this causing problems with overlapping frames. After overlaped frames i get sequence of events. This cause input lags on mouse movement (only for mouse, keyboard inputs is ok). I realized that problem is gone when i turn off screen capture in obs (i always streaming my development).
bool WindowXCBOpengl::HandleEvent([[maybe_unused]] CEvent& _Event) { xcb_generic_event_t* generic_event; while ((generic_event = xcb_poll_for_event (connection))) { switch (generic_event->response_type & ~0x80) { case XCB_EXPOSE: { xcb_expose_event_t *expose_event = (xcb_expose_event_t *)generic_event; break; } case XCB_BUTTON_PRESS: { xcb_button_press_event_t *expose_event = (xcb_button_press_event_t *)generic_event; switch (expose_event->detail) { case 1: _Event.SetEvent(EEvents::eMOUSE_LEFT_BUTTON); break; case 3: _Event.SetEvent(EEvents::eMOUSE_RIGHT_BUTTON); This is how i handling events in XCB
bool WindowXOpengl::HandleEvent(CEvent& _Event) { XEvent uXEvent; while(XPending(pDisp_)) { XNextEvent(pDisp_, &uXEvent); KeySym ulKey; unsigned int uiMouse_Button; XMotionEvent motion; switch(uXEvent.type) { case MotionNotify: ///< With structure "motion" we can get position of mouse pointer and e.c. motion = uXEvent.xmotion; _Event.SetEvent(EEvents::eMOUSE_POINTER_POSITION); _Event.mousePointerPosition.position_X = motion.x; _Event.mousePointerPosition.position_Y = motion.y; This is how i handling events in Xlib.
XCB documentation said that my XCB-code preaty the same as Xlib-code. But i get different results. As i said i get input lags in mouse movements. link to XCB docs page: https://xcb.freedesktop.org/tutorial/events/
Non-blocking handling in Xlib looks like this:
while (XPending (display)) { XEvent event; XNextEvent(display, &event); /* ...handle the event */ } The equivalent in XCB looks like:
xcb_generic_event_t *event; while ( (event = xcb_poll_for_event (connection, 0)) ) { /* ...handle the event */ }
Источник: https://stackoverflow.com/questions/781 ... s-handling
I working on my game engine with both support of Windows and Linux. And for Linux i added support for Xlib and XCB libraries that help me to create window and handling events in it. With Xlib all working good, but when i turn off vsync in XCB and geting mush FPS this causing problems with overlapping frames. After overlaped frames i get sequence of events. This cause input lags on mouse movement (only for mouse, keyboard inputs is ok). I realized that problem is gone when i turn off screen capture in obs (i always streaming my development).
bool WindowXCBOpengl::HandleEvent([[maybe_unused]] CEvent& _Event) { xcb_generic_event_t* generic_event; while ((generic_event = xcb_poll_for_event (connection))) { switch (generic_event->response_type & ~0x80) { case XCB_EXPOSE: { xcb_expose_event_t *expose_event = (xcb_expose_event_t *)generic_event; break; } case XCB_BUTTON_PRESS: { xcb_button_press_event_t *expose_event = (xcb_button_press_event_t *)generic_event; switch (expose_event->detail) { case 1: _Event.SetEvent(EEvents::eMOUSE_LEFT_BUTTON); break; case 3: _Event.SetEvent(EEvents::eMOUSE_RIGHT_BUTTON); This is how i handling events in XCB
bool WindowXOpengl::HandleEvent(CEvent& _Event) { XEvent uXEvent; while(XPending(pDisp_)) { XNextEvent(pDisp_, &uXEvent); KeySym ulKey; unsigned int uiMouse_Button; XMotionEvent motion; switch(uXEvent.type) { case MotionNotify: ///< With structure "motion" we can get position of mouse pointer and e.c. motion = uXEvent.xmotion; _Event.SetEvent(EEvents::eMOUSE_POINTER_POSITION); _Event.mousePointerPosition.position_X = motion.x; _Event.mousePointerPosition.position_Y = motion.y; This is how i handling events in Xlib.
XCB documentation said that my XCB-code preaty the same as Xlib-code. But i get different results. As i said i get input lags in mouse movements. link to XCB docs page: https://xcb.freedesktop.org/tutorial/events/
Non-blocking handling in Xlib looks like this:
while (XPending (display)) { XEvent event; XNextEvent(display, &event); /* ...handle the event */ } The equivalent in XCB looks like:
xcb_generic_event_t *event; while ( (event = xcb_poll_for_event (connection, 0)) ) { /* ...handle the event */ }
Источник: https://stackoverflow.com/questions/781 ... s-handling
Мобильная версия