Esempio n. 1
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShow)
{
	D3DApp *app = D3DApp::GetApp();
	if (app->Initialize(hInstance, width, height)) {
		app->Run();
	}
	app->Destroy();
}
Esempio n. 2
0
int main()
{
	HINSTANCE hInstance = GetModuleHandle(NULL);
	D3DApp* demo = NULL;
	int result;
	int index;
	cout << "1、clear view." << endl;
	cout << "2、box." << endl;
	cout << "3、skull" << endl;
	cout << "4、terrain" << endl;
	cout << "5、lighting" << endl;
	cin >> index;
	switch (index)
	{
	case CLEAR_VIEW:
		demo =  new D3dAppDemo1(hInstance);
		break;
	case BOX:
		demo = new CubeDemo(hInstance);
		break;
	case SKULL:
		demo = new ModelSkull(hInstance);
		break;
	case TERRAIN:
		demo = new Terrain(hInstance);
		break;
	case LIGHTING:
		demo = new LightDemo::LightingApp(hInstance);
	default:
		break;
	}
	
	if(!demo || !demo->Init() )
		return 0;

	result = demo->Run();
	delete demo;
	return result;

}
Esempio n. 3
0
//entry point for any windows program
int WINAPI WinMain(	HINSTANCE hInstance,
					HINSTANCE hPrevInstance,
					LPSTR lpCmdLine,
					int nCmdShow)
{
	//void* myP = (void*)(new Packet(1, 5, 5));
	//Packet myPack;
	//short id;
	//memcpy( &id, myP, sizeof(short));


	//Create console
	AllocConsole();
	//std::cout << "Test console!!!";
	

	//start timer
	TIM->Start();
	D3DApp dapp;
	//gTextureMan = new TextureManager();

	//the handle for the window, filled by a function
	HWND hWnd;
	//this struct holds info for the window  class
	WNDCLASSEX wc;



	//clear out the window class for use
	ZeroMemory(&wc, sizeof(WNDCLASSEX) );

	//fill in the struct with the needed information
	wc.cbSize = sizeof(WNDCLASSEX);
	wc.style = CS_HREDRAW | CS_VREDRAW;
	wc.lpfnWndProc = WindowProc;
	wc.hInstance = hInstance;
	wc.hCursor = LoadCursor(NULL, IDC_ARROW);
	wc.hbrBackground = (HBRUSH) COLOR_WINDOW;
	wc.lpszClassName = "WindowClass1";

	//register the window class
	RegisterClassEx(&wc);

	// create the window and use the result as the handle
    hWnd = CreateWindowEx(NULL,
                          "WindowClass1",    // name of the window class
                          "DirectX by Jimmy Roland",   // title of the window
                          WS_OVERLAPPEDWINDOW,    // window style
                          300,    // x-position of the window
                          300,    // y-position of the window
                          SCREEN_WIDTH,    // width of the window
                          SCREEN_HEIGHT,    // height of the window
                          NULL,    // we have no parent window, NULL
                          NULL,    // we aren't using menus, NULL
                          hInstance,    // application handle
                          NULL);    // used with multiple windows, NULL

    // display the window on the screen
    ShowWindow(hWnd, nCmdShow);

	//start Visual Leak Detector
	VLDEnable();

	//create global for DirectInput pointer
	gDInput = new DirectInput(hInstance, hWnd, 
		DISCL_NONEXCLUSIVE |
		DISCL_FOREGROUND,
		DISCL_NONEXCLUSIVE |
		DISCL_FOREGROUND);


	//set up and initialize Direct3D
	dapp.InitD3D(hWnd,hInstance, true);
	dapp.CreateFPSDisplay();
	// enter the main loop:
	gD3DDev = *dapp.GetDevice();
	dapp.VertexDeclarations();
    // this struct holds Windows event messages
    MSG msg;


    // Enter the infinite message loop
    while(TRUE)
    {
        // Check to see if any messages are waiting in the queue
        while(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            // translate keystroke messages into the right format
            TranslateMessage(&msg);

            // send the message to the WindowProc function
            DispatchMessage(&msg);
        }

        // If the message is WM_QUIT, exit the while loop
        if(msg.message == WM_QUIT)
            break;

		//DirectInput polling
		gDInput->poll();
		//dapp.SetMousePos(hWnd);

        // Run game code here
		dapp.Update( (float)TIM->GetTimeElapsed() );
    }

	VLDReportLeaks();
	//clean up DirectX and COM
	dapp.CleanDirect3D();

	//delete global
	delete gDInput;

    // return this part of the WM_QUIT message to Windows
    return msg.wParam;
}
Esempio n. 4
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE prevInstance, PSTR cmdLine, int showCmd) {
	D3DApp* Renderer = new D3DApp(hInstance);
	Renderer->run();// run
	delete Renderer;
	return 0;
}