MCPcopy Create free account
hub / github.com/KhronosGroup/Vulkan-Samples / handle_mouse_move

Method handle_mouse_move

framework/api_vulkan_sample.cpp:351–392  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

349}
350
351void ApiVulkanSample::handle_mouse_move(int32_t x, int32_t y)
352{
353 int32_t dx = static_cast<int32_t>(mouse_pos.x) - x;
354 int32_t dy = static_cast<int32_t>(mouse_pos.y) - y;
355
356 bool handled = false;
357
358 if (has_gui())
359 {
360 ImGuiIO &io = ImGui::GetIO();
361 handled = io.WantCaptureMouse;
362 }
363 mouse_moved(static_cast<float>(x), static_cast<float>(y), handled);
364
365 if (handled)
366 {
367 mouse_pos = glm::vec2(static_cast<float>(x), static_cast<float>(y));
368 return;
369 }
370
371 if (mouse_buttons.left)
372 {
373 rotation.x += dy * 1.25f * rotation_speed;
374 rotation.y -= dx * 1.25f * rotation_speed;
375 camera.rotate(glm::vec3(dy * camera.rotation_speed, -dx * camera.rotation_speed, 0.0f));
376 view_updated = true;
377 }
378 if (mouse_buttons.right)
379 {
380 zoom += dy * .005f * zoom_speed;
381 camera.translate(glm::vec3(-0.0f, 0.0f, dy * .005f * zoom_speed));
382 view_updated = true;
383 }
384 if (mouse_buttons.middle)
385 {
386 camera_pos.x -= dx * 0.01f;
387 camera_pos.y -= dy * 0.01f;
388 camera.translate(glm::vec3(-dx * 0.01f, -dy * 0.01f, 0.0f));
389 view_updated = true;
390 }
391 mouse_pos = glm::vec2(static_cast<float>(x), static_cast<float>(y));
392}
393
394void ApiVulkanSample::mouse_moved(double x, double y, bool &handled)
395{}

Callers

nothing calls this directly

Calls 2

rotateMethod · 0.80
translateMethod · 0.80

Tested by

no test coverage detected