Windows message loop fixes, added mouse wheel zoom

This commit is contained in:
saschawillems 2016-03-17 20:20:43 +01:00
parent e13f7c6e12
commit af6df4e860

View file

@ -300,7 +300,8 @@ void VulkanExampleBase::renderLoop()
while (TRUE) while (TRUE)
{ {
auto tStart = std::chrono::high_resolution_clock::now(); auto tStart = std::chrono::high_resolution_clock::now();
PeekMessage(&msg, NULL, 0, 0, PM_REMOVE); if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
{
if (msg.message == WM_QUIT) if (msg.message == WM_QUIT)
{ {
break; break;
@ -310,6 +311,7 @@ void VulkanExampleBase::renderLoop()
TranslateMessage(&msg); TranslateMessage(&msg);
DispatchMessage(&msg); DispatchMessage(&msg);
} }
}
render(); render();
frameCounter++; frameCounter++;
auto tEnd = std::chrono::high_resolution_clock::now(); auto tEnd = std::chrono::high_resolution_clock::now();
@ -807,6 +809,13 @@ void VulkanExampleBase::handleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPAR
mousePos.x = (float)LOWORD(lParam); mousePos.x = (float)LOWORD(lParam);
mousePos.y = (float)HIWORD(lParam); mousePos.y = (float)HIWORD(lParam);
break; break;
case WM_MOUSEWHEEL:
{
short wheelDelta = GET_WHEEL_DELTA_WPARAM(wParam);
zoom += (float)wheelDelta * 0.005f * zoomSpeed;
viewChanged();
break;
}
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
if (wParam & MK_RBUTTON) if (wParam & MK_RBUTTON)
{ {