Parcourir la source

Updates win32 game loop to render frames outside of WM_PAINT.
Changed GP_ASSERT to use C assert on all platforms (instead of _debugbreak on win32) to prevent issue with hanging on asserts when running in debug mode and not attached to debugger.
Removed unnecessary/erroneous assert in AnimationClip.

Steve Grenier il y a 13 ans
Parent
commit
d9a76dd0ab
3 fichiers modifiés avec 8 ajouts et 15 suppressions
  1. 0 1
      gameplay/src/AnimationClip.cpp
  2. 3 9
      gameplay/src/Base.h
  3. 5 5
      gameplay/src/PlatformWin32.cpp

+ 0 - 1
gameplay/src/AnimationClip.cpp

@@ -375,7 +375,6 @@ bool AnimationClip::update(unsigned long elapsedTime)
     if (_listeners)
     if (_listeners)
     {
     {
         GP_ASSERT(_listenerItr);
         GP_ASSERT(_listenerItr);
-        GP_ASSERT(**_listenerItr);
 
 
         if (_speed >= 0.0f)
         if (_speed >= 0.0f)
         {
         {

+ 3 - 9
gameplay/src/Base.h

@@ -60,20 +60,14 @@ extern void printError(const char* format, ...);
 
 
 // Assert macros.
 // Assert macros.
 #ifdef _DEBUG
 #ifdef _DEBUG
-#ifdef WIN32
-#define GP_FORCE_ASSERTION_FAILURE do { __debugbreak(); } while (0)
-#else
-#define GP_FORCE_ASSERTION_FAILURE do { assert(0); } while (0)
-#endif
 #define GP_ASSERT(expression) do { \
 #define GP_ASSERT(expression) do { \
     if (!(expression)) \
     if (!(expression)) \
     { \
     { \
         printError("%s -- Assertion '" #expression "' failed.\n", __current__func__); \
         printError("%s -- Assertion '" #expression "' failed.\n", __current__func__); \
-        GP_FORCE_ASSERTION_FAILURE; \
+        assert(expression); \
     } } while (0)
     } } while (0)
 #else
 #else
-#define GP_FORCE_ASSERTION_FAILURE do { (void)sizeof(int); } while (0)
-#define GP_ASSERT(expression) do { (void)sizeof(expression); } while (0)
+#define GP_ASSERT(expression)
 #endif
 #endif
 
 
 // Error macro.
 // Error macro.
@@ -85,7 +79,7 @@ extern void printError(const char* format, ...);
         printError("%s -- ", __current__func__); \
         printError("%s -- ", __current__func__); \
         printError(__VA_ARGS__); \
         printError(__VA_ARGS__); \
         printError("\n"); \
         printError("\n"); \
-        GP_FORCE_ASSERTION_FAILURE; \
+        assert(0); \
         std::exit(-1); \
         std::exit(-1); \
     } while (0)
     } while (0)
 #endif
 #endif

+ 5 - 5
gameplay/src/PlatformWin32.cpp

@@ -276,11 +276,6 @@ LRESULT CALLBACK __WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
 
 
     switch (msg)
     switch (msg)
     {
     {
-    case WM_PAINT:
-        gameplay::Game::getInstance()->frame();
-        SwapBuffers(__hdc);
-        return 0;
-
     case WM_CLOSE:
     case WM_CLOSE:
         DestroyWindow(__hwnd);
         DestroyWindow(__hwnd);
         return 0;
         return 0;
@@ -663,6 +658,11 @@ int Platform::enterMessagePump()
                 break;
                 break;
             }
             }
         }
         }
+        else
+        {
+            _game->frame();
+            SwapBuffers(__hdc);
+        }
 
 
         // If we are done, then exit.
         // If we are done, then exit.
         if (_game->getState() == Game::UNINITIALIZED)
         if (_game->getState() == Game::UNINITIALIZED)