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; }
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; }