From 89362944b137b773f87c0c7eba7f5fc36bed79bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=91=D1=80=D0=B0=D0=BD=D0=B8=D0=BC=D0=B8=D1=80=20=D0=9A?= =?UTF-8?q?=D0=B0=D1=80=D0=B0=D1=9F=D0=B8=D1=9B?= Date: Tue, 8 Dec 2020 19:11:18 -0800 Subject: [PATCH] GLFW: Use glfwWaitEventsTimeout instead glfwWaitEvents and posting empty events. --- examples/common/entry/entry_glfw.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) diff --git a/examples/common/entry/entry_glfw.cpp b/examples/common/entry/entry_glfw.cpp index 5be0b89b7..9bfc11266 100644 --- a/examples/common/entry/entry_glfw.cpp +++ b/examples/common/entry/entry_glfw.cpp @@ -76,7 +76,7 @@ namespace entry # if ENTRY_CONFIG_USE_WAYLAND wl_egl_window *win_impl = (wl_egl_window*)glfwGetWindowUserPointer(_window); if(win_impl) - { + { glfwSetWindowUserPointer(_window, nullptr); wl_egl_window_destroy(win_impl); } @@ -495,7 +495,7 @@ namespace entry while (NULL != m_windows[0] && !glfwWindowShouldClose(m_windows[0])) { - glfwWaitEvents(); + glfwWaitEventsTimeout(0.016); for (uint32_t ii = 0; ii < ENTRY_CONFIG_MAX_GAMEPADS; ++ii) { @@ -799,13 +799,11 @@ namespace entry const Event* poll() { - glfwPostEmptyEvent(); return s_ctx.m_eventQueue.poll(); } const Event* poll(WindowHandle _handle) { - glfwPostEmptyEvent(); return s_ctx.m_eventQueue.poll(_handle); } @@ -825,7 +823,6 @@ namespace entry msg->m_title = _title; msg->m_handle.idx = s_ctx.m_windowAlloc.alloc(); s_ctx.m_msgs.push(msg); - glfwPostEmptyEvent(); return msg->m_handle; } @@ -834,7 +831,6 @@ namespace entry Msg* msg = new Msg(GLFW_WINDOW_DESTROY); msg->m_handle = _handle; s_ctx.m_msgs.push(msg); - glfwPostEmptyEvent(); } void setWindowPos(WindowHandle _handle, int32_t _x, int32_t _y) @@ -844,7 +840,6 @@ namespace entry msg->m_y = _y; msg->m_handle = _handle; s_ctx.m_msgs.push(msg); - glfwPostEmptyEvent(); } void setWindowSize(WindowHandle _handle, uint32_t _width, uint32_t _height) @@ -854,7 +849,6 @@ namespace entry msg->m_height = _height; msg->m_handle = _handle; s_ctx.m_msgs.push(msg); - glfwPostEmptyEvent(); } void setWindowTitle(WindowHandle _handle, const char* _title) @@ -863,7 +857,6 @@ namespace entry msg->m_title = _title; msg->m_handle = _handle; s_ctx.m_msgs.push(msg); - glfwPostEmptyEvent(); } void setWindowFlags(WindowHandle _handle, uint32_t _flags, bool _enabled) @@ -876,7 +869,6 @@ namespace entry Msg* msg = new Msg(GLFW_WINDOW_TOGGLE_FULL_SCREEN); msg->m_handle = _handle; s_ctx.m_msgs.push(msg); - glfwPostEmptyEvent(); } void setMouseLock(WindowHandle _handle, bool _lock) @@ -885,7 +877,6 @@ namespace entry msg->m_value = _lock; msg->m_handle = _handle; s_ctx.m_msgs.push(msg); - glfwPostEmptyEvent(); } int32_t MainThreadEntry::threadFunc(bx::Thread* _thread, void* _userData) @@ -899,7 +890,6 @@ namespace entry Msg* msg = new Msg(GLFW_WINDOW_DESTROY); msg->m_handle.idx = 0; s_ctx.m_msgs.push(msg); - glfwPostEmptyEvent(); return result; }