Example #1
0
// ウィンドウプロシージャ
LRESULT WINAPI MsgProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
	switch (msg)
	{
		case WM_DESTROY:
			CleanupD3D();
			PostQuitMessage(0);
			return 0;
	}
	return DefWindowProc(hWnd, msg, wParam, lParam);
}
Example #2
0
//The entry point for any windows program
int WINAPI WinMain(HINSTANCE hInstance,
	HINSTANCE hPrevInstance,
	LPSTR lpCmdLine,
	INT nCmdShow)
{
	char *const temp_fake_args[1]{lpCmdLine};
	z_main(0, temp_fake_args);
	//handle for window
	HWND hWnd;
	//window information class
	WNDCLASSEX wc;

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

	//fill in 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);

	RECT wr = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT };
	AdjustWindowRect(&wr, WS_OVERLAPPEDWINDOW, false);
	//create the window and use the results as the handle
	hWnd = CreateWindowEx(NULL,
		"WindowClass1", //name of the window class
		"Our First Windowed Program", //title of the window
		WS_OVERLAPPEDWINDOW, //window style
		300, // x-position of the window
		100, //y-position of the window
		wr.right - wr.left, // with of the window
		wr.bottom - wr.top, // height of the window
		NULL, // we have no parent window, NULL
		NULL, // we aren't using menus, NULL
		hInstance, // application handle
		NULL); // used with mltiple windows, NULL

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

	//initialize d3d11
	InitD3D(hWnd);

	//enter the main loop
	//this struct holds the windows event messages
	MSG msg = { 0 };

	//windows game loop
	while (true)
	{
		if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
		{
			//translate keystrokes
			TranslateMessage(&msg);

			//send to windproc
			DispatchMessage(&msg);

			if (msg.message == WM_QUIT)
				break; //exit loop

			RenderFrame();
		}
		else
		{
			//whatev dog
		}
	}

	//release d3d resources
	CleanupD3D();

	return msg.wParam;
}