1 #include<Windows.h> 2 #include<conio.h> 3 #include<memory> 4 5 #include"GameSpriteDemo.h" 6 #include"TriangleDemo.h" 7 8 #include"D3DTextDemo.h" 9 10 11 /* 12 * This is the beginning of the main function 13 * 14 * Author: ROTBLATT 15 * Date: 2015-05-31 16 * 17 */ 18 19 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, 20 WPARAM wParam, LPARAM lParam); 21 22 int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prevInstance, 23 LPWSTR cmdLine, int cmdShow) 24 { 25 UNREFERENCED_PARAMETER(prevInstance); 26 UNREFERENCED_PARAMETER(cmdLine); 27 28 WNDCLASSEX wndClass = { 0 }; 29 //ZeroMemory(&wndClass, sizeof(wndClass)); 30 wndClass.cbSize = sizeof(WNDCLASSEX); 31 wndClass.style = CS_HREDRAW | CS_VREDRAW; 32 wndClass.lpfnWndProc = WndProc; 33 wndClass.hInstance = hInstance; 34 wndClass.hCursor = LoadCursor(NULL, IDC_ARROW); 35 wndClass.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1); 36 wndClass.lpszMenuName = NULL; 37 wndClass.lpszClassName = "DX11BookWindowClass"; 38 39 if (!RegisterClassEx(&wndClass)) 40 return -1; 41 42 RECT rc = { 0, 0, 1024, 768 }; 43 AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE); 44 45 HWND hwnd = CreateWindow("DX11BookWindowClass", 46 "DirectX 11 Demo", 47 WS_OVERLAPPEDWINDOW | WS_VSCROLL, 48 CW_USEDEFAULT, 49 CW_USEDEFAULT, 50 rc.right - rc.left, 51 rc.bottom - rc.top, 52 NULL, NULL, hInstance, NULL); 53 54 if (!hwnd) 55 return -1; 56 57 ShowWindow(hwnd, cmdShow); 58 59 //GameSpriteDemo demo; 60 //TriangleDemo demo; 61 D3DTextDemo demo; 62 bool result = demo.Initialize(hInstance, hwnd); 63 64 if (result == false) 65 return -1; 66 67 MSG msg = { 0 }; 68 69 while (msg.message != WM_QUIT) 70 { 71 if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) 72 { 73 TranslateMessage(&msg); 74 DispatchMessage(&msg); 75 } 76 //Update and Draw 77 demo.Update(0.0f); 78 demo.Render(); 79 } 80 demo.Shutdown(); 81 82 return static_cast<int>(msg.wParam); 83 } 84 85 LRESULT CALLBACK WndProc(HWND hwnd, UINT message, 86 WPARAM wParam, LPARAM lParam) 87 { 88 PAINTSTRUCT paintStruct; 89 HDC hDC; 90 91 switch (message) 92 { 93 case WM_PAINT: 94 //_cprintf(""); 95 hDC = BeginPaint(hwnd, &paintStruct); 96 EndPaint(hwnd, &paintStruct); 97 break; 98 case WM_SIZE: 99 //MessageBox(NULL, "Windows Changing", "Prompt", MB_OK); 100 //RECT rect; 101 //GetClientRect(hwnd, &rect); 102 //ValidateRect(hwnd,&rect); 103 104 break; 105 106 case WM_LBUTTONDOWN: 107 MessageBox(hwnd, "LBT Clicked", "PROMPT", MB_OK); 108 break; 109 110 case WM_DESTROY: 111 PostQuitMessage(0); 112 break; 113 default: 114 return DefWindowProc(hwnd,message,wParam,lParam); 115 } 116 117 return 0; 118 }
时间: 2024-10-25 17:26:53