void Game::GameLoop() { graphics.BeginFrame(); DrawGraphics(); HandleInput(); if (!prince->isDead()) { ControlAI(); CheckCollision(); } graphics.EndFrame(); }
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { const LPCWSTR appname = TEXT("OpenGL Sample"); WNDCLASS wndclass; MSG msg; // Define the window class wndclass.style = 0; wndclass.lpfnWndProc = (WNDPROC)MainWndProc; wndclass.cbClsExtra = 0; wndclass.cbWndExtra = 0; wndclass.hInstance = hInstance; wndclass.hIcon = LoadIcon(hInstance, appname); wndclass.hCursor = LoadCursor(NULL,IDC_ARROW); wndclass.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); wndclass.lpszMenuName = appname; wndclass.lpszClassName = appname; // Register the window class if (!RegisterClass(&wndclass)) return FALSE; // Create the window hWnd = CreateWindow( appname, appname, WS_OVERLAPPEDWINDOW | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, CW_USEDEFAULT, CW_USEDEFAULT, 800, 600, NULL, NULL, hInstance, NULL); if (!hWnd) return FALSE; // Initialize OpenGL InitGraphics(); // Display the window ShowWindow(hWnd, nCmdShow); UpdateWindow(hWnd); // Event loop while (1) { if (PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE) == TRUE) { if (!GetMessage(&msg, NULL, 0, 0)) return TRUE; TranslateMessage(&msg); DispatchMessage(&msg); } DrawGraphics(); } wglDeleteContext(hRC); ReleaseDC(hWnd, hDC); }