| 86 | } |
| 87 | |
| 88 | void RaceNetRenderer::RescaleUI(){ |
| 89 | if(ImGui::IsAnyItemActive()) return; |
| 90 | |
| 91 | // Get mouse movement and compute new projection matrix with it |
| 92 | static float prevZoomLevel = ImGui::GetIO().MouseWheel * 4.0f; |
| 93 | float currentZoomLevel = ImGui::GetIO().MouseWheel * 4.0f; |
| 94 | |
| 95 | // If panning, update projection matrix |
| 96 | if (ImGui::GetIO().MouseDown[0]) { |
| 97 | float xChange = ImGui::GetIO().MouseDelta.x; |
| 98 | float yChange = ImGui::GetIO().MouseDelta.y; |
| 99 | |
| 100 | minX -= xChange*0.5f; |
| 101 | maxX -= xChange*0.5f; |
| 102 | minY -= yChange*0.5f; |
| 103 | maxY -= yChange*0.5f; |
| 104 | |
| 105 | projectionMatrix = glm::ortho(minX, maxX, minY, maxY, -1.0f, 1.0f); |
| 106 | } |
| 107 | |
| 108 | // If scrolling, update projection matrix |
| 109 | if(prevZoomLevel != currentZoomLevel){ |
| 110 | prevZoomLevel = currentZoomLevel; |
| 111 | |
| 112 | minX += currentZoomLevel; |
| 113 | maxX -= currentZoomLevel; |
| 114 | minY -= (currentZoomLevel * 0.5625f); |
| 115 | maxY += (currentZoomLevel * 0.5625f); |
| 116 | |
| 117 | projectionMatrix = glm::ortho(minX, maxX, minY, maxY, -1.0f, 1.0f); |
| 118 | } |
| 119 | } |
| 120 | |
| 121 | RaceNetRenderer::~RaceNetRenderer() { |
| 122 | ImGui_ImplOpenGL3_Shutdown(); |
nothing calls this directly
no outgoing calls
no test coverage detected