Пример #1
0
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
    HWND hWnd;
    WNDCLASSEX wc;

    ZeroMemory(&wc, sizeof(WNDCLASSEX));

    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 = "WindowClass";

    RegisterClassEx(&wc);

    RECT wr = {0, 0, 800, 600};
    AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);

    hWnd = CreateWindowEx(NULL,
                          "WindowClass",
                          "Our First Direct3D Program",
                          WS_OVERLAPPEDWINDOW,
                          300,
                          300,
                          wr.right - wr.left,
                          wr.bottom - wr.top,
                          NULL,
                          NULL,
                          hInstance,
                          NULL);
    ShowWindow(hWnd, nCmdShow);
    InitD3D(hWnd);

    MSG msg;
    while(TRUE)
    {
        if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);

            if(msg.message == WM_QUIT)
                break;
        }
        else
        {
            // Run game code here
        }
    }

    CleanD3D();
    return msg.wParam;
}
Пример #2
0
SINT WINAPI WinMain( 
		HINSTANCE hInstance,
		HINSTANCE hPrevInstance ,
		LPSTR lpCmdLine,
		SINT nCmdShow // how the window will be shown
	){
		SLONG width = 800;
		SLONG height = 600;

		HWND hWnd;

		InitWindows( hWnd, hInstance, nCmdShow, width, height );
		InitD3D( hWnd, (SFLOAT)width, (SFLOAT)height );

		//show the window
		ShowWindow( hWnd, nCmdShow );
		MSG msg;

		while( TRUE ){ //min and max are limitations on which messages we want to get from the queue

			if( PeekMessage( &msg, NULL, 0, 0, PM_REMOVE ) ){
				
				TranslateMessage( &msg );
				DispatchMessage( &msg ); // sends message to WindowProc

				if( msg.message == WM_QUIT ){
					break;
				}

			} else {
				Render();
			}
				
		}

		//cleaning up D3D
		CleanD3D();

		return msg.wParam;

}
Пример #3
0
// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance,
                   HINSTANCE hPrevInstance,
                   LPSTR lpCmdLine,
                   int nCmdShow)
{
    HWND hWnd;
    WNDCLASSEX wc;

    ZeroMemory(&wc, sizeof(WNDCLASSEX));

    wc.cbSize = sizeof(WNDCLASSEX);
    wc.style = CS_HREDRAW | CS_VREDRAW;
    wc.lpfnWndProc = WindowProc;
    wc.hInstance = hInstance;
    wc.hCursor = LoadCursor(NULL, IDC_ARROW);
    wc.lpszClassName = L"WindowClass";

    RegisterClassEx(&wc);

    RECT wr = {0, 0, SCREEN_WIDTH, SCREEN_HEIGHT};
    AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, FALSE);

    hWnd = CreateWindowEx(NULL,
                          L"WindowClass",
                          L"Our First Direct3D Program",
                          WS_OVERLAPPEDWINDOW,
                          30,
                          30,
                          wr.right - wr.left,
                          wr.bottom - wr.top,
                          NULL,
                          NULL,
                          hInstance,
                          NULL);

    ShowWindow(hWnd, nCmdShow);

    // set up and initialize Direct3D
    InitD3D(hWnd);

    // enter the main loop:

    MSG msg;

    while(TRUE)
    {
        if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
        {
            TranslateMessage(&msg);
            DispatchMessage(&msg);

            if(msg.message == WM_QUIT)
                break;
        }

        RenderFrame();
    }

    // clean up DirectX and COM
    CleanD3D();

    return msg.wParam;
}
Пример #4
0
CWindowDG::~CWindowDG()
{
	CleanD3D();
}
Пример #5
0
Prism::DirectX::~DirectX()
{
    CleanD3D();
}
Пример #6
0
// the entry point for any Windows program
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{

	// handler for the window, filled by a function
	HWND hWnd = nullptr;

	// this struct holds information for the window class
	WNDCLASSEX wc = { 0 };

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

	// fill in the struct with 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 = CLASS_NAME;

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

	RECT wr = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT };
	AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, false);

	// create the window and use the result as the handle
	hWnd = CreateWindowEx(
		null,
		CLASS_NAME,			// name of the window class
		WINDOW_TITLE,		// title of the window
		WS_OVERLAPPEDWINDOW,// window style
		300,	// x-pos 
		300,	// y-pos
		(wr.right - wr.left),	// width
		(wr.bottom - wr.top),	// height
		null,	// paretn window
		null,	// window menus
		hInstance,	// application handle
		null	// user with multiple windows
		);

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

	// set up and initialize Direct3D
	InitD3D(hWnd);

	// enter the main loop:

	// this struct holds Windows event messages
	MSG msg;

	
	float r = 0.2f;
	float g = 0.2f;
	float b = 0.2f;

	// wait for the next message in the queue, store the result in 'msg'
	while (true)
	{
		if (PeekMessage(&msg, null, 0, 0, PM_REMOVE))
		{
			// translate keystroke messages into the right format
			TranslateMessage(&msg);

			//send the message to the WindowsProc()
			DispatchMessage(&msg);

			// check to see if it's time to quit
			if (msg.message == WM_QUIT)
				break;
		}

		// Game Code HERE!
		RenderFrame(r,g,b);

		
	}

	// clean up DirectX and COM
	CleanD3D();

	// return this part of the WM_QUIT message to Windows
	return msg.wParam;
}