Main message handler for the sample.
| 114 | |
| 115 | // Main message handler for the sample. |
| 116 | LRESULT CALLBACK Win32Application::WindowProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam) |
| 117 | { |
| 118 | DX12CudaSample *pSample = reinterpret_cast<DX12CudaSample *>(GetWindowLongPtr(hWnd, GWLP_USERDATA)); |
| 119 | |
| 120 | switch (message) { |
| 121 | case WM_CREATE: { |
| 122 | // Save the DXSample* passed in to CreateWindow. |
| 123 | LPCREATESTRUCT pCreateStruct = reinterpret_cast<LPCREATESTRUCT>(lParam); |
| 124 | SetWindowLongPtr(hWnd, GWLP_USERDATA, reinterpret_cast<LONG_PTR>(pCreateStruct->lpCreateParams)); |
| 125 | } |
| 126 | return 0; |
| 127 | |
| 128 | case WM_KEYDOWN: |
| 129 | if (pSample) { |
| 130 | pSample->OnKeyDown(static_cast<UINT8>(wParam)); |
| 131 | } |
| 132 | return 0; |
| 133 | |
| 134 | case WM_KEYUP: |
| 135 | if (pSample) { |
| 136 | pSample->OnKeyUp(static_cast<UINT8>(wParam)); |
| 137 | } |
| 138 | return 0; |
| 139 | |
| 140 | case WM_PAINT: |
| 141 | if (pSample) { |
| 142 | pSample->OnRender(); |
| 143 | } |
| 144 | return 0; |
| 145 | |
| 146 | case WM_DESTROY: |
| 147 | PostQuitMessage(0); |
| 148 | return 0; |
| 149 | } |
| 150 | |
| 151 | // Handle any messages the switch statement didn't. |
| 152 | return DefWindowProc(hWnd, message, wParam, lParam); |
| 153 | } |