| 120 | } |
| 121 | |
| 122 | void ProfileManager::Flip() |
| 123 | { |
| 124 | // Flip the profiler. |
| 125 | MicroProfileFlip(); |
| 126 | |
| 127 | if (!m_ProfileWindow) |
| 128 | return; |
| 129 | |
| 130 | int width, height; |
| 131 | glfwGetFramebufferSize(m_ProfileWindow, &width, &height); |
| 132 | HDC dc = wglGetCurrentDC(); |
| 133 | HGLRC ctx = wglGetCurrentContext(); |
| 134 | |
| 135 | glfwMakeContextCurrent(m_ProfileWindow); |
| 136 | glClear(GL_COLOR_BUFFER_BIT); |
| 137 | |
| 138 | int nWheelDelta = 0; |
| 139 | vr::VREvent_t VREvent; |
| 140 | while (vr::VROverlay()->PollNextOverlayEvent(m_ProfileOverlay, &VREvent, sizeof(VREvent))) |
| 141 | { |
| 142 | switch (VREvent.eventType) |
| 143 | { |
| 144 | case vr::VREvent_MouseMove: |
| 145 | m_MousePos.v[0] = VREvent.data.mouse.x; |
| 146 | m_MousePos.v[1] = VREvent.data.mouse.y; |
| 147 | MicroProfileMousePosition((uint32_t)m_MousePos.v[0], (uint32_t)m_MousePos.v[1], nWheelDelta); |
| 148 | break; |
| 149 | case vr::VREvent_ScrollDiscrete: |
| 150 | nWheelDelta = int(-VREvent.data.scroll.ydelta * (float)height); |
| 151 | MicroProfileMousePosition((uint32_t)m_MousePos.v[0], (uint32_t)m_MousePos.v[1], nWheelDelta); |
| 152 | break; |
| 153 | case vr::VREvent_MouseButtonDown: |
| 154 | m_MouseButtons |= VREvent.data.mouse.button; |
| 155 | MicroProfileMouseButton(!!(m_MouseButtons & vr::VRMouseButton_Left), !!(m_MouseButtons & vr::VRMouseButton_Right)); |
| 156 | break; |
| 157 | case vr::VREvent_MouseButtonUp: |
| 158 | m_MouseButtons &= ~VREvent.data.mouse.button; |
| 159 | MicroProfileMouseButton(!!(m_MouseButtons & vr::VRMouseButton_Left), !!(m_MouseButtons & vr::VRMouseButton_Right)); |
| 160 | break; |
| 161 | } |
| 162 | } |
| 163 | |
| 164 | MicroProfileRender(width, height, 1.0f); |
| 165 | |
| 166 | if (m_Texture) |
| 167 | { |
| 168 | m_Texture->LockSharedTexture(); |
| 169 | |
| 170 | glBindTexture(GL_TEXTURE_2D, m_Target); |
| 171 | glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, width, height); |
| 172 | |
| 173 | m_Texture->UnlockSharedTexture(); |
| 174 | } |
| 175 | |
| 176 | glfwSwapBuffers(m_ProfileWindow); |
| 177 | glfwPollEvents(); |
| 178 | |
| 179 | if (m_Texture) |
no test coverage detected