www.pudn.com > Direct3D_ZBuffer.zip > Main.cpp


#include "Game.h" 
#include  
 
CGame* g_pGame = NULL; 
 
void CleanUp() 
{ 
	SafeDelete(g_pGame); 
} 
 
//The windows message handler 
LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) 
{ 
    switch(msg) 
    { 
        case WM_DESTROY: 
            PostQuitMessage(0); 
            return 0; 
        break; 
        case WM_KEYUP:  
            switch (wParam) 
            {  
                case VK_ESCAPE: 
                    //User has pressed the escape key, so quit 
                    DestroyWindow(hWnd); 
                    return 0; 
                break; 
            }  
        break; 
 
    } 
 
    return DefWindowProc(hWnd, msg, wParam, lParam); 
} 
 
//Application entry point 
INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT) 
{ 
    //Register the window class 
    WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L,  
                     GetModuleHandle(NULL), NULL, NULL, NULL, NULL, 
                     _T("DX Project 4"), NULL}; 
	 
	//Set the mouse pointer to an arrow 
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);	 
	 
	RegisterClassEx(&wc); 
 
    //Create the application's window 
    HWND hWnd = CreateWindow(_T("DX Project 4"), _T("www.andypike.com: Tutorial 4"),  
                              WS_OVERLAPPEDWINDOW, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN), 
                              NULL, NULL, wc.hInstance, NULL); 
 
	g_pGame = new CGame(); 
    g_pGame->EnableLogging(); 
 
	//Initialize Direct3D 
	if(g_pGame->Initialise(hWnd, 800, 600)) 
    { 
        //Show our window 
        ShowWindow(hWnd, SW_SHOWDEFAULT); 
        UpdateWindow(hWnd); 
 
        //Start game running: Enter the game loop 
        g_pGame->GameLoop();         
    } 
 
    CleanUp(); 
 
    UnregisterClass(_T("DX Project 4"), wc.hInstance); 
 
    return 0; 
}