Ver Fonte

Merge branch 'next' of https://github.com/blackberry/GamePlay into next

Conflicts:
	gameplay/src/Gamepad.cpp
sgrenier há 13 anos atrás
pai
commit
18ebaf93ef

+ 7 - 14
gameplay/.cproject

@@ -20,11 +20,10 @@
 							<builder buildPath="${workspace_loc:/gameplay/Device-Debug}" id="org.eclipse.cdt.build.core.internal.builder.159190287" keepEnvironmentInBuildfile="false" name="CDT Internal Builder" superClass="org.eclipse.cdt.build.core.internal.builder"/>
 							<tool id="com.qnx.qcc.tool.compiler.96907942" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
 								<option id="com.qnx.qcc.option.compile.debug.1765481355" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
-								<option id="com.qnx.qcc.option.compiler.security.311918799" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
+								<option id="com.qnx.qcc.option.compiler.security.311918799" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1481323494" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
-									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.2133604142" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/lua/include&quot;"/>
@@ -84,11 +83,10 @@
 							<builder buildPath="${workspace_loc:/gameplay/Device-Release}" id="cdt.managedbuild.target.gnu.builder.base.1199322737" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
 							<tool id="com.qnx.qcc.tool.compiler.1345567866" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
 								<option id="com.qnx.qcc.option.compiler.optlevel.1056793982" name="Optimization Level" superClass="com.qnx.qcc.option.compiler.optlevel" value="com.qnx.qcc.option.compiler.optlevel.1" valueType="enumerated"/>
-								<option id="com.qnx.qcc.option.compiler.security.324540233" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
+								<option id="com.qnx.qcc.option.compiler.security.324540233" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.398688299" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
-									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1670164593" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -146,11 +144,10 @@
 							<tool id="com.qnx.qcc.tool.compiler.1281156842" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
 								<option id="com.qnx.qcc.option.compile.debug.626405189" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.profile2.1207899085" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
-								<option id="com.qnx.qcc.option.compiler.security.1649809766" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
+								<option id="com.qnx.qcc.option.compiler.security.1649809766" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.276653249" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
-									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1503059677" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -211,11 +208,10 @@
 							<tool id="com.qnx.qcc.tool.compiler.306557636" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
 								<option id="com.qnx.qcc.option.compile.debug.168813234" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.coverage.1032644527" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
-								<option id="com.qnx.qcc.option.compiler.security.1227516972" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
+								<option id="com.qnx.qcc.option.compiler.security.1227516972" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.374283024" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
-									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1769677874" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -274,11 +270,10 @@
 							<builder buildPath="${workspace_loc:/gameplay/Simulator}" id="cdt.managedbuild.target.gnu.builder.base.10075032" keepEnvironmentInBuildfile="false" name="Gnu Make Builder" superClass="cdt.managedbuild.target.gnu.builder.base"/>
 							<tool id="com.qnx.qcc.tool.compiler.1004416224" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
 								<option id="com.qnx.qcc.option.compile.debug.1122485646" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
-								<option id="com.qnx.qcc.option.compiler.security.1671403331" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
+								<option id="com.qnx.qcc.option.compiler.security.1671403331" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1863269886" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
-									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.847642559" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -335,11 +330,10 @@
 							<tool id="com.qnx.qcc.tool.compiler.417488704" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
 								<option id="com.qnx.qcc.option.compile.debug.1290366598" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.profile2.216911941" name="Build for Profiling (Function Instrumentation) (-finstrument-functions)" superClass="com.qnx.qcc.option.compiler.profile2" value="true" valueType="boolean"/>
-								<option id="com.qnx.qcc.option.compiler.security.1329750381" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
+								<option id="com.qnx.qcc.option.compiler.security.1329750381" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1679396285" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
-									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.513622172" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>
@@ -397,11 +391,10 @@
 							<tool id="com.qnx.qcc.tool.compiler.563072865" name="QCC Compiler" superClass="com.qnx.qcc.tool.compiler">
 								<option id="com.qnx.qcc.option.compile.debug.1789973550" name="Debug (-g)" superClass="com.qnx.qcc.option.compile.debug" value="true" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.coverage.1289221781" name="Build for Code Coverage (-Wc,-ftest-coverage -Wc,-fprofile-arcs)" superClass="com.qnx.qcc.option.compiler.coverage" value="true" valueType="boolean"/>
-								<option id="com.qnx.qcc.option.compiler.security.1296061040" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="true" valueType="boolean"/>
+								<option id="com.qnx.qcc.option.compiler.security.1296061040" name="Enhanced Security (-fstack-protector-strong)" superClass="com.qnx.qcc.option.compiler.security" value="false" valueType="boolean"/>
 								<option id="com.qnx.qcc.option.compiler.defines.1925901823" name="Defines (-D)" superClass="com.qnx.qcc.option.compiler.defines" valueType="definedSymbols">
 									<listOptionValue builtIn="false" value="_FORTIFY_SOURCE=2"/>
 									<listOptionValue builtIn="false" value="BT_USE_NEON"/>
-									<listOptionValue builtIn="false" value="BLACKBERRY_USE_GAMEPAD"/>
 								</option>
 								<option id="com.qnx.qcc.option.compiler.includePath.1685994750" name="Include Directories (-I)" superClass="com.qnx.qcc.option.compiler.includePath" valueType="includePath">
 									<listOptionValue builtIn="false" value="&quot;../../external-deps/bullet/include&quot;"/>

+ 1 - 1
gameplay/src/Base.h

@@ -279,7 +279,7 @@ typedef GLuint FrameBufferHandle;
 typedef GLuint RenderBufferHandle;
 
 /** Gamepad handle definitions vary by platform. */
-#ifdef __QNX__
+#if defined(__QNX__) && defined (USE_BLACKBERRY_GAMEPAD)
     typedef screen_device_t GamepadHandle;
 #elif USE_XINPUT
     typedef unsigned long GamepadHandle;

+ 8 - 6
gameplay/src/Form.cpp

@@ -481,10 +481,9 @@ void Form::updateBounds()
         }
  
         _viewportClipBounds.set(x, y, width, height);
-
         _absoluteClipBounds.set(x - border.left - padding.left, y - border.top - padding.top,
-            width + border.left + padding.left + border.right + padding.right,
-            height + border.top + padding.top + border.bottom + padding.bottom);
+                                width + border.left + padding.left + border.right + padding.right,
+                                height + border.top + padding.top + border.bottom + padding.bottom);
         if (_clearBounds.isEmpty())
         {
             _clearBounds.set(_absoluteClipBounds);
@@ -515,9 +514,13 @@ void Form::updateBounds()
 
         GP_ASSERT(_layout);
         if (_scroll != SCROLL_NONE)
+        {
             updateScroll();
+        }
         else
+        {
             _layout->update(this, Vector2::zero());
+        }
     }
 }
 
@@ -546,11 +549,10 @@ void Form::draw()
         Container::draw(_theme->getSpriteBatch(), Rectangle(0, 0, _bounds.width, _bounds.height),  true/*WAS _skin!=NULL*/, false, _bounds.height);
         _theme->setProjectionMatrix(_defaultProjectionMatrix);
 
-        // Rebind the previous framebuffer and game viewport.
-        previousFrameBuffer->bind();
-
         // restore the previous game viewport
         game->setViewport(prevViewport);
+        // Rebind the previous framebuffer and game viewport.
+        previousFrameBuffer->bind();
     }
 
     // Draw either with a 3D quad or sprite batch

+ 0 - 5
gameplay/src/FrameBuffer.cpp

@@ -80,9 +80,6 @@ FrameBuffer* FrameBuffer::create(const char* id)
 
 FrameBuffer* FrameBuffer::create(const char* id, unsigned int width, unsigned int height)
 {
-    // Call getMaxRenderTargets() to force __maxRenderTargets to be set
-    getMaxRenderTargets();
-
     RenderTarget* renderTarget = NULL;
     if (width > 0 && height > 0)
     {
@@ -197,7 +194,6 @@ RenderTarget* FrameBuffer::getRenderTarget(unsigned int index) const
     {
         return _renderTargets[index];
     }
-
     return NULL;
 }
 
@@ -258,5 +254,4 @@ FrameBuffer* FrameBuffer::bindDefault()
     return __defaultFrameBuffer;
 }
 
-
 }

+ 3 - 19
gameplay/src/Gamepad.cpp

@@ -2,32 +2,16 @@
 #include "Gamepad.h"
 #include "Game.h"
 #include "Button.h"
+#include "Platform.h"
 
 namespace gameplay
 {
 
 static std::vector<Gamepad*> __gamepads;
 
-
-
-GamepadHandle _handle;        // The handle of the Gamepad.
-unsigned int _buttonCount;    // Number of buttons.
-unsigned int _joystickCount;  // Number of joysticks.
-unsigned int _triggerCount;   // Number of triggers.
-unsigned int _vendorId;
-unsigned int _productId;
-std::string _vendorString;
-std::string _productString;
-Form* _form;
-Joystick* _uiJoysticks[2];
-Button* _uiButtons[20];
-unsigned int _buttons;
-Vector2 _joysticks[2];
-float _triggers[2];
-
-
 Gamepad::Gamepad(const char* formPath)
-    : _handle((GamepadHandle)INT_MAX),  _buttonCount(0), _joystickCount(0), _triggerCount(0), _vendorId(0), _productId(0), _form(NULL), _buttons(0)
+    : _handle((GamepadHandle)INT_MAX), _buttonCount(0), _joystickCount(0), _triggerCount(0), _vendorId(0), _productId(0),
+      _form(NULL), _buttons(0)
 {
     GP_ASSERT(formPath);
     _form = Form::create(formPath);

+ 9 - 7
gameplay/src/Platform.h

@@ -231,13 +231,6 @@ private:
      */
     static bool isGestureRegistered(Gesture::GestureEvent evt);
 
-    /**
-     * Polls the platform for the updated Gamepad states such as joysticks, buttons and trigger values.
-     *
-     * @param gamepad The gamepad to be returned with the latest polled values populated.
-     */
-    static void pollGamepadState(Gamepad* gamepad);
-
     /**
      * Opens an URL in an external browser, if available.
      *
@@ -295,6 +288,15 @@ public:
      */
     static void gamepadEventDisconnectedInternal(GamepadHandle handle);
 
+    /**
+     * Internal metehod used by Gamepad that polls the platform for the updated Gamepad
+     * states such as joysticks, buttons and trigger values.
+     *
+     * @param gamepad The gamepad to be returned with the latest polled values populated.
+     * @script{ignore}
+     */
+    static void pollGamepadState(Gamepad* gamepad);
+
 private:
 
     Game* _game;                // The game this platform is interfacing with.

+ 11 - 10
gameplay/src/PlatformBlackBerry.cpp

@@ -491,35 +491,31 @@ void gesture_callback(gesture_base_t* gesture, mtouch_event_t* event, void* para
     }
 }
 
-#ifdef BLACKBERRY_USE_GAMEPAD
+#ifdef USE_BLACKBERRY_GAMEPAD
 
 static const char* __vendorStrings[] =
 {
     "SteelSeries",
     "Nintendo",
-    "Fructel"
 };
 
 static const char* __productStrings[] =
 {
     "FREE",
     "Wii Remote",
-    "Gametel"
 };
 
 static const int __VIDs[] = {
     0x1038,
     0x057e,
-    0x25b6
 };
 
 static const int __PIDs[] = {
     0x1412,
     0x0306,
-    0x0001
 };
 
-static const unsigned int __knownGamepads = 3;
+static const unsigned int __knownGamepads = 2;
 
 void queryGamepad(GamepadHandle handle, int* buttonCount, int* joystickCount, int* productId, int* vendorId, char* productString, char* vendorString)
 {
@@ -627,6 +623,10 @@ void Platform::pollGamepadState(Gamepad* gamepad)
         gamepad->_triggers[i] = value;
     }
 }
+#else
+void Platform::pollGamepadState(Gamepad* gamepad)
+{
+}
 #endif
 
 Platform::Platform(Game* game)
@@ -683,8 +683,6 @@ Platform* Platform::create(Game* game, void* attachToWindow)
     FileSystem::setResourcePath("./app/native/");
     Platform* platform = new Platform(game);
 
-    screen_device_t* screenDevs;
-
     // Query game config
     int samples = 0;
     Properties* config = Game::getInstance()->getConfig()->getNamespace("window", true);
@@ -972,7 +970,10 @@ Platform* Platform::create(Game* game, void* attachToWindow)
         glIsVertexArray = (PFNGLISVERTEXARRAYOESPROC)eglGetProcAddress("glIsVertexArrayOES");
     }
 
- #ifdef BLACKBERRY_USE_GAMEPAD
+ #ifdef USE_BLACKBERRY_GAMEPAD
+
+    screen_device_t* screenDevs;
+
     // Discover initial gamepad devices.
     int count;
     screen_get_context_property_iv(__screenContext, SCREEN_PROPERTY_DEVICE_COUNT, &count);
@@ -1220,7 +1221,7 @@ int Platform::enterMessagePump()
                         }
                         break;
                     }
-#ifdef BLACKBERRY_USE_GAMEPAD
+#ifdef USE_BLACKBERRY_GAMEPAD
                     case SCREEN_EVENT_DEVICE:
                     {
                         // A device was attached or removed.

+ 1 - 0
gameplay/src/Terrain.h

@@ -6,6 +6,7 @@
 #include "HeightField.h"
 #include "Texture.h"
 #include "BoundingBox.h"
+#include "TerrainPatch.h"
 
 namespace gameplay
 {

+ 2 - 2
gameplay/src/gameplay.h

@@ -38,8 +38,6 @@
 #include "VertexFormat.h"
 #include "VertexAttributeBinding.h"
 #include "Model.h"
-#include "HeightField.h"
-#include "Terrain.h"
 #include "Camera.h"
 #include "Light.h"
 #include "Scene.h"
@@ -52,6 +50,8 @@
 #include "RenderTarget.h"
 #include "DepthStencilTarget.h"
 #include "ScreenDisplayer.h"
+#include "HeightField.h"
+#include "Terrain.h"
 
 // Audio
 #include "AudioController.h"