Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Default message handler ------------------------------------------------------------
- LRESULT CALLBACK WndProc(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
- {
- switch(umessage)
- {
- // Check if the window is being destroyed
- case WM_DESTROY:
- {
- PostQuitMessage(0);
- return 0;
- }
- // Check if the window is being closed
- case WM_CLOSE:
- {
- PostQuitMessage(0);
- return 0;
- }
- // All other messages pass to the message handler in the engine
- default:
- {
- return Engine::Get()->MessageHandler(hwnd, umessage, wparam, lparam);
- }
- }
- }
- // Application message handler --------------------------------------------------------
- LRESULT CALLBACK Engine::MessageHandler(HWND hwnd, UINT umessage, WPARAM wparam, LPARAM lparam)
- {
- switch(umessage)
- {
- case WM_SIZE:
- {
- Float screenWidth, screenHeight;
- bool result;
- // Get the new window dimensions
- screenWidth = LOWORD(lparam);
- screenHeight = HIWORD(lparam);
- // Resize the window and buffers
- result = mWindow.Resize(screenWidth, screenHeight);
- if(!result) { MessageBoxW(hwnd, L"Error resizing the swap chain buffers.", L"An error has occured", MB_OK); PostQuitMessage(0); }
- return 0;
- }
- // Check if a key has been pressed on the keyboard
- case WM_KEYDOWN:
- {
- // If a key is pressed send it to the input object so it can record that state
- //mInput->KeyDown((UInt)wparam);
- return 0;
- }
- // Check if a key has been released on the keyboard
- case WM_KEYUP:
- {
- // If a key is released then send it to the input object so it can unset the state for that key
- //mInput->KeyUp((UInt)wparam);
- return 0;
- }
- // All other messages pass to the default message handler
- default:
- {
- return DefWindowProc(hwnd, umessage, wparam, lparam);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment