mocha-engine / mocha

Mocha: A work-in-progress 3D game engine
GNU Lesser General Public License v3.0
53 stars 7 forks source link

Moving game window to another window causes crash #13

Closed peter-r-g closed 1 year ago

peter-r-g commented 1 year ago

When moving the main game window of Mocha to another monitor it causes a crash with the error: Expression: 0 && "Code uses SetCursorPos()/SetCursorScreenPos() to extend window/parent boundaries." https://user-images.githubusercontent.com/11802285/211881397-813127fd-5767-4174-8d1a-14f9ad4333ac.mp4

xezno commented 1 year ago

Thanks for this - wasn't aware it was an issue as my main/default monitor is the one on the left.. so my window coordinates never become negative (unless I move the window off-screen).

This was caused by a breaking change in ImGui v1.89 - see here: https://github.com/ocornut/imgui/releases/tag/v1.89#:~:text=Instead%2C%20please-,submit%20an%20item,-%3A%0ABegin(...). Since we're getting the position of the main viewport and then moving the cursor based on that, the cursor position becomes negative when moving to the left of the default Windows monitor (eg. on dual-monitor setups where the main monitor is the one on the right).