Skip to content

Instantly share code, notes, and snippets.

@ThomasParistech
Created September 27, 2023 20:32
Show Gist options
  • Save ThomasParistech/027fbb503a77dd58d45ed40c44a4c1f9 to your computer and use it in GitHub Desktop.
Save ThomasParistech/027fbb503a77dd58d45ed40c44a4c1f9 to your computer and use it in GitHub Desktop.
void scroll_callback(GLFWwindow* window, double xoffset, double yoffset) {
if (yoffset!=0)
camera.zoom(-yoffset);
}
void mouseButton(GLFWwindow* window, int button, int action, int mods) {
ImGuiIO& io = ImGui::GetIO();
if (io.WantCaptureMouse)
return;
mouse_buttons[button] = action;
}
void mouseMotion(GLFWwindow* window, double xpos, double ypos) {
ImGuiIO& io = ImGui::GetIO();
if (io.WantCaptureMouse)
return;
double dxn = (xpos - mouse_x) / window_w;
double dyn = (ypos - mouse_y) / window_h;
mouse_x = xpos;
mouse_y = ypos;
if (mouse_buttons[GLFW_MOUSE_BUTTON_LEFT] == GLFW_PRESS)
camera.rotate(dxn, dyn);
if (mouse_buttons[GLFW_MOUSE_BUTTON_RIGHT] == GLFW_PRESS)
camera.shift_center(dxn, dyn);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment