Exemplo n.º 1
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
	MSG msg;
	bool done = false;

	window.Initialize(800, 600, 32, false);

	Initialize();

	while(!done){
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
			if(msg.message==WM_QUIT){
				done = true;
			}
			else{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		else{
			Render();
			window.Swap();
		}
	}

	window.Terminate();

	return msg.wParam;
}
Exemplo n.º 2
0
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int iCmdShow)
{
	MSG msg;
	bool done = false;

	window.Initialize(800, 600, 32, false);

	Initialize();

	int ticks = GetTickCount();

	float deltaTime;

	LARGE_INTEGER lastTime, curTime, timerFreq;

	QueryPerformanceFrequency(&timerFreq);
	QueryPerformanceCounter(&lastTime);

	while(!done){
		if(PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)){
			if(msg.message==WM_QUIT){
				done = true;
			}
			else{
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
		}
		QueryPerformanceCounter(&curTime);
		deltaTime = (float)(curTime.QuadPart-lastTime.QuadPart)/timerFreq.QuadPart;
		lastTime = curTime;
		
		Render(deltaTime);
        window.Swap();
	}

	window.Terminate();
	
	return msg.wParam;
}
Exemplo n.º 3
0
LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_KEYDOWN:
		switch(wParam)
		{
		case VK_ESCAPE:
			PostQuitMessage(0);
			break;
		default:
			break;
		}
		break;
	case WM_DESTROY:
	case WM_CLOSE:
		PostQuitMessage(0);
		break;
	case WM_SIZE:
		window.Resize(LOWORD(lParam), HIWORD(lParam));
		break;
	}
	return DefWindowProc(hWnd, uMsg, wParam, lParam);
}