| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
…ngineSquared/EngineSquared into 195-support-callbacks-in-input-manager
| inputManager.RegisterCursorPosCallback([&](ES::Engine::Core &cbCore, double xpos, double ypos) { | ||
| auto &dragging = cbCore.GetResource<ES::Plugin::OpenGL::Utils::MouseDragging>(); | ||
| auto &camera = cbCore.GetResource<ES::Plugin::OpenGL::Resource::Camera>(); | ||
|
|
||
| if (ES::Plugin::Input::Utils::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_LEFT)) | ||
| { | ||
| float fractionChangeX = static_cast<float>(xpos - dragging.lastMousePos.x) / camera.size.x; | ||
| float fractionChangeY = static_cast<float>(dragging.lastMousePos.y - ypos) / camera.size.y; | ||
| camera.viewer.rotate(fractionChangeX, fractionChangeY); | ||
| } | ||
| else if (ES::Plugin::Input::Utils::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_MIDDLE)) | ||
| { | ||
| float fractionChangeY = static_cast<float>(dragging.lastMousePos.y - ypos) / camera.size.y; | ||
| camera.viewer.zoom(fractionChangeY); | ||
| } | ||
| else if (ES::Plugin::Input::Utils::IsMouseButtonPressed(GLFW_MOUSE_BUTTON_RIGHT)) | ||
| { | ||
| float fractionChangeX = static_cast<float>(xpos - dragging.lastMousePos.x) / camera.size.x; | ||
| float fractionChangeY = static_cast<float>(dragging.lastMousePos.y - ypos) / camera.size.y; | ||
| camera.viewer.translate(-fractionChangeX, -fractionChangeY, true); | ||
| } | ||
|
|
||
| dragging.lastMousePos.x = xpos; | ||
| dragging.lastMousePos.y = ypos; | ||
| }); |
There was a problem hiding this comment.
Perhaps you could use an array of function pointers or simply split each conditions into a single callback to reduce the lambda length?
Sorry, something went wrong.
There was a problem hiding this comment.
or maybe remove the two white spaces, but I'll try that :)
Sorry, something went wrong.
There was a problem hiding this comment.
done
Sorry, something went wrong.
|
Sorry, something went wrong.
Related to: - #195 Used in [RollingBall/use-new-input-plugin](https://github.com/EngineSquared/Rolling-Ball/tree/use-new-input-plugin) Notes: - Explaination about the glfw window user pointer [here](https://discourse.glfw.org/t/what-is-a-possible-use-of-glfwgetwindowuserpointer/1294), this can be useful later - The glfw joystick callback `glfwSetJoystickCallback` (which indicates when a controller (dis)connects) is not supported because of glfw's handling of user data pointers for joysticks (it is handled per joystick and not per window), but joystick operation can be handled through polling. - The `UpdateKey` system has been removed. Why would pressing "escape" always close the window ? --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
| Back | FazBrowse Home | New Git URL |
Related to:
Used in RollingBall/use-new-input-plugin
Notes: