/******************************************************************************** Run this program ********************************************************************************/ void Application::Run() { #if TYPE_OF_VIEW == 3 scene = new CSceneManager(m_window_width, m_window_height); // Use this for 3D gameplay #else scene = new CSceneManager2D(m_window_width, m_window_height); // Use this for 2D gameplay #endif scene->Init(); m_timer.startTimer(); // Start timer to calculate how long it takes to render this frame while (!glfwWindowShouldClose(m_window) && !IsKeyPressed(VK_ESCAPE)) { // Get the elapsed time m_dElapsedTime = m_timer.getElapsedTime(); m_dAccumulatedTime_ThreadOne += m_dElapsedTime; m_dAccumulatedTime_ThreadTwo += m_dElapsedTime; if (m_dAccumulatedTime_ThreadOne > 0.03) { GetMouseUpdate(); GetKeyboardUpdate(); m_GSM->HandleEvents(); m_GSM->Update(m_dElapsedTime); /* scene->Update(m_dElapsedTime); */ m_dAccumulatedTime_ThreadOne = 0.0; } if (m_dAccumulatedTime_ThreadTwo > 1.0) { //UpdateAI(); m_dAccumulatedTime_ThreadTwo = 0.0; } // Render the scene m_GSM->Draw(); //scene->Render(); //Swap buffers glfwSwapBuffers(m_window); //Get and organize events, like keyboard and mouse input, window resizing, etc... glfwPollEvents(); m_timer.waitUntil(frameTime); // Frame rate limiter. Limits each frame to a specified time in ms. } //Check if the ESC key had been pressed or if the window had been closed // Delete the scene m_GSM->Cleanup(); //scene->Exit(); if (scene) { delete scene; scene = NULL; } }
void Application::Run() { //Main Loop scene = new SceneText(); scene->Init(); m_timer.startTimer(); // Start timer to calculate how long it takes to render this frame while (!glfwWindowShouldClose(m_window) && !IsKeyPressed(VK_ESCAPE)) { //Get the elapsed time m_dElapsedTime = m_timer.getElapsedTime(); m_dAccumulatedTime_ThreadOne += m_dElapsedTime; m_dAccumulatedTime_ThreadTwo += m_dElapsedTime; if (m_dAccumulatedTime_ThreadOne > 0.01) { GetMouseUpdate(); GetKeyboardUpdate(); scene->Update(m_dElapsedTime); m_dAccumulatedTime_ThreadOne = 0.0; } if (m_dAccumulatedTime_ThreadTwo > 1.0) { //UpdateAI(); m_dAccumulatedTime_ThreadTwo = 0.0; } // Render the scene scene->Render(); //Swap buffers glfwSwapBuffers(m_window); //Get and organize events, like keyboard and mouse input, window resizing, etc... glfwPollEvents(); m_timer.waitUntil(frameTime); // Frame rate limiter. Limits each frame to a specified time in ms. if (SceneText::bReset) { scene->Exit(); delete scene; scene = new SceneText(); scene->Init(); } } //Check if the ESC key had been pressed or if the window had been closed scene->Exit(); delete scene; }
/******************************************************************************** Run this program ********************************************************************************/ void Application::Run() { m_timer.startTimer(); // Start timer to calculate how long it takes to render this frame while (theGSM->Running() && !glfwWindowShouldClose(m_window)) { // Get the elapsed time m_dElapsedTime = m_timer.getElapsedTime(); m_dAccumulatedTime_ThreadOne += m_dElapsedTime; m_dAccumulatedTime_ThreadTwo += m_dElapsedTime; if (m_dAccumulatedTime_ThreadOne > 0.03) { // Get inputs GetMouseUpdate(); GetKeyboardUpdate(); // Update the GSM theGSM->HandleEvents(); theGSM->Update(m_dElapsedTime); m_dAccumulatedTime_ThreadOne = 0.0; } if (m_dAccumulatedTime_ThreadTwo > 1.0) { //UpdateAI(); m_dAccumulatedTime_ThreadTwo = 0.0; } // Render the scene theGSM->Draw(); //Swap buffers glfwSwapBuffers(m_window); //Get and organize events, like keyboard and mouse input, window resizing, etc... glfwPollEvents(); m_timer.waitUntil(frameTime); // Frame rate limiter. Limits each frame to a specified time in ms. } //Check if the ESC key had been pressed or if the window had been closed // Clean up the GSM theGSM->Cleanup(); }
void Application::Run() { //Main Loop scene = new SceneStealth(); scene->Init(); m_timer.startTimer(); // Start timer to calculate how long it takes to render this frame while (!glfwWindowShouldClose(m_window) && !IsKeyPressed(VK_ESCAPE) && !scene->GetExit()) { scene->Update(m_timer.getElapsedTime()); scene->Render(); //Swap buffers glfwSwapBuffers(m_window); //Get and organize events, like keyboard and mouse input, window resizing, etc... GetMouseUpdate(); //Update mouse GetKeyboardUpdate(); glfwPollEvents(); m_timer.waitUntil(frameTime); // Frame rate limiter. Limits each frame to a specified time in ms. } //Check if the ESC key had been pressed or if the window had been closed scene->Exit(); delete scene; }