Advertisement
RaWRCoder

MainCycle

Nov 5th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.14 KB | None | 0 0
  1. // Главный цикл приложения
  2. _s32 Engine::Run()
  3. {
  4.     LOGLN(L"[DBG] Engine started ...");
  5.  
  6.     if (m_pInitData->bFullScreen)
  7.         SetFullScreenMode(true);
  8.  
  9.     LogProcessorInfo();
  10.     LogDisplayDevicesInfo();
  11.  
  12.     m_pCamera = new Camera();
  13.     m_frame3D = new Frame3D();
  14.     if (!SetUpNewFrame(m_frame3D))
  15.         return E_FAIL;
  16.     SelectGameFrame(m_frame3D);
  17.  
  18.     MSG msg = { 0 };
  19.  
  20.     LOGLN((L"[Localization]: " + LOCCS("#localization_title")).c_str());
  21.    
  22.     GetWindowRect(m_hWnd, m_pWindowClientRect);
  23.     m_iWidth = m_pWindowClientRect->right - m_pWindowClientRect->left;
  24.     m_iHeight = m_pWindowClientRect->bottom - m_pWindowClientRect->top;
  25.     UI_GetInput();
  26.  
  27.     m_timeLastUpdate = time(nullptr);
  28.  
  29.     while (msg.message != WM_QUIT)
  30.     {
  31.         if (PeekMessage(&msg, 0, 0, 0, PM_REMOVE))
  32.         {
  33.             TranslateMessage(&msg);
  34.             DispatchMessage(&msg);
  35.         }
  36.         else
  37.         {
  38.             auto now = time(nullptr);
  39.             _f32 delta = static_cast<_f32>(difftime(now, m_timeLastUpdate));
  40.             /*if (delta < m_fTargetDelay)
  41.                 continue;*/
  42.             m_timeLastUpdate = now;
  43.  
  44.             Update(delta);
  45.             Render(delta);
  46.         }
  47.     }
  48.  
  49.     LOGLN(L"[DBG] Engine closed!");
  50.     return static_cast<_s32>(msg.wParam);
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement