Fix for [#32361] "Blenderplayer quad-buffer maximum 100Hz Fps" reported by HG1.
authorMitchell Stokes <mogurijin@gmail.com>
Sat, 18 Aug 2012 23:46:37 +0000 (23:46 +0000)
committerMitchell Stokes <mogurijin@gmail.com>
Sat, 18 Aug 2012 23:46:37 +0000 (23:46 +0000)
Allowing the Blenderplayer to break 100fps by making it less dependent on Ghost's messages.

source/gameengine/GamePlayer/ghost/GPG_Application.cpp
source/gameengine/GamePlayer/ghost/GPG_Application.h
source/gameengine/GamePlayer/ghost/GPG_ghost.cpp

index eccb83fe80c59efc1d3b8f64a83ec4ab355f0bbb..21de7011eda5f9abac5c557bfda8d676e7d59e46 100644 (file)
@@ -464,31 +464,34 @@ bool GPG_Application::processEvent(GHOST_IEvent* event)
                        handled = false;
                        break;
 
-               case GHOST_kEventWindowUpdate:
-                       {
-                               GHOST_IWindow* window = event->getWindow();
-                               if (!m_system->validWindow(window)) break;
-                               // Update the state of the game engine
-                               if (m_kxsystem && !m_exitRequested)
-                               {
-                                       // Proceed to next frame
-                                       window->activateDrawingContext();
-
-                                       // first check if we want to exit
-                                       m_exitRequested = m_ketsjiengine->GetExitCode();
-                                       
-                                       // kick the engine
-                                       bool renderFrame = m_ketsjiengine->NextFrame();
-                                       if (renderFrame)
-                                       {
-                                               // render the frame
-                                               m_ketsjiengine->Render();
-                                       }
-                               }
-                               m_exitString = m_ketsjiengine->GetExitString();
-                       }
-                       break;
-               
+               // The player now runs as often as it can (repsecting vsync and fixedtime).
+               // This allows the player to break 100fps, but this code is being left here
+               // as reference. (see EngineNextFrame)
+               //case GHOST_kEventWindowUpdate:
+               //      {
+               //              GHOST_IWindow* window = event->getWindow();
+               //              if (!m_system->validWindow(window)) break;
+               //              // Update the state of the game engine
+               //              if (m_kxsystem && !m_exitRequested)
+               //              {
+               //                      // Proceed to next frame
+               //                      window->activateDrawingContext();
+
+               //                      // first check if we want to exit
+               //                      m_exitRequested = m_ketsjiengine->GetExitCode();
+               //                      
+               //                      // kick the engine
+               //                      bool renderFrame = m_ketsjiengine->NextFrame();
+               //                      if (renderFrame)
+               //                      {
+               //                              // render the frame
+               //                              m_ketsjiengine->Render();
+               //                      }
+               //              }
+               //              m_exitString = m_ketsjiengine->GetExitString();
+               //      }
+               //      break;
+               //
                case GHOST_kEventWindowSize:
                        {
                        GHOST_IWindow* window = event->getWindow();
@@ -789,6 +792,28 @@ void GPG_Application::stopEngine()
        m_engineRunning = false;
 }
 
+void GPG_Application::EngineNextFrame()
+{
+       // Update the state of the game engine
+       if (m_kxsystem && !m_exitRequested)
+       {
+               // Proceed to next frame
+               if (m_mainWindow)
+                       m_mainWindow->activateDrawingContext();
+
+               // first check if we want to exit
+               m_exitRequested = m_ketsjiengine->GetExitCode();
+               
+               // kick the engine
+               bool renderFrame = m_ketsjiengine->NextFrame();
+               if (renderFrame && m_mainWindow)
+               {
+                       // render the frame
+                       m_ketsjiengine->Render();
+               }
+       }
+       m_exitString = m_ketsjiengine->GetExitString();
+}
 
 void GPG_Application::exitEngine()
 {
index 51dac5cb3f3985ceccaa08f59e1ec12f0f372547..e04fcc2a5559822591dd8bccde5d81e30b9dde3d 100644 (file)
@@ -77,6 +77,7 @@ public:
                        GlobalSettings* getGlobalSettings(void);
                        bool StartGameEngine(int stereoMode);
                        void StopGameEngine();
+                       void EngineNextFrame();
 
 protected:
        bool    handleWheel(GHOST_IEvent* event);
index 025611972cef1c4f936ff62e0f575eaa22624884..63f2988e2596a45a11598f0e49132198865029a3 100644 (file)
@@ -970,6 +970,8 @@ int main(int argc, char** argv)
                                                {
                                                        system->processEvents(false);
                                                        system->dispatchEvents();
+                                                       app.EngineNextFrame();
+
                                                        if ((exitcode = app.getExitRequested()))
                                                        {
                                                                run = false;