Browse Source

Updates GPB and Visual Studio project files for the template project (used to create new projects).
Fixes automatic game pausing on QNX/BB10 platforms on system events.
Fixes ScreenDisplayer compilation warning.

Chris Culy 13 years ago
parent
commit
94c80d3194

+ 2 - 0
gameplay-template/gameplay-template.vcxproj

@@ -76,6 +76,7 @@
       <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_ITERATOR_DEBUG_LEVEL=0;%(PreprocessorDefinitions)</PreprocessorDefinitions>
       <AdditionalIncludeDirectories>GAMEPLAY_PATH/external-deps/bullet/include;GAMEPLAY_PATH/gameplay/src;GAMEPLAY_PATH/external-deps/openal/include/AL;GAMEPLAY_PATH/external-deps/oggvorbis/include;GAMEPLAY_PATH/external-deps/libpng/include;GAMEPLAY_PATH/external-deps/zlib/include;GAMEPLAY_PATH/external-deps/glew/include</AdditionalIncludeDirectories>
       <RuntimeTypeInfo>true</RuntimeTypeInfo>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>
@@ -107,6 +108,7 @@
       <RuntimeTypeInfo>true</RuntimeTypeInfo>
       <ShowIncludes>false</ShowIncludes>
       <PreprocessToFile>false</PreprocessToFile>
+      <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
     </ClCompile>
     <Link>
       <SubSystem>Windows</SubSystem>

BIN
gameplay-template/res/box.gpb


+ 46 - 27
gameplay/src/PlatformQNX.cpp

@@ -778,6 +778,7 @@ int Platform::enterMessagePump()
     int domain;
     mtouch_event_t touchEvent;
     int touchId = 0;
+    bool suspended = false;
 
     // Get the initial time.
     clock_gettime(CLOCK_REALTIME, &__timespec);
@@ -950,6 +951,23 @@ int Platform::enterMessagePump()
                 case NAVIGATOR_SWIPE_DOWN:
                     _game->menu();
                     break;
+                case NAVIGATOR_WINDOW_STATE:
+                {
+                	navigator_window_state_t state = navigator_event_get_window_state(event);
+                	switch (state)
+                	{
+                	case NAVIGATOR_WINDOW_FULLSCREEN:
+                		_game->resume();
+                		suspended = false;
+                		break;
+                	case NAVIGATOR_WINDOW_THUMBNAIL:
+                	case NAVIGATOR_WINDOW_INVISIBLE:
+                		_game->pause();
+                		suspended = true;
+                		break;
+                	}
+                	break;
+                }
                 case NAVIGATOR_EXIT:
                     _game->exit();
                     break;
@@ -957,13 +975,11 @@ int Platform::enterMessagePump()
             }
             else if (domain == sensor_get_domain())
             {
-            	if (bps_event_get_code(event) == SENSOR_AZIMUTH_PITCH_ROLL_READING)
-            	{
-					float azimuth;
-					sensor_event_get_apr(event, &azimuth, &__pitch, &__roll);
-
-
-				   }
+                if (bps_event_get_code(event) == SENSOR_AZIMUTH_PITCH_ROLL_READING)
+                {
+                    float azimuth;
+                    sensor_event_get_apr(event, &azimuth, &__pitch, &__roll);
+                }
             }
         }
 
@@ -971,27 +987,30 @@ int Platform::enterMessagePump()
         if (_game->getState() == Game::UNINITIALIZED)
             break;
 
-        _game->frame();
-
-        // Post the new frame to the display.
-        // Note that there are a couple cases where eglSwapBuffers could fail
-        // with an error code that requires a certain level of re-initialization:
-        //
-        // 1) EGL_BAD_NATIVE_WINDOW - Called when the surface we're currently using
-        //    is invalidated. This would require us to destroy our EGL surface,
-        //    close our OpenKODE window, and start again.
-        //
-        // 2) EGL_CONTEXT_LOST - Power management event that led to our EGL context
-        //    being lost. Requires us to re-create and re-initalize our EGL context
-        //    and all OpenGL ES state.
-        //
-        // For now, if we get these, we'll simply exit.
-        rc = eglSwapBuffers(__eglDisplay, __eglSurface);
-        if (rc != EGL_TRUE)
+        if (!suspended)
         {
-            _game->exit();
-            perror("eglSwapBuffers");
-            break;
+            _game->frame();
+
+            // Post the new frame to the display.
+            // Note that there are a couple cases where eglSwapBuffers could fail
+            // with an error code that requires a certain level of re-initialization:
+            //
+            // 1) EGL_BAD_NATIVE_WINDOW - Called when the surface we're currently using
+            //    is invalidated. This would require us to destroy our EGL surface,
+            //    close our OpenKODE window, and start again.
+            //
+            // 2) EGL_CONTEXT_LOST - Power management event that led to our EGL context
+            //    being lost. Requires us to re-create and re-initalize our EGL context
+            //    and all OpenGL ES state.
+            //
+            // For now, if we get these, we'll simply exit.
+            rc = eglSwapBuffers(__eglDisplay, __eglSurface);
+            if (rc != EGL_TRUE)
+            {
+                _game->exit();
+                perror("eglSwapBuffers");
+                break;
+            }
         }
     }
 

+ 9 - 0
gameplay/src/ScreenDisplayer.h

@@ -14,6 +14,11 @@ class ScreenDisplayer
 {
 public:
 
+	/**
+	 * Constructor.
+	 */
+	ScreenDisplayer();
+
     /**
      * Displays a screen using the {@link Game#renderOnce} mechanism for at least the given amount of time.
      * 
@@ -35,6 +40,10 @@ private:
     long _startTime;
 };
 
+inline ScreenDisplayer::ScreenDisplayer() : _time(0L), _startTime(0L)
+{
+}
+
 template <typename T> void ScreenDisplayer::run(T* instance, void (T::*method) (void*), void* cookie, long time)
 {
     _time = time;