Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <tchar.h>
- #include <stdio.h>
- #include <vector>
- using namespace std;
- #include "dxSystem.h"
- /*******************************************************************
- * Global Variables
- *******************************************************************/
- HWND hWnd; //window handle
- int windowWidth = 800;
- int windowHeight = 600;
- //directX manager
- dxSystem* dx;
- /*******************************************************************
- * Main Window Procedure - handles application events
- *******************************************************************/
- LRESULT CALLBACK wndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
- {
- switch (message)
- {
- // Allow the user to press the escape key to end the application
- case WM_KEYDOWN : switch(wParam)
- {
- case VK_ESCAPE : PostQuitMessage(0);
- break;
- }
- break;
- // The user hit the close button, close the application
- case WM_DESTROY : PostQuitMessage(0);
- break;
- }
- return DefWindowProc(hWnd, message, wParam, lParam);
- }
- /*******************************************************************
- * Initialize Main Window
- ********************************************************************/
- bool initWindow(HWND &hWnd, HINSTANCE hInstance, int width, int height)
- {
- WNDCLASSEX wcex;
- wcex.cbSize = sizeof(WNDCLASSEX);
- wcex.style = CS_HREDRAW | CS_VREDRAW;
- wcex.lpfnWndProc = (WNDPROC)wndProc;
- wcex.cbClsExtra = 0;
- wcex.cbWndExtra = 0;
- wcex.hInstance = hInstance;
- wcex.hIcon = 0;
- wcex.hCursor = LoadCursor(NULL, IDC_ARROW);
- wcex.hbrBackground = (HBRUSH)(COLOR_WINDOW+1);
- wcex.lpszMenuName = NULL;
- wcex.lpszClassName = TEXT("DXTutorial");
- wcex.hIconSm = 0;
- RegisterClassEx(&wcex);
- //Resize the window
- RECT rect = { 0, 0, width, height };
- AdjustWindowRect(&rect, WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX, FALSE);
- //create the window from the class defined above
- hWnd = CreateWindow( L"ENGINE",
- L"ENGINE",
- WS_OVERLAPPED | WS_CAPTION | WS_SYSMENU | WS_MINIMIZEBOX,
- CW_USEDEFAULT,
- CW_USEDEFAULT,
- rect.right - rect.left,
- rect.bottom - rect.top,
- NULL,
- NULL,
- hInstance,
- NULL);
- //window handle not created
- if (!hWnd) return false;
- //if window creation was successful
- ShowWindow(hWnd, SW_SHOW);
- UpdateWindow(hWnd);
- return true;
- }
- /*******************************************************************
- * WinMain
- *******************************************************************/
- int APIENTRY _tWinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow )
- {
- // Set up the application window
- initWindow(hWnd, hInstance, windowWidth, windowHeight);
- //set up directx manager
- dx->initialise(windowWidth, windowHeight, &hWnd);
- // Main message loop
- MSG msg = {0};
- while (WM_QUIT != msg.message)
- {
- while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE) == TRUE)
- {
- TranslateMessage(&msg);
- DispatchMessage(&msg);
- }
- dx->render();
- }
- dx->shutDown();
- delete dx;
- dx = 0;
- return (int) msg.wParam;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement