Просмотр исходного кода

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

Karim Ahmed 13 лет назад
Родитель
Сommit
dd4df71d70
73 измененных файлов с 1190 добавлено и 410 удалено
  1. 11 11
      CHANGES.md
  2. 9 2
      CMakeLists.txt
  3. 1 1
      README.md
  4. 5 4
      gameplay-encoder/CMakeLists.txt
  5. 1 1
      gameplay-encoder/README.md
  6. 3 3
      gameplay-encoder/gameplay-bundle.txt
  7. 1 1
      gameplay-encoder/src/Animation.cpp
  8. 2 2
      gameplay-encoder/src/AnimationChannel.cpp
  9. 1 1
      gameplay-encoder/src/Animations.cpp
  10. 1 7
      gameplay-encoder/src/FileIO.cpp
  11. 2 3
      gameplay-encoder/src/FileIO.h
  12. 3 3
      gameplay-encoder/src/GPBFile.cpp
  13. 2 2
      gameplay-encoder/src/Mesh.cpp
  14. 2 2
      gameplay-encoder/src/MeshSkin.cpp
  15. 2 2
      gameplay-encoder/src/Object.h
  16. 1 1
      gameplay-encoder/src/ReferenceTable.cpp
  17. 13 13
      gameplay/CMakeLists.txt
  18. 1 1
      gameplay/src/AnimationClip.cpp
  19. 1 1
      gameplay/src/AnimationTarget.h
  20. 0 25
      gameplay/src/Base.h
  21. 1 1
      gameplay/src/Bundle.h
  22. 1 1
      gameplay/src/Button.h
  23. 1 1
      gameplay/src/CheckBox.h
  24. 16 14
      gameplay/src/Container.cpp
  25. 11 3
      gameplay/src/Container.h
  26. 18 3
      gameplay/src/DepthStencilTarget.cpp
  27. 18 6
      gameplay/src/DepthStencilTarget.h
  28. 4 4
      gameplay/src/Effect.cpp
  29. 1 4
      gameplay/src/FileSystem.cpp
  30. 8 1
      gameplay/src/FileSystem.h
  31. 1 1
      gameplay/src/Form.cpp
  32. 1 1
      gameplay/src/Form.h
  33. 57 56
      gameplay/src/FrameBuffer.cpp
  34. 20 1
      gameplay/src/FrameBuffer.h
  35. 1 1
      gameplay/src/Gamepad.h
  36. 1 1
      gameplay/src/Joystick.h
  37. 1 1
      gameplay/src/Label.h
  38. 1 1
      gameplay/src/Logger.cpp
  39. 1 1
      gameplay/src/Matrix.h
  40. 1 21
      gameplay/src/Mesh.cpp
  41. 2 19
      gameplay/src/MeshPart.cpp
  42. 1 1
      gameplay/src/Node.cpp
  43. 1 1
      gameplay/src/Node.h
  44. 3 3
      gameplay/src/PhysicsCharacter.cpp
  45. 1 1
      gameplay/src/PhysicsCollisionObject.h
  46. 1 1
      gameplay/src/PhysicsController.cpp
  47. 10 0
      gameplay/src/PhysicsRigidBody.cpp
  48. 72 3
      gameplay/src/PhysicsRigidBody.h
  49. 38 0
      gameplay/src/PhysicsRigidBody.inl
  50. 1 1
      gameplay/src/PhysicsVehicleWheel.h
  51. 6 9
      gameplay/src/PlatformBlackBerry.cpp
  52. 3 3
      gameplay/src/PlatformWindows.cpp
  53. 1 1
      gameplay/src/Quaternion.cpp
  54. 1 1
      gameplay/src/RadioButton.h
  55. 125 135
      gameplay/src/RenderState.cpp
  56. 64 6
      gameplay/src/RenderState.h
  57. 20 1
      gameplay/src/RenderTarget.cpp
  58. 30 0
      gameplay/src/RenderTarget.h
  59. 2 0
      gameplay/src/ScriptController.cpp
  60. 1 1
      gameplay/src/ScriptController.h
  61. 1 1
      gameplay/src/Slider.h
  62. 18 12
      gameplay/src/Texture.cpp
  63. 21 0
      gameplay/src/Texture.h
  64. 37 0
      gameplay/src/lua/lua_FileSystem.cpp
  65. 1 0
      gameplay/src/lua/lua_FileSystem.h
  66. 38 0
      gameplay/src/lua/lua_Game.cpp
  67. 1 0
      gameplay/src/lua/lua_Game.h
  68. 229 0
      gameplay/src/lua/lua_PhysicsRigidBody.cpp
  69. 4 0
      gameplay/src/lua/lua_PhysicsRigidBody.h
  70. 199 1
      gameplay/src/lua/lua_PhysicsRigidBodyParameters.cpp
  71. 2 0
      gameplay/src/lua/lua_PhysicsRigidBodyParameters.h
  72. 29 0
      gameplay/src/lua/lua_Platform.cpp
  73. 1 0
      gameplay/src/lua/lua_Platform.h

+ 11 - 11
CHANGES.md

@@ -5,22 +5,22 @@
 - CodeBlocks 10 IDE support for Linux.
 - CodeBlocks 10 IDE support for Linux.
 - Gamepad controllers support for desktops.
 - Gamepad controllers support for desktops.
 - Touch gesture support for tap, swipe and pinch.
 - Touch gesture support for tap, swipe and pinch.
-- Vehicle phyics support via new PhysicsVehicle and PhysicsVehicleWheel classes.
+- Vehicle physics support via new PhysicsVehicle and PhysicsVehicleWheel classes.
 - Adds new racer sample (sample06-racer).
 - Adds new racer sample (sample06-racer).
 - Adds gameplay-tests project as a test app for various basic engine features with some initial tests.
 - Adds gameplay-tests project as a test app for various basic engine features with some initial tests.
 - Adds support for Scene files for wildcard identifiers.
 - Adds support for Scene files for wildcard identifiers.
 - Adds Visual Studio Plug-in support for BlackBerry PlayBook and BlackBerry 10.
 - Adds Visual Studio Plug-in support for BlackBerry PlayBook and BlackBerry 10.
 - Adds configurable multi-sampling anti-aliasing support. 
 - Adds configurable multi-sampling anti-aliasing support. 
 - Adds updates to latest FBX SDK 2013.3.
 - Adds updates to latest FBX SDK 2013.3.
-- Adds file formats documenation for game.config .scene, .material, .animation, .physics, .particle
+- Adds file formats documentation for game.config .scene, .material, .animation, .physics, .particle
 - Adds Game/Platform::canExit for testing device capabilities to quit. (only ios)
 - Adds Game/Platform::canExit for testing device capabilities to quit. (only ios)
 - Web community forums at http://www.gameplay3d.org/forums.
 - Web community forums at http://www.gameplay3d.org/forums.
 - Changed keyTimes from unsigned long[]  to unsigned int[]. (breaks compat. in AnimationTarget and Animation::Channel)
 - Changed keyTimes from unsigned long[]  to unsigned int[]. (breaks compat. in AnimationTarget and Animation::Channel)
 - Fixed inconsistencies from Bundle::getObjectID() to Bundle::getObjectId() (breaks compat. in Bundle)
 - Fixed inconsistencies from Bundle::getObjectID() to Bundle::getObjectId() (breaks compat. in Bundle)
 - Fixes the texture coordinates of Mesh::createQuad(float x, float y, float width, float height).
 - Fixes the texture coordinates of Mesh::createQuad(float x, float y, float width, float height).
-- Fixes line-wise distortion when loading RGB png's into texture that are non-power of two.
-- Fixes inconsitencies in createXXXX methods.  (breaks compat. in Scene)
-- Fixes Rectanngle::contains.
+- Fixes line-wise distortion when loading RGB png's into textures that are non-power of two.
+- Fixes inconsistencies in createXXXX methods.  (breaks compat. in Scene)
+- Fixes Rectangle::contains.
 - Fixes Lua print logging.
 - Fixes Lua print logging.
 - Fixes Lua errors to be treated as runtime warnings.
 - Fixes Lua errors to be treated as runtime warnings.
 - Fixes setVertexData to pointers instead of constant data.
 - Fixes setVertexData to pointers instead of constant data.
@@ -31,7 +31,7 @@
 
 
 - Lua script bindings for all gameplay interfaces.
 - Lua script bindings for all gameplay interfaces.
 - Lua script binding generator tool (gameplay-luagen) for generating gameplay Lua bindings from doxygen xml output.
 - Lua script binding generator tool (gameplay-luagen) for generating gameplay Lua bindings from doxygen xml output.
-- AIController, AIAgent, AIStateMachine, AIState and AIMessage clases for scripted AI support.
+- AIController, AIAgent, AIStateMachine, AIState and AIMessage classes for scripted AI support.
 - Sample for sample05-lua to demonstrate basic Lua with AI scripting.
 - Sample for sample05-lua to demonstrate basic Lua with AI scripting.
 - Gamepad class with virtual gamepad support.
 - Gamepad class with virtual gamepad support.
 - Pre-built versions gameplay-encoder added to bin folder with TTF, DAE and FBX support built-in.
 - Pre-built versions gameplay-encoder added to bin folder with TTF, DAE and FBX support built-in.
@@ -76,10 +76,10 @@
 - BlackBerry 10 support.
 - BlackBerry 10 support.
 - iOS 5.1 support.
 - iOS 5.1 support.
 - Android 2.3+ support.
 - Android 2.3+ support.
-- User interface system with declaritive forms and themes.
+- User interface system with declarative forms and themes.
 - Bluetooth keyboard/mouse support on BlackBerry platform.
 - Bluetooth keyboard/mouse support on BlackBerry platform.
 - Developer guide.
 - Developer guide.
-- Sample/turorial for sample03-character.
+- Sample/tutorial for sample03-character.
 - Sample for sample04-particles to demonstrate particle emitters.
 - Sample for sample04-particles to demonstrate particle emitters.
 - Fixes for loading properties from URL.
 - Fixes for loading properties from URL.
 - Fixes on Win32/MacOSX for when mouse pointer leaves the window and returns.
 - Fixes on Win32/MacOSX for when mouse pointer leaves the window and returns.
@@ -91,8 +91,8 @@
 
 
 - FBX support in gameplay-encoder.
 - FBX support in gameplay-encoder.
 - MacOSX platform support using XCode.
 - MacOSX platform support using XCode.
-- Offscreen rendering functionality using FrameBuffer.
-- Loading 3D scences using declaritive .scene files.
+- Off-screen rendering functionality using FrameBuffer.
+- Loading 3D scenes using declarative  .scene files.
 - Loading audio from .ogg files using vorbis.
 - Loading audio from .ogg files using vorbis.
 - Loading AudioSources from .audio files.
 - Loading AudioSources from .audio files.
 - Loading Animations from .animation files.
 - Loading Animations from .animation files.
@@ -103,7 +103,7 @@
 - Font improvements for justify, clip, wrap and scaling.
 - Font improvements for justify, clip, wrap and scaling.
 - Fixes for Font::drawText to use point size and not float scalar.
 - Fixes for Font::drawText to use point size and not float scalar.
 - Fixes for memory leaks in and fixes to AnimationTarget.
 - Fixes for memory leaks in and fixes to AnimationTarget.
-- Fixes for bumped and paralax shaders.
+- Fixes for bumped and parallax shaders.
 - Fixes to simplify folders for resources in samples.
 - Fixes to simplify folders for resources in samples.
 - Fixes to the material/shader system.
 - Fixes to the material/shader system.
 - Fixes to the ParticleEmitter.
 - Fixes to the ParticleEmitter.

+ 9 - 2
CMakeLists.txt

@@ -2,15 +2,22 @@ cmake_minimum_required(VERSION 2.6)
 
 
 project(GamePlay)
 project(GamePlay)
 
 
-set(GAMEPLAY_VERSION 1.5.0)
+set(GAMEPLAY_VERSION 1.6.0)
 set(CMAKE_C_COMPILER_INIT g++)
 set(CMAKE_C_COMPILER_INIT g++)
 
 
 # debug
 # debug
 message( "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" )
 message( "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}" )
-if( "${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG" )
+if ( "${CMAKE_BUILD_TYPE}" STREQUAL "DEBUG" )
     add_definitions(-D_DEBUG)
     add_definitions(-D_DEBUG)
 endif()
 endif()
 
 
+# architecture
+if ( CMAKE_SIZEOF_VOID_P EQUAL 8 )
+set(ARCH_DIR "x64")
+else()
+set(ARCH_DIR "x86")
+endif()
+
 # gameplay library
 # gameplay library
 add_subdirectory(gameplay)
 add_subdirectory(gameplay)
 
 

+ 1 - 1
README.md

@@ -16,7 +16,7 @@ An open-source, cross-platform 3D native C++ game framework making it easy to le
 - Terrain and Water
 - Terrain and Water
 - Asset Pipeline improvements
 - Asset Pipeline improvements
 
 
-## Licence
+## License
 The project is open sourced under the Apache 2.0 license.
 The project is open sourced under the Apache 2.0 license.
 
 
 ## Bug Reporting and Feature Requests
 ## Bug Reporting and Feature Requests

+ 5 - 4
gameplay-encoder/CMakeLists.txt

@@ -9,13 +9,14 @@ include_directories(
     /usr/include
     /usr/include
 )
 )
 
 
+add_definitions(-D_DEBUG)
 add_definitions(-D__linux__ -DNO_BOOST -DNO_ZAE)
 add_definitions(-D__linux__ -DNO_BOOST -DNO_ZAE)
 
 
 link_directories(
 link_directories(
-    ${CMAKE_SOURCE_DIR}/external-deps/zlib/lib/linux
-    ${CMAKE_SOURCE_DIR}/external-deps/libpng/lib/linux
-    ${CMAKE_SOURCE_DIR}/external-deps/freetype2/lib/linux
-    ${CMAKE_SOURCE_DIR}/external-deps/collada-dom/lib/linux
+    ${CMAKE_SOURCE_DIR}/external-deps/zlib/lib/linux/${ARCH_DIR}
+    ${CMAKE_SOURCE_DIR}/external-deps/libpng/lib/linux/${ARCH_DIR}
+    ${CMAKE_SOURCE_DIR}/external-deps/freetype2/lib/linux/${ARCH_DIR}
+    ${CMAKE_SOURCE_DIR}/external-deps/collada-dom/lib/linux/${ARCH_DIR}
     /usr/lib
     /usr/lib
 )
 )
 
 

+ 1 - 1
gameplay-encoder/README.md

@@ -22,7 +22,7 @@ For more information goto "http://www.autodesk.com/fbx".
 
 
 ## Building gameplay-encoder
 ## Building gameplay-encoder
 The gameplay-encoder comes pre-built for Windows 7, MacOS X and Linux x64 in the 'bin' folder.
 The gameplay-encoder comes pre-built for Windows 7, MacOS X and Linux x64 in the 'bin' folder.
-However, to build the gameplay-ecoder yourself just open either the 
+However, to build the gameplay-encoder yourself just open either the 
 Visual Studio 2010 project "gameplay-encoder.vccproj" on Windows 7 or
 Visual Studio 2010 project "gameplay-encoder.vccproj" on Windows 7 or
 XCode project "gameplay-encoder.xcodeproj" on MacOSX.
 XCode project "gameplay-encoder.xcodeproj" on MacOSX.
 Uncomment the root CMakeList.txt for the gameplay-encoder and run standard cmake .. from build then make.
 Uncomment the root CMakeList.txt for the gameplay-encoder and run standard cmake .. from build then make.

+ 3 - 3
gameplay-encoder/gameplay-bundle.txt

@@ -3,7 +3,7 @@ gameplay Bundle File Format (.gpb)
 
 
 File Description
 File Description
 ================
 ================
-A simple binary bundle file format supporting definition of primitve and builtin objects.
+A simple binary bundle file format supporting definition of primitive and built-in objects.
 
 
 File Extension and Mime Type
 File Extension and Mime Type
 ============================
 ============================
@@ -15,7 +15,7 @@ File Structure
 Section      Name            Type
 Section      Name            Type
 ------------------------------------------------------------------------------------------------------
 ------------------------------------------------------------------------------------------------------
 Header
 Header
-             Identifier      byte[9]     = { '«', 'G', 'P', 'B', '»', '\r', '\n', '\x1A', '\n' } 
+             Identifier      byte[9]     = { '\xAB', 'G', 'P', 'B', '\xBB', '\r', '\n', '\x1A', '\n' } 
              Version         byte[2]     = { 1, 1 }
              Version         byte[2]     = { 1, 1 }
              References      Reference[]
              References      Reference[]
 Data
 Data
@@ -42,7 +42,7 @@ Xrefs
 Xrefs are string with a specific format used for referencing objects internal and external to
 Xrefs are string with a specific format used for referencing objects internal and external to
 a package. An xref with the format "#id" references an object within the current package with
 a package. An xref with the format "#id" references an object within the current package with
 the given ID. Xrefs can also have the format "file#id", where "file" is the name of package file
 the given ID. Xrefs can also have the format "file#id", where "file" is the name of package file
-(relative to the locaiton of the current package) and "id" is the unique identifier of an object
+(relative to the location of the current package) and "id" is the unique identifier of an object
 in that bundle.
 in that bundle.
 
 
 Primitives
 Primitives

+ 1 - 1
gameplay-encoder/src/Animation.cpp

@@ -26,7 +26,7 @@ void Animation::writeBinary(FILE* file)
     Object::writeBinary(file);
     Object::writeBinary(file);
     // Animation writes its ID because it is not listed in the ref table.
     // Animation writes its ID because it is not listed in the ref table.
     write(getId(), file);
     write(getId(), file);
-    write(_channels.size(), file);
+    write((unsigned int)_channels.size(), file);
     for (std::vector<AnimationChannel*>::iterator i = _channels.begin(); i != _channels.end(); ++i)
     for (std::vector<AnimationChannel*>::iterator i = _channels.begin(); i != _channels.end(); ++i)
     {
     {
         (*i)->writeBinary(file);
         (*i)->writeBinary(file);

+ 2 - 2
gameplay-encoder/src/AnimationChannel.cpp

@@ -28,10 +28,10 @@ void AnimationChannel::writeBinary(FILE* file)
     Object::writeBinary(file);
     Object::writeBinary(file);
     write(_targetId, file);
     write(_targetId, file);
     write(_targetAttrib, file);
     write(_targetAttrib, file);
-    write(_keytimes.size(), file);
+    write((unsigned int)_keytimes.size(), file);
     for (std::vector<float>::const_iterator i = _keytimes.begin(); i != _keytimes.end(); ++i)
     for (std::vector<float>::const_iterator i = _keytimes.begin(); i != _keytimes.end(); ++i)
     {
     {
-        write((unsigned long)*i, file);
+        write((unsigned int)*i, file);
     }
     }
     write(_keyValues, file);
     write(_keyValues, file);
     write(_tangentsIn, file);
     write(_tangentsIn, file);

+ 1 - 1
gameplay-encoder/src/Animations.cpp

@@ -27,7 +27,7 @@ const char* Animations::getElementName(void) const
 void Animations::writeBinary(FILE* file)
 void Animations::writeBinary(FILE* file)
 {
 {
     Object::writeBinary(file);
     Object::writeBinary(file);
-    write(_animations.size(), file);
+    write((unsigned int)_animations.size(), file);
     for (std::vector<Animation*>::iterator i = _animations.begin(); i != _animations.end(); ++i)
     for (std::vector<Animation*>::iterator i = _animations.begin(); i != _animations.end(); ++i)
     {
     {
         (*i)->writeBinary(file);
         (*i)->writeBinary(file);

+ 1 - 7
gameplay-encoder/src/FileIO.cpp

@@ -31,12 +31,6 @@ void write(unsigned int value, FILE* file)
     assert(r == 1);
     assert(r == 1);
 }
 }
 
 
-void write(unsigned long value, FILE* file)
-{
-    size_t r = fwrite(&value, sizeof(unsigned long), 1, file);
-    assert(r == 1);
-}
-
 void write(unsigned short value, FILE* file)
 void write(unsigned short value, FILE* file)
 {
 {
     size_t r = fwrite(&value, sizeof(unsigned short), 1, file);
     size_t r = fwrite(&value, sizeof(unsigned short), 1, file);
@@ -63,7 +57,7 @@ void write(const float* values, int length, FILE* file)
 void write(const std::string& str, FILE* file)
 void write(const std::string& str, FILE* file)
 {
 {
     // Write the length of the string
     // Write the length of the string
-    write(str.size(), file);
+    write((unsigned int)str.size(), file);
     
     
     if (str.size() > 0)
     if (str.size() > 0)
     {
     {

+ 2 - 3
gameplay-encoder/src/FileIO.h

@@ -64,7 +64,6 @@ void write(unsigned char value, FILE* file);
 void write(char value, FILE* file);
 void write(char value, FILE* file);
 void write(const char* str, FILE* file);
 void write(const char* str, FILE* file);
 void write(unsigned int value, FILE* file);
 void write(unsigned int value, FILE* file);
-void write(unsigned long value, FILE* file);
 void write(unsigned short value, FILE* file);
 void write(unsigned short value, FILE* file);
 void write(bool value, FILE* file);
 void write(bool value, FILE* file);
 void write(float value, FILE* file);
 void write(float value, FILE* file);
@@ -87,7 +86,7 @@ template <class T>
 void write(std::list<T> list, FILE* file)
 void write(std::list<T> list, FILE* file)
 {
 {
     // First write the size of the list
     // First write the size of the list
-    write(list.size(), file);
+    write((unsigned int)list.size(), file);
     // Then write each element
     // Then write each element
     typename std::list<T>::const_iterator i;
     typename std::list<T>::const_iterator i;
     for (i = list.begin(); i != list.end(); ++i)
     for (i = list.begin(); i != list.end(); ++i)
@@ -106,7 +105,7 @@ template <class T>
 void write(std::vector<T> vector, FILE* file)
 void write(std::vector<T> vector, FILE* file)
 {
 {
     // First write the size of the vector
     // First write the size of the vector
-    write(vector.size(), file);
+    write((unsigned int)vector.size(), file);
     // Then write each element
     // Then write each element
     typename std::vector<T>::const_iterator i;
     typename std::vector<T>::const_iterator i;
     for (i = vector.begin(); i != vector.end(); ++i)
     for (i = vector.begin(); i != vector.end(); ++i)

+ 3 - 3
gameplay-encoder/src/GPBFile.cpp

@@ -67,7 +67,7 @@ bool GPBFile::saveBinary(const std::string& filepath)
     size_t n = 0;
     size_t n = 0;
 
 
     // identifier
     // identifier
-    char identifier[] = { '�', 'G', 'P', 'B', '�', '\r', '\n', '\x1A', '\n' };
+    char identifier[] = { '\xAB', 'G', 'P', 'B', '\xBB', '\r', '\n', '\x1A', '\n' };
     n = fwrite(identifier, 1, sizeof(identifier), _file);
     n = fwrite(identifier, 1, sizeof(identifier), _file);
     if (n != sizeof(identifier))
     if (n != sizeof(identifier))
     {
     {
@@ -89,14 +89,14 @@ bool GPBFile::saveBinary(const std::string& filepath)
     _refTable.writeBinary(_file);
     _refTable.writeBinary(_file);
 
 
     // meshes
     // meshes
-    write(_geometry.size(), _file);
+    write((unsigned int)_geometry.size(), _file);
     for (std::list<Mesh*>::const_iterator i = _geometry.begin(); i != _geometry.end(); ++i)
     for (std::list<Mesh*>::const_iterator i = _geometry.begin(); i != _geometry.end(); ++i)
     {
     {
         (*i)->writeBinary(_file);
         (*i)->writeBinary(_file);
     }
     }
 
 
     // Objects
     // Objects
-    write(_objects.size(), _file);
+    write((unsigned int)_objects.size(), _file);
     for (std::list<Object*>::const_iterator i = _objects.begin(); i != _objects.end(); ++i)
     for (std::list<Object*>::const_iterator i = _objects.begin(); i != _objects.end(); ++i)
     {
     {
         (*i)->writeBinary(_file);
         (*i)->writeBinary(_file);

+ 2 - 2
gameplay-encoder/src/Mesh.cpp

@@ -27,7 +27,7 @@ void Mesh::writeBinary(FILE* file)
 {
 {
     Object::writeBinary(file);
     Object::writeBinary(file);
     // vertex formats
     // vertex formats
-    write(_vertexFormat.size(), file);
+    write((unsigned int)_vertexFormat.size(), file);
     for (std::vector<VertexElement>::iterator i = _vertexFormat.begin(); i != _vertexFormat.end(); ++i)
     for (std::vector<VertexElement>::iterator i = _vertexFormat.begin(); i != _vertexFormat.end(); ++i)
     {
     {
         i->writeBinary(file);
         i->writeBinary(file);
@@ -45,7 +45,7 @@ void Mesh::writeBinaryVertices(FILE* file)
         // Assumes that all vertices are the same size.
         // Assumes that all vertices are the same size.
         // Write the number of bytes for the vertex data
         // Write the number of bytes for the vertex data
         const Vertex& vertex = vertices.front();
         const Vertex& vertex = vertices.front();
-        write(vertices.size() * vertex.byteSize(), file); // (vertex count) * (vertex size)
+        write((unsigned int)(vertices.size() * vertex.byteSize()), file); // (vertex count) * (vertex size)
 
 
         // for each vertex
         // for each vertex
         for (std::vector<Vertex>::const_iterator i = vertices.begin(); i != vertices.end(); ++i)
         for (std::vector<Vertex>::const_iterator i = vertices.begin(); i != vertices.end(); ++i)

+ 2 - 2
gameplay-encoder/src/MeshSkin.cpp

@@ -36,12 +36,12 @@ void MeshSkin::writeBinary(FILE* file)
 {
 {
     Object::writeBinary(file);
     Object::writeBinary(file);
     write(_bindShape, 16, file);
     write(_bindShape, 16, file);
-    write(_joints.size(), file);
+    write((unsigned int)_joints.size(), file);
     for (std::vector<Node*>::const_iterator i = _joints.begin(); i != _joints.end(); ++i)
     for (std::vector<Node*>::const_iterator i = _joints.begin(); i != _joints.end(); ++i)
     {
     {
         (*i)->writeBinaryXref(file);
         (*i)->writeBinaryXref(file);
     }
     }
-    write(_bindPoses.size() * 16, file);
+    write((unsigned int)_bindPoses.size() * 16, file);
     for (std::vector<Matrix>::const_iterator i = _bindPoses.begin(); i != _bindPoses.end(); ++i)
     for (std::vector<Matrix>::const_iterator i = _bindPoses.begin(); i != _bindPoses.end(); ++i)
     {
     {
         write(i->m, 16, file);
         write(i->m, 16, file);

+ 2 - 2
gameplay-encoder/src/Object.h

@@ -109,7 +109,7 @@ public:
     static void writeBinaryObjects(std::list<T> list, FILE* file)
     static void writeBinaryObjects(std::list<T> list, FILE* file)
     {
     {
         // First write the size of the list
         // First write the size of the list
-        write(list.size(), file);
+        write((unsigned int)list.size(), file);
         // Then write each element
         // Then write each element
         typename std::list<T>::const_iterator i;
         typename std::list<T>::const_iterator i;
         for (i = list.begin(); i != list.end(); ++i)
         for (i = list.begin(); i != list.end(); ++i)
@@ -125,7 +125,7 @@ public:
     static void writeBinaryObjects(std::vector<T> vector, FILE* file)
     static void writeBinaryObjects(std::vector<T> vector, FILE* file)
     {
     {
         // First write the size of the vector
         // First write the size of the vector
-        write(vector.size(), file);
+        write((unsigned int)vector.size(), file);
         // Then write each element
         // Then write each element
         typename std::vector<T>::const_iterator i;
         typename std::vector<T>::const_iterator i;
         for (i = vector.begin(); i != vector.end(); ++i)
         for (i = vector.begin(); i != vector.end(); ++i)

+ 1 - 1
gameplay-encoder/src/ReferenceTable.cpp

@@ -30,7 +30,7 @@ Object* ReferenceTable::get(const std::string& xref)
 
 
 void ReferenceTable::writeBinary(FILE* file)
 void ReferenceTable::writeBinary(FILE* file)
 {
 {
-    write(_table.size(), file);
+    write((unsigned int)_table.size(), file);
     for ( std::map<std::string, Reference>::iterator i=_table.begin() ; i != _table.end(); ++i)
     for ( std::map<std::string, Reference>::iterator i=_table.begin() ; i != _table.end(); ++i)
     {
     {
         i->second.writeBinary(file);
         i->second.writeBinary(file);

+ 13 - 13
gameplay/CMakeLists.txt

@@ -77,7 +77,7 @@ set(GAMEPLAY_SRC
     src/gameplay-main-blackberry.cpp
     src/gameplay-main-blackberry.cpp
     src/gameplay-main-linux.cpp
     src/gameplay-main-linux.cpp
     src/gameplay-main-windows.cpp
     src/gameplay-main-windows.cpp
-	src/Gesture.h
+    src/Gesture.h
     src/Image.cpp
     src/Image.cpp
     src/Image.h
     src/Image.h
     src/Image.inl
     src/Image.inl
@@ -146,10 +146,10 @@ set(GAMEPLAY_SRC
     src/PhysicsSocketConstraint.h
     src/PhysicsSocketConstraint.h
     src/PhysicsSpringConstraint.cpp
     src/PhysicsSpringConstraint.cpp
     src/PhysicsSpringConstraint.h
     src/PhysicsSpringConstraint.h
-	src/PhysicsVehicle.cpp
-	src/PhysicsVehicle.h
-	src/PhysicsVehicleWheel.cpp
-	src/PhysicsVehicle.h
+    src/PhysicsVehicle.cpp
+    src/PhysicsVehicle.h
+    src/PhysicsVehicleWheel.cpp
+    src/PhysicsVehicle.h
     src/Plane.cpp
     src/Plane.cpp
     src/Plane.h
     src/Plane.h
     src/Plane.inl
     src/Plane.inl
@@ -333,10 +333,10 @@ set(GAMEPLAY_LUA
     src/lua/lua_GamepadGamepadEvent.h
     src/lua/lua_GamepadGamepadEvent.h
     src/lua/lua_GameState.cpp
     src/lua/lua_GameState.cpp
     src/lua/lua_GameState.h
     src/lua/lua_GameState.h
-	src/lua/lua_Gesture.cpp
-	src/lua/lua_Gesture.h
-	src/lua/lua_GestureGestureEvent.cpp
-	src/lua/lua_GestureGestureEvent.h
+    src/lua/lua_Gesture.cpp
+    src/lua/lua_Gesture.h
+    src/lua/lua_GestureGestureEvent.cpp
+    src/lua/lua_GestureGestureEvent.h
     src/lua/lua_Global.cpp
     src/lua/lua_Global.cpp
     src/lua/lua_Global.h
     src/lua/lua_Global.h
     src/lua/lua_Image.cpp
     src/lua/lua_Image.cpp
@@ -451,10 +451,10 @@ set(GAMEPLAY_LUA
     src/lua/lua_PhysicsSocketConstraint.h
     src/lua/lua_PhysicsSocketConstraint.h
     src/lua/lua_PhysicsSpringConstraint.cpp
     src/lua/lua_PhysicsSpringConstraint.cpp
     src/lua/lua_PhysicsSpringConstraint.h
     src/lua/lua_PhysicsSpringConstraint.h
-	src/lua/lua_PhysicsVehicle.cpp
-	src/lua/lua_PhysicsVehicle.h
-	src/lua/lua_PhysicsVehicleWheel.cpp
-	src/lua/lua_PhysicsVehicleWheel.h
+    src/lua/lua_PhysicsVehicle.cpp
+    src/lua/lua_PhysicsVehicle.h
+    src/lua/lua_PhysicsVehicleWheel.cpp
+    src/lua/lua_PhysicsVehicleWheel.h
     src/lua/lua_Plane.cpp
     src/lua/lua_Plane.cpp
     src/lua/lua_Plane.h
     src/lua/lua_Plane.h
     src/lua/lua_Platform.cpp
     src/lua/lua_Platform.cpp

+ 1 - 1
gameplay/src/AnimationClip.cpp

@@ -249,7 +249,7 @@ void AnimationClip::crossFade(AnimationClip* clip, unsigned long duration)
     _crossFadeToClip->setClipStateBit(CLIP_IS_FADING_IN_BIT);
     _crossFadeToClip->setClipStateBit(CLIP_IS_FADING_IN_BIT);
     _crossFadeToClip->_blendWeight = 0.0f;
     _crossFadeToClip->_blendWeight = 0.0f;
     
     
-    // Set and intiliaze this clip to fade out
+    // Set and initialize this clip to fade out
     setClipStateBit(CLIP_IS_FADING_OUT_STARTED_BIT);
     setClipStateBit(CLIP_IS_FADING_OUT_STARTED_BIT);
     setClipStateBit(CLIP_IS_FADING_OUT_BIT);
     setClipStateBit(CLIP_IS_FADING_OUT_BIT);
     _crossFadeOutElapsed = 0.0f;
     _crossFadeOutElapsed = 0.0f;

+ 1 - 1
gameplay/src/AnimationTarget.h

@@ -215,7 +215,7 @@ private:
      *
      *
      * @param type The TargetType of the AnimationTarget.
      * @param type The TargetType of the AnimationTarget.
      * @param propertyIdStr The property ID string.
      * @param propertyIdStr The property ID string.
-     * @return The property ID value for teh property ID string; -1 if the propertyIdStr does not exist
+     * @return The property ID value for the property ID string; -1 if the propertyIdStr does not exist
      *    for the TargetType.
      *    for the TargetType.
      */
      */
     static int getPropertyId(TargetType type, const char* propertyIdStr);
     static int getPropertyId(TargetType type, const char* propertyIdStr);

+ 0 - 25
gameplay/src/Base.h

@@ -295,35 +295,10 @@ typedef GLuint RenderBufferHandle;
     } while(0)
     } while(0)
 #endif
 #endif
 
 
-/**
- * Executes the specified GL code and checks the GL error afterwards
- * to ensure it succeeded.
- *
- * This macro should be used instead of GL_ASSERT for code that must
- * be checked in both debug and release builds. The GL_LAST_ERROR
- * macro can be used afterwards to check whether a GL error was
- * encountered executing the specified code.
- */
-#define GL_CHECK( gl_code ) do \
-    { \
-        while (glGetError() != GL_NO_ERROR) ; \
-        gl_code; \
-        __gl_error_code = glGetError(); \
-        if (__gl_error_code != GL_NO_ERROR) \
-        { \
-            GP_ERROR(#gl_code ": %d", (int)__gl_error_code); \
-        } \
-    } while(0)
-
 /** Global variable to hold GL errors
 /** Global variable to hold GL errors
  * @script{ignore} */
  * @script{ignore} */
 extern GLenum __gl_error_code;
 extern GLenum __gl_error_code;
 
 
-/**
- * Accesses the most recently set global GL error.
- */
-#define GL_LAST_ERROR() __gl_error_code
-
 /**
 /**
  * Executes the specified AL code and checks the AL error afterwards
  * Executes the specified AL code and checks the AL error afterwards
  * to ensure it succeeded.
  * to ensure it succeeded.

+ 1 - 1
gameplay/src/Bundle.h

@@ -285,7 +285,7 @@ private:
      * 
      * 
      * @param length A pointer to where the length of the array will be copied to.
      * @param length A pointer to where the length of the array will be copied to.
      * @param values A pointer to the vector to copy the values to. The vector will be resized if it is smaller than length.
      * @param values A pointer to the vector to copy the values to. The vector will be resized if it is smaller than length.
-     * @param readSize The size that reads will be preformed at, size must be the same as or smaller then the sizeof(T)
+     * @param readSize The size that reads will be performed at, size must be the same as or smaller then the sizeof(T)
      * 
      * 
      * @return True if successful, false if an error occurred.
      * @return True if successful, false if an error occurred.
      */
      */

+ 1 - 1
gameplay/src/Button.h

@@ -27,7 +27,7 @@ namespace gameplay
          width       = <width>   // Can be used in place of 'size', e.g. with 'autoHeight = true'
          width       = <width>   // Can be used in place of 'size', e.g. with 'autoHeight = true'
          height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
          height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
          text        = <string>
          text        = <string>
-         consumeEvents = <bool>  // Whether the button propogates input events to the Game's input event handler. Defualt is true.
+         consumeEvents = <bool>  // Whether the button propagates input events to the Game's input event handler. Default is true.
     }
     }
  @endverbatim
  @endverbatim
  */
  */

+ 1 - 1
gameplay/src/CheckBox.h

@@ -28,7 +28,7 @@ namespace gameplay
          text        = <string>
          text        = <string>
          checked     = <bool>
          checked     = <bool>
          iconSize    = <width, height>   // The size to draw the checkbox icon, if different from its size in the texture.
          iconSize    = <width, height>   // The size to draw the checkbox icon, if different from its size in the texture.
-         consumeEvents = <bool>  // Whether the checkbox propogates input events to the Game's input event handler. Default is true.
+         consumeEvents = <bool>  // Whether the checkbox propagates input events to the Game's input event handler. Default is true.
     }
     }
  @endverbatim
  @endverbatim
  */
  */

+ 16 - 14
gameplay/src/Container.cpp

@@ -37,7 +37,7 @@ Container::Container()
       _scrollBarLeftCap(NULL), _scrollBarHorizontal(NULL), _scrollBarRightCap(NULL),
       _scrollBarLeftCap(NULL), _scrollBarHorizontal(NULL), _scrollBarRightCap(NULL),
       _scroll(SCROLL_NONE), _scrollBarBounds(Rectangle::empty()), _scrollPosition(Vector2::zero()),
       _scroll(SCROLL_NONE), _scrollBarBounds(Rectangle::empty()), _scrollPosition(Vector2::zero()),
       _scrollBarsAutoHide(false), _scrollBarOpacity(1.0f), _scrolling(false),
       _scrollBarsAutoHide(false), _scrollBarOpacity(1.0f), _scrolling(false),
-       _scrollingFirstX(0), _scrollingFirstY(0), _scrollingLastX(0), _scrollingLastY(0),
+      _scrollingVeryFirstX(0), _scrollingVeryFirstY(0), _scrollingFirstX(0), _scrollingFirstY(0), _scrollingLastX(0), _scrollingLastY(0),
       _scrollingStartTimeX(0), _scrollingStartTimeY(0), _scrollingLastTime(0),
       _scrollingStartTimeX(0), _scrollingStartTimeY(0), _scrollingLastTime(0),
       _scrollingVelocity(Vector2::zero()), _scrollingFriction(1.0f),
       _scrollingVelocity(Vector2::zero()), _scrollingFriction(1.0f),
       _scrollingRight(false), _scrollingDown(false),
       _scrollingRight(false), _scrollingDown(false),
@@ -369,8 +369,8 @@ bool Container::isScrolling() const
         return true;
         return true;
 
 
     return (_scrolling &&
     return (_scrolling &&
-            (abs(_scrollingLastX - _scrollingFirstX) > SCROLL_THRESHOLD ||
-             abs(_scrollingLastY - _scrollingFirstY) > SCROLL_THRESHOLD));
+            (abs(_scrollingLastX - _scrollingVeryFirstX) > SCROLL_THRESHOLD ||
+             abs(_scrollingLastY - _scrollingVeryFirstY) > SCROLL_THRESHOLD));
 }
 }
 
 
 Animation* Container::getAnimation(const char* id) const
 Animation* Container::getAnimation(const char* id) const
@@ -804,8 +804,8 @@ bool Container::touchEventScroll(Touch::TouchEvent evt, int x, int y, unsigned i
         {
         {
             _contactIndex = (int) contactIndex;
             _contactIndex = (int) contactIndex;
             _contactIndices++;
             _contactIndices++;
-            _scrollingLastX = _scrollingFirstX = x;
-            _scrollingLastY = _scrollingFirstY = y;
+            _scrollingLastX = _scrollingFirstX = _scrollingVeryFirstX = x;
+            _scrollingLastY = _scrollingFirstY = _scrollingVeryFirstY = y;
             _scrollingVelocity.set(0, 0);
             _scrollingVelocity.set(0, 0);
             _scrolling = true;
             _scrolling = true;
             _scrollingStartTimeX = _scrollingStartTimeY = 0;
             _scrollingStartTimeX = _scrollingStartTimeY = 0;
@@ -957,7 +957,7 @@ bool Container::mouseEventScroll(Mouse::MouseEvent evt, int x, int y, int wheelD
                 if (x + _viewportBounds.x >= vBounds.x &&
                 if (x + _viewportBounds.x >= vBounds.x &&
                     x + _viewportBounds.x <= vBounds.x + vBounds.width)
                     x + _viewportBounds.x <= vBounds.x + vBounds.width)
                 {
                 {
-                    // Then we're within the horizontal bounds of the verticle scrollbar.
+                    // Then we're within the horizontal bounds of the vertical scrollbar.
                     // We want to either jump up or down, or drag the scrollbar itself.
                     // We want to either jump up or down, or drag the scrollbar itself.
                     if (y < vBounds.y)
                     if (y < vBounds.y)
                     {
                     {
@@ -1108,13 +1108,11 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
         }
         }
         break;
         break;
     case Touch::TOUCH_RELEASE:
     case Touch::TOUCH_RELEASE:
-        {
-            if (eventConsumed)
-            {
-                if (_contactIndices > 0)
-                    _contactIndices--;
-            }
-        }
+		if (eventConsumed)
+		{
+			if (_contactIndices > 0)
+				_contactIndices--;
+		}
         break;
         break;
     }
     }
 
 
@@ -1128,7 +1126,11 @@ bool Container::pointerEvent(bool mouse, char evt, int x, int y, int data)
     }
     }
 
 
     release();
     release();
-    return (_consumeInputEvents | eventConsumed);
+    if (x > _clipBounds.x && x <= _clipBounds.x + _clipBounds.width &&
+		y > _clipBounds.y && y <= _clipBounds.y + _clipBounds.height)
+    	return (_consumeInputEvents | eventConsumed);
+    else
+    	return eventConsumed;
 }
 }
 
 
 Container::Scroll Container::getScroll(const char* scroll)
 Container::Scroll Container::getScroll(const char* scroll)

+ 11 - 3
gameplay/src/Container.h

@@ -27,7 +27,7 @@ namespace gameplay
          height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
          height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
          scroll      = <Container::Scroll constant> // Whether scrolling is allowed and in which directions.
          scroll      = <Container::Scroll constant> // Whether scrolling is allowed and in which directions.
          scrollBarsAutoHide = <bool>    // Whether scrollbars fade out when not in use.
          scrollBarsAutoHide = <bool>    // Whether scrollbars fade out when not in use.
-         consumeEvents = <bool>             // Whether the container propogates input events to the Game's input event handler. Default is true.
+         consumeEvents = <bool>             // Whether the container propagates input events to the Game's input event handler. Default is true.
 
 
          // All the nested controls within this container.
          // All the nested controls within this container.
          container 
          container 
@@ -444,11 +444,19 @@ protected:
      */
      */
     bool _scrolling;
     bool _scrolling;
     /** 
     /** 
-     * First scrolling touch x position
+	 * First scrolling touch x position
+	 */
+	int _scrollingVeryFirstX;
+	/**
+	 * First scrolling touch y position
+	 */
+	int _scrollingVeryFirstY;
+    /**
+     * First scrolling touch x position since last change in direction.
      */ 
      */ 
     int _scrollingFirstX;
     int _scrollingFirstX;
     /** 
     /** 
-     * First scrolling touch y position
+     * First scrolling touch y position since last change in direction.
      */ 
      */ 
     int _scrollingFirstY;
     int _scrollingFirstY;
     /** 
     /** 

+ 18 - 3
gameplay/src/DepthStencilTarget.cpp

@@ -6,8 +6,8 @@ namespace gameplay
 
 
 static std::vector<DepthStencilTarget*> __depthStencilTargets;
 static std::vector<DepthStencilTarget*> __depthStencilTargets;
 
 
-DepthStencilTarget::DepthStencilTarget(const char* id, Format format)
-    : _id(id ? id : ""), _format(format), _renderBuffer(0)
+DepthStencilTarget::DepthStencilTarget(const char* id, Format format, unsigned int width, unsigned int height)
+    : _id(id ? id : ""), _format(format), _renderBuffer(0), _width(width), _height(height)
 {
 {
 }
 }
 
 
@@ -28,7 +28,12 @@ DepthStencilTarget::~DepthStencilTarget()
 DepthStencilTarget* DepthStencilTarget::create(const char* id, Format format, unsigned int width, unsigned int height)
 DepthStencilTarget* DepthStencilTarget::create(const char* id, Format format, unsigned int width, unsigned int height)
 {
 {
     // Create the depth stencil target.
     // Create the depth stencil target.
-    DepthStencilTarget* depthStencilTarget = new DepthStencilTarget(id, format);
+    DepthStencilTarget* depthStencilTarget = new DepthStencilTarget(id, format, width, height);
+
+    // Create a render buffer for this new depth stencil target
+    GL_ASSERT( glGenRenderbuffers(1, &depthStencilTarget->_renderBuffer) );
+    GL_ASSERT( glBindRenderbuffer(GL_RENDERBUFFER, depthStencilTarget->_renderBuffer) );
+    GL_ASSERT( glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, width, height) );
 
 
     // Add it to the cache.
     // Add it to the cache.
     __depthStencilTargets.push_back(depthStencilTarget);
     __depthStencilTargets.push_back(depthStencilTarget);
@@ -64,4 +69,14 @@ DepthStencilTarget::Format DepthStencilTarget::getFormat() const
     return _format;
     return _format;
 }
 }
 
 
+unsigned int DepthStencilTarget::getWidth() const
+{
+    return _width;
+}
+
+unsigned int DepthStencilTarget::getHeight() const
+{
+    return _height;
+}
+
 }
 }

+ 18 - 6
gameplay/src/DepthStencilTarget.h

@@ -8,11 +8,7 @@ namespace gameplay
 {
 {
 
 
 /**
 /**
- * Defines a contain for depth and stencil targets in a frame buffer object.
- *
- * This class assumes that the target hardware supports depth textures, since
- * creation of a DepthStencilTarget always attempts to create an underlying
- * depth texture.
+ * Defines a container for depth and stencil targets in a frame buffer object.
  */
  */
 class DepthStencilTarget : public Ref
 class DepthStencilTarget : public Ref
 {
 {
@@ -72,12 +68,26 @@ public:
      */
      */
     Format getFormat() const;
     Format getFormat() const;
 
 
+    /**
+     * Returns the width of the DepthStencilTarget.
+     *
+     * @return The width.
+     */
+    unsigned int getWidth() const;
+
+    /**
+     * Returns the height of the DepthStencilTarget.
+     *
+     * @return The height.
+     */
+    unsigned int getHeight() const;
+
 private:
 private:
 
 
     /**
     /**
      * Constructor.
      * Constructor.
      */
      */
-    DepthStencilTarget(const char* id, Format format);
+    DepthStencilTarget(const char* id, Format format, unsigned int width, unsigned int height);
 
 
     /**
     /**
      * Destructor.
      * Destructor.
@@ -92,6 +102,8 @@ private:
     std::string _id;
     std::string _id;
     Format _format;
     Format _format;
     RenderBufferHandle _renderBuffer;
     RenderBufferHandle _renderBuffer;
+    unsigned int _width;
+    unsigned int _height;
 };
 };
 
 
 }
 }

+ 4 - 4
gameplay/src/Effect.cpp

@@ -220,7 +220,7 @@ Effect* Effect::createFromSource(const char* vshPath, const char* vshSource, con
     GLint length;
     GLint length;
     GLint success;
     GLint success;
 
 
-    // Replace all comma seperated definitions with #define prefix and \n suffix
+    // Replace all comma separated definitions with #define prefix and \n suffix
     std::string definesStr = "";
     std::string definesStr = "";
     replaceDefines(defines, definesStr);
     replaceDefines(defines, definesStr);
     
     
@@ -355,7 +355,7 @@ Effect* Effect::createFromSource(const char* vshPath, const char* vshSource, con
     // preferred attribute locations, we're going to query the locations that were
     // preferred attribute locations, we're going to query the locations that were
     // automatically bound by the GPU. While it can sometimes be convenient to use
     // automatically bound by the GPU. While it can sometimes be convenient to use
     // glBindAttribLocation, some vendors actually reserve certain attribute indices
     // glBindAttribLocation, some vendors actually reserve certain attribute indices
-    // and thereore using this function can create compatibility issues between
+    // and therefore using this function can create compatibility issues between
     // different hardware vendors.
     // different hardware vendors.
     GLint activeAttributes;
     GLint activeAttributes;
     GL_ASSERT( glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &activeAttributes) );
     GL_ASSERT( glGetProgramiv(program, GL_ACTIVE_ATTRIBUTES, &activeAttributes) );
@@ -563,8 +563,8 @@ void Effect::setValue(Uniform* uniform, const Texture::Sampler* sampler)
 
 
 void Effect::bind()
 void Effect::bind()
 {
 {
-   glUseProgram(_program) ;
-   GLenum test = glGetError();
+   GL_ASSERT( glUseProgram(_program) );
+
     __currentEffect = this;
     __currentEffect = this;
 }
 }
 
 

+ 1 - 4
gameplay/src/FileSystem.cpp

@@ -25,9 +25,6 @@ extern AAssetManager* __assetManager;
 namespace gameplay
 namespace gameplay
 {
 {
 
 
-// Creates a file on the file system from the specified asset (Android-specific).
-static void createFileFromAsset(const char* path);
-
 #ifdef __ANDROID__
 #ifdef __ANDROID__
 #include <unistd.h>
 #include <unistd.h>
 
 
@@ -334,7 +331,7 @@ bool FileSystem::isAbsolutePath(const char* filePath)
 #endif
 #endif
 }
 }
 
 
-void createFileFromAsset(const char* path)
+void FileSystem::createFileFromAsset(const char* path)
 {
 {
 #ifdef __ANDROID__
 #ifdef __ANDROID__
     static std::set<std::string> upToDateAssets;
     static std::set<std::string> upToDateAssets;

+ 8 - 1
gameplay/src/FileSystem.h

@@ -39,7 +39,7 @@ public:
      * Loads a properties file containing a list of filesystem aliases.
      * Loads a properties file containing a list of filesystem aliases.
      *
      *
      * The specified aliases file is a valid properties file that contains one
      * The specified aliases file is a valid properties file that contains one
-     * or more namespaces with a list of fielsystem aliases that will be used
+     * or more namespaces with a list of filesystem aliases that will be used
      * to establish soft links to files when reading files through this class.
      * to establish soft links to files when reading files through this class.
      *
      *
      * This can be helpful for managing loading of resources that may change
      * This can be helpful for managing loading of resources that may change
@@ -146,6 +146,13 @@ public:
      */
      */
     static bool isAbsolutePath(const char* filePath);
     static bool isAbsolutePath(const char* filePath);
 
 
+    /**
+     * Creates a file on the file system from the specified asset (Android-specific).
+     * 
+     * @param path The path to the file.
+     */
+    static void createFileFromAsset(const char* path);
+
 private:
 private:
 
 
     /**
     /**

+ 1 - 1
gameplay/src/Form.cpp

@@ -538,7 +538,7 @@ void Form::draw()
     // to texture a quad.  The quad will be given the same dimensions as the form and
     // to texture a quad.  The quad will be given the same dimensions as the form and
     // must be transformed appropriately by the user, unless they call setQuad() themselves.
     // must be transformed appropriately by the user, unless they call setQuad() themselves.
     // On the other hand, if this form has not been set on a node, SpriteBatch will be used
     // On the other hand, if this form has not been set on a node, SpriteBatch will be used
-    // to render the contents of the frambuffer directly to the display.
+    // to render the contents of the framebuffer directly to the display.
 
 
     // Check whether this form has changed since the last call to draw() and if so, render into the framebuffer.
     // Check whether this form has changed since the last call to draw() and if so, render into the framebuffer.
     if (isDirty())
     if (isDirty())

+ 1 - 1
gameplay/src/Form.h

@@ -32,7 +32,7 @@ class Theme;
         size       = <width, height>       // Size of the form, measured in pixels.
         size       = <width, height>       // Size of the form, measured in pixels.
         width      = <width>               // Can be used in place of 'size', e.g. with 'autoHeight = true'
         width      = <width>               // Can be used in place of 'size', e.g. with 'autoHeight = true'
         height     = <height>              // Can be used in place of 'size', e.g. with 'autoWidth = true'
         height     = <height>              // Can be used in place of 'size', e.g. with 'autoWidth = true'
-        consumeEvents = <bool>             // Whether the form propogates input events to the Game's input event handler. Default is false
+        consumeEvents = <bool>             // Whether the form propagates input events to the Game's input event handler. Default is false
       
       
         // All the nested controls within this form.
         // All the nested controls within this form.
         container { }
         container { }

+ 57 - 56
gameplay/src/FrameBuffer.cpp

@@ -11,6 +11,7 @@ namespace gameplay
 static unsigned int __maxRenderTargets = 0;
 static unsigned int __maxRenderTargets = 0;
 static std::vector<FrameBuffer*> __frameBuffers;
 static std::vector<FrameBuffer*> __frameBuffers;
 static FrameBufferHandle __defaultHandle = 0;
 static FrameBufferHandle __defaultHandle = 0;
+static FrameBufferHandle __currentHandle = 0;
 
 
 FrameBuffer::FrameBuffer(const char* id, unsigned int width, unsigned int height) :
 FrameBuffer::FrameBuffer(const char* id, unsigned int width, unsigned int height) :
     _id(id ? id : ""), _width(width), _height(height), _handle(0), 
     _id(id ? id : ""), _width(width), _height(height), _handle(0), 
@@ -52,29 +53,50 @@ FrameBuffer::~FrameBuffer()
 
 
 void FrameBuffer::initialize()
 void FrameBuffer::initialize()
 {
 {
+    // Query the current/initial FBO handle and store is as out 'default' frame buffer.
+    // On many platforms this will simply be the zero (0) handle, but this is not always the case.
     GLint fbo;
     GLint fbo;
     glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo);
     glGetIntegerv(GL_FRAMEBUFFER_BINDING, &fbo);
     __defaultHandle = (FrameBufferHandle)fbo;
     __defaultHandle = (FrameBufferHandle)fbo;
+    __currentHandle = __defaultHandle;
+
+    // Query the max supported color attachments. This glGet operation is not supported
+    // on GL ES 2.x, so if the define does not exist, assume a value of 1.
+#ifdef GL_MAX_COLOR_ATTACHMENTS
+        GLint val;
+        GL_ASSERT( glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &val) );
+        __maxRenderTargets = (unsigned int)std::max(1, val);
+#else
+        __maxRenderTargets = 1;
+#endif
 }
 }
 
 
-FrameBuffer* FrameBuffer::create(const char* id, unsigned int width, unsigned int height)
+FrameBuffer* FrameBuffer::create(const char* id)
 {
 {
-    if (!isPowerOfTwo(width) | !isPowerOfTwo(height))
-    {
-        GP_ERROR("Failed to create render target for frame buffer. Width and Height must be a power of 2.");
-        return NULL;
-    }
+    return create(id, 0, 0);
+}
 
 
+FrameBuffer* FrameBuffer::create(const char* id, unsigned int width, unsigned int height)
+{
     // Call getMaxRenderTargets() to force __maxRenderTargets to be set
     // Call getMaxRenderTargets() to force __maxRenderTargets to be set
     getMaxRenderTargets();
     getMaxRenderTargets();
 
 
-    // Create RenderTarget with same ID.
     RenderTarget* renderTarget = NULL;
     RenderTarget* renderTarget = NULL;
-    renderTarget = RenderTarget::create(id, width, height);
-    if (renderTarget == NULL)
+    if (width > 0 && height > 0)
     {
     {
-        GP_ERROR("Failed to create render target for frame buffer.");
-        return NULL;
+        if (!isPowerOfTwo(width) | !isPowerOfTwo(height))
+        {
+            GP_ERROR("Failed to create render target for frame buffer. Width and Height must be a power of 2.");
+            return NULL;
+        }
+
+        // Create a default RenderTarget with same ID.
+        renderTarget = RenderTarget::create(id, width, height);
+        if (renderTarget == NULL)
+        {
+            GP_ERROR("Failed to create render target for frame buffer.");
+            return NULL;
+        }
     }
     }
 
 
     // Create the frame buffer
     // Create the frame buffer
@@ -84,12 +106,14 @@ FrameBuffer* FrameBuffer::create(const char* id, unsigned int width, unsigned in
     frameBuffer->_handle = handle;
     frameBuffer->_handle = handle;
     
     
     // Create the render target array for the new frame buffer
     // Create the render target array for the new frame buffer
-    RenderTarget** renderTargets = new RenderTarget*[__maxRenderTargets];
-    memset(renderTargets, 0, sizeof(RenderTarget*) * __maxRenderTargets);
-    frameBuffer->_renderTargets = renderTargets;
+    frameBuffer->_renderTargets = new RenderTarget*[__maxRenderTargets];
+    memset(frameBuffer->_renderTargets, 0, sizeof(RenderTarget*) * __maxRenderTargets);
 
 
-    frameBuffer->setRenderTarget(renderTarget, 0);
-    SAFE_RELEASE(renderTarget);
+    if (renderTarget)
+    {
+        frameBuffer->setRenderTarget(renderTarget, 0);
+        SAFE_RELEASE(renderTarget);
+    }
 
 
     __frameBuffers.push_back(frameBuffer);
     __frameBuffers.push_back(frameBuffer);
 
 
@@ -131,16 +155,6 @@ unsigned int FrameBuffer::getHeight() const
 
 
 unsigned int FrameBuffer::getMaxRenderTargets()
 unsigned int FrameBuffer::getMaxRenderTargets()
 {
 {
-    if (__maxRenderTargets == 0)
-    {
-#ifdef GL_MAX_COLOR_ATTACHMENTS
-        GLint val;
-        GL_ASSERT( glGetIntegerv(GL_MAX_COLOR_ATTACHMENTS, &val) );
-        __maxRenderTargets = (unsigned int) val;
-#else
-        __maxRenderTargets = 1;
-#endif
-    }
     return __maxRenderTargets;
     return __maxRenderTargets;
 }
 }
 
 
@@ -162,31 +176,23 @@ void FrameBuffer::setRenderTarget(RenderTarget* target, unsigned int index)
 
 
     if (target)
     if (target)
     {
     {
+        GP_ASSERT( _renderTargets[index]->getTexture() );
+
         // This FrameBuffer now references the RenderTarget.
         // This FrameBuffer now references the RenderTarget.
         target->addRef();
         target->addRef();
 
 
-        // Store the current FBO binding so we can restore it
-        GLint currentFbo;
-        GL_ASSERT( glGetIntegerv(GL_FRAMEBUFFER_BINDING, &currentFbo) );
-
         // Now set this target as the color attachment corresponding to index.
         // Now set this target as the color attachment corresponding to index.
         GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, _handle) );
         GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, _handle) );
-        GL_ASSERT( glBindTexture(GL_TEXTURE_2D, _renderTargets[index]->getTexture()->getHandle()) );
-        GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) );
-        GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) );
-        GL_ASSERT( glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE) );
-        GL_ASSERT( glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE) );
-        GL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _width, _height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL) );
         GLenum attachment = GL_COLOR_ATTACHMENT0 + index;
         GLenum attachment = GL_COLOR_ATTACHMENT0 + index;
-        GP_ASSERT( _renderTargets[index]->getTexture() );
         GL_ASSERT( glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, _renderTargets[index]->getTexture()->getHandle(), 0) );
         GL_ASSERT( glFramebufferTexture2D(GL_FRAMEBUFFER, attachment, GL_TEXTURE_2D, _renderTargets[index]->getTexture()->getHandle(), 0) );
         GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
         GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
         if (fboStatus != GL_FRAMEBUFFER_COMPLETE)
         if (fboStatus != GL_FRAMEBUFFER_COMPLETE)
         {
         {
-            GP_ERROR("Framebuffer status incompleted: 0x%x", fboStatus);
+            GP_ERROR("Framebuffer status incomplete: 0x%x", fboStatus);
         }
         }
+
         // Restore the FBO binding
         // Restore the FBO binding
-        GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, currentFbo) );
+        GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, __currentHandle) );
     }
     }
 }
 }
 
 
@@ -216,36 +222,25 @@ void FrameBuffer::setDepthStencilTarget(DepthStencilTarget* target)
         // The FrameBuffer now owns this DepthStencilTarget.
         // The FrameBuffer now owns this DepthStencilTarget.
         target->addRef();
         target->addRef();
 
 
-        // Store the current FBO binding so we can restore it.
-        GLint currentFbo;
-        GL_ASSERT( glGetIntegerv(GL_FRAMEBUFFER_BINDING, &currentFbo) );
-
         // Now set this target as the color attachment corresponding to index.
         // Now set this target as the color attachment corresponding to index.
         GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, _handle) );
         GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, _handle) );
-        
-        // Create a render buffer 
-        RenderBufferHandle renderBuffer = 0;
-        GL_ASSERT( glGenRenderbuffers(1, &renderBuffer) );
-        GL_ASSERT( glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer) );
-        GL_ASSERT( glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, _width, _height) );
-        GL_ASSERT( glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, renderBuffer) );
-        // Attach the 
+
+        // Attach the render buffer to the framebuffer
+        GL_ASSERT( glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, _depthStencilTarget->_renderBuffer) );
         if (target->getFormat() == DepthStencilTarget::DEPTH_STENCIL)
         if (target->getFormat() == DepthStencilTarget::DEPTH_STENCIL)
         {
         {
-            GL_ASSERT( glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer) );
+            GL_ASSERT( glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, _depthStencilTarget->_renderBuffer) );
         }
         }
 
 
         // Check the framebuffer is good to go.
         // Check the framebuffer is good to go.
         GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
         GLenum fboStatus = glCheckFramebufferStatus(GL_FRAMEBUFFER);
         if (fboStatus != GL_FRAMEBUFFER_COMPLETE)
         if (fboStatus != GL_FRAMEBUFFER_COMPLETE)
         {
         {
-            GP_ERROR("Framebuffer status incompleted: 0x%x", fboStatus);
+            GP_ERROR("Framebuffer status incomplete: 0x%x", fboStatus);
         }
         }
-        _depthStencilTarget->_renderBuffer = renderBuffer;
-
 
 
         // Restore the FBO binding
         // Restore the FBO binding
-        GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, currentFbo) );
+        GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, __currentHandle) );
     }
     }
 }
 }
 
 
@@ -258,11 +253,17 @@ void FrameBuffer::bind()
 {
 {
     // Bind this FrameBuffer for rendering.
     // Bind this FrameBuffer for rendering.
     GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, _handle) );
     GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, _handle) );
+
+    // Update the current FBO handle
+    __currentHandle = _handle;
 }
 }
 
 
 void FrameBuffer::bindDefault()
 void FrameBuffer::bindDefault()
 {
 {
     GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, __defaultHandle) );
     GL_ASSERT( glBindFramebuffer(GL_FRAMEBUFFER, __defaultHandle) );
+
+    // Update the current FBO handle
+    __currentHandle = __defaultHandle;
 }
 }
 
 
 bool FrameBuffer::isPowerOfTwo(unsigned int value)
 bool FrameBuffer::isPowerOfTwo(unsigned int value)

+ 20 - 1
gameplay/src/FrameBuffer.h

@@ -23,12 +23,31 @@ class FrameBuffer : public Ref
 
 
 public:
 public:
 
 
+    /**
+     * Creates a new, empty FrameBuffer object.
+     *
+     * The new FrameBuffer does not have any render targets or a depth/stencil target and these
+     * must be added before it can be used. The FrameBuffer is added to the list of available
+     * FrameBuffers.
+     *
+     * @param id The ID of the new FrameBuffer. Uniqueness is recommended but not enforced.
+     *
+     * @return A newly created FrameBuffer.
+     * @script{create}
+     */
+    static FrameBuffer* create(const char* id);
+
     /**
     /**
      * Creates a new FrameBuffer with a single RenderTarget of the specified width and height,
      * Creates a new FrameBuffer with a single RenderTarget of the specified width and height,
      * and adds the FrameBuffer to the list of available FrameBuffers.
      * and adds the FrameBuffer to the list of available FrameBuffers.
+     *
+     * If width and height are non-zero a default RenderTarget of type RGBA will be created
+     * and added to the FrameBuffer, with the same ID. The ID of the render target can be
+     * changed later via RenderTarget::setId(const char*).
+     *
      * You can additionally add a DepthStencilTarget using FrameBuffer::setDepthStencilTarget.
      * You can additionally add a DepthStencilTarget using FrameBuffer::setDepthStencilTarget.
      *
      *
-     * @param id The ID of the new FrameBuffer.  Uniqueness is recommended but not enforced.
+     * @param id The ID of the new FrameBuffer. Uniqueness is recommended but not enforced.
      * @param width The width of the RenderTarget to be created and attached.
      * @param width The width of the RenderTarget to be created and attached.
      * @param height The height of the RenderTarget to be created and attached.
      * @param height The height of the RenderTarget to be created and attached.
      *
      *

+ 1 - 1
gameplay/src/Gamepad.h

@@ -111,7 +111,7 @@ public:
      *
      *
      * Note: What if the user decides to add gamepad controls (joysticks, buttons) to the gamepad form? How do we handle new/deleted controls?
      * Note: What if the user decides to add gamepad controls (joysticks, buttons) to the gamepad form? How do we handle new/deleted controls?
      *
      *
-     * @return the Form used to represent this gamepad. NULL if the gamepad is not reprented with a Form.
+     * @return the Form used to represent this gamepad. NULL if the gamepad is not represented with a Form.
      */
      */
     Form* getForm() const;
     Form* getForm() const;
 
 

+ 1 - 1
gameplay/src/Joystick.h

@@ -17,7 +17,7 @@ namespace gameplay
         alignment   = <Control::Alignment constant> // Note: 'position' will be ignored.
         alignment   = <Control::Alignment constant> // Note: 'position' will be ignored.
         size        = <width, height>           // Size of the Control, measured in pixels.
         size        = <width, height>           // Size of the Control, measured in pixels.
         radius      = <float>                   // The value of the left- / bottom-most point on the slider.
         radius      = <float>                   // The value of the left- / bottom-most point on the slider.
-        consumeEvents = <bool>                  // Whether the slider propogates input events to the Game's input event handler. Default is true.
+        consumeEvents = <bool>                  // Whether the slider propagates input events to the Game's input event handler. Default is true.
         
         
     }
     }
  @endverbatim
  @endverbatim

+ 1 - 1
gameplay/src/Label.h

@@ -24,7 +24,7 @@ namespace gameplay
          width       = <width>   // Can be used in place of 'size', e.g. with 'autoHeight = true'
          width       = <width>   // Can be used in place of 'size', e.g. with 'autoHeight = true'
          height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
          height      = <height>  // Can be used in place of 'size', e.g. with 'autoWidth = true'
          text        = <string>
          text        = <string>
-         consumeEvents = <bool>  // Whether the label propogates input events to the Game's input event handler. Default is true.
+         consumeEvents = <bool>  // Whether the label propagates input events to the Game's input event handler. Default is true.
     }
     }
  @endverbatim
  @endverbatim
  */
  */

+ 1 - 1
gameplay/src/Logger.cpp

@@ -29,7 +29,7 @@ void Logger::log(Level level, const char* message, ...)
     va_start(args, message);
     va_start(args, message);
 
 
     // Declare a moderately sized buffer on the stack that should be
     // Declare a moderately sized buffer on the stack that should be
-    // large enough to accomodate most log requests.
+    // large enough to accommodate most log requests.
     int size = 1024;
     int size = 1024;
     char stackBuffer[1024];
     char stackBuffer[1024];
     std::vector<char> dynamicBuffer;
     std::vector<char> dynamicBuffer;

+ 1 - 1
gameplay/src/Matrix.h

@@ -129,7 +129,7 @@ public:
      * Creates a view matrix based on the specified input parameters.
      * Creates a view matrix based on the specified input parameters.
      *
      *
      * @param eyePosition The eye position.
      * @param eyePosition The eye position.
-     * @param targetPosition The target's cener position.
+     * @param targetPosition The target's center position.
      * @param up The up vector.
      * @param up The up vector.
      * @param dst A matrix to store the result in.
      * @param dst A matrix to store the result in.
      */
      */

+ 1 - 21
gameplay/src/Mesh.cpp

@@ -36,28 +36,8 @@ Mesh* Mesh::createMesh(const VertexFormat& vertexFormat, unsigned int vertexCoun
 {
 {
     GLuint vbo;
     GLuint vbo;
     GL_ASSERT( glGenBuffers(1, &vbo) );
     GL_ASSERT( glGenBuffers(1, &vbo) );
-    if (GL_LAST_ERROR())
-    {
-        GP_ERROR("Failed to create VBO for mesh with OpenGL error %d.", GL_LAST_ERROR());
-        return NULL;
-    }
-
     GL_ASSERT( glBindBuffer(GL_ARRAY_BUFFER, vbo) );
     GL_ASSERT( glBindBuffer(GL_ARRAY_BUFFER, vbo) );
-    if (GL_LAST_ERROR())
-    {
-        GP_ERROR("Failed to bind VBO for mesh with OpenGL error %d.", GL_LAST_ERROR());
-        glDeleteBuffers(1, &vbo);
-        return NULL;
-    }
-
-    GL_CHECK( glBufferData(GL_ARRAY_BUFFER, vertexFormat.getVertexSize() * vertexCount, NULL, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW) );
-    if (GL_LAST_ERROR())
-    {
-        GP_ERROR("Failed to load VBO with vertex data with OpenGL error %d.", GL_LAST_ERROR());
-        glBindBuffer(GL_ARRAY_BUFFER, 0);
-        glDeleteBuffers(1, &vbo);
-        return NULL;
-    }
+    GL_ASSERT( glBufferData(GL_ARRAY_BUFFER, vertexFormat.getVertexSize() * vertexCount, NULL, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW) );
 
 
     Mesh* mesh = new Mesh(vertexFormat);
     Mesh* mesh = new Mesh(vertexFormat);
     mesh->_vertexCount = vertexCount;
     mesh->_vertexCount = vertexCount;

+ 2 - 19
gameplay/src/MeshPart.cpp

@@ -23,19 +23,7 @@ MeshPart* MeshPart::create(Mesh* mesh, unsigned int meshIndex, Mesh::PrimitiveTy
     // Create a VBO for our index buffer.
     // Create a VBO for our index buffer.
     GLuint vbo;
     GLuint vbo;
     GL_ASSERT( glGenBuffers(1, &vbo) );
     GL_ASSERT( glGenBuffers(1, &vbo) );
-    if (GL_LAST_ERROR())
-    {
-        GP_ERROR("Failed to create VBO for index buffer with OpenGL error %d.", GL_LAST_ERROR());
-        return NULL;
-    }
-
     GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo) );
     GL_ASSERT( glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, vbo) );
-    if (GL_LAST_ERROR())
-    {
-        GP_ERROR("Failed to bind VBO for index buffer with OpenGL error %d.", GL_LAST_ERROR());
-        glDeleteBuffers(1, &vbo);
-        return NULL;
-    }
 
 
     unsigned int indexSize = 0;
     unsigned int indexSize = 0;
     switch (indexFormat)
     switch (indexFormat)
@@ -54,13 +42,8 @@ MeshPart* MeshPart::create(Mesh* mesh, unsigned int meshIndex, Mesh::PrimitiveTy
         glDeleteBuffers(1, &vbo);
         glDeleteBuffers(1, &vbo);
         return NULL;
         return NULL;
     }
     }
-    GL_CHECK( glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize * indexCount, NULL, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW) );
-    if (GL_LAST_ERROR())
-    {
-        GP_ERROR("Failed to load VBO with index data with OpenGL error %d.", GL_LAST_ERROR());
-        glDeleteBuffers(1, &vbo);
-        return NULL;
-    }
+
+    GL_ASSERT( glBufferData(GL_ELEMENT_ARRAY_BUFFER, indexSize * indexCount, NULL, dynamic ? GL_DYNAMIC_DRAW : GL_STATIC_DRAW) );
 
 
     MeshPart* part = new MeshPart();
     MeshPart* part = new MeshPart();
     part->_mesh = mesh;
     part->_mesh = mesh;

+ 1 - 1
gameplay/src/Node.cpp

@@ -839,7 +839,7 @@ const BoundingSphere& Node::getBoundingSphere() const
                 // world matrix. This computes a final world matrix used for transforming this
                 // world matrix. This computes a final world matrix used for transforming this
                 // node's bounding volume. This allows us to store a much smaller bounding
                 // node's bounding volume. This allows us to store a much smaller bounding
                 // volume approximation than would otherwise be possible for skinned meshes,
                 // volume approximation than would otherwise be possible for skinned meshes,
-                // since joint parent nodes that are not in the matrix pallette do not need to
+                // since joint parent nodes that are not in the matrix palette do not need to
                 // be considered as directly transforming vertices on the GPU (they can instead
                 // be considered as directly transforming vertices on the GPU (they can instead
                 // be applied directly to the bounding volume transformation below).
                 // be applied directly to the bounding volume transformation below).
                 GP_ASSERT(_model->getSkin()->getRootJoint());
                 GP_ASSERT(_model->getSkin()->getRootJoint());

+ 1 - 1
gameplay/src/Node.h

@@ -539,7 +539,7 @@ public:
     /**
     /**
      * Sets the physics collision object for this node from the given properties object.
      * Sets the physics collision object for this node from the given properties object.
      * 
      * 
-     * @param properties The properties object defining the collision ojbect.
+     * @param properties The properties object defining the collision object.
      */
      */
     PhysicsCollisionObject* setCollisionObject(Properties* properties);
     PhysicsCollisionObject* setCollisionObject(Properties* properties);
 
 

+ 3 - 3
gameplay/src/PhysicsCharacter.cpp

@@ -309,7 +309,7 @@ void PhysicsCharacter::stepUp(btCollisionWorld* collisionWorld, btScalar time)
 
 
     if (_verticalVelocity.isZero())
     if (_verticalVelocity.isZero())
     {
     {
-        // Simply increase our poisiton by step height to enable us
+        // Simply increase our position by step height to enable us
         // to smoothly move over steps.
         // to smoothly move over steps.
         targetPosition += btVector3(0, _stepHeight, 0);
         targetPosition += btVector3(0, _stepHeight, 0);
     }
     }
@@ -521,7 +521,7 @@ static btVector3 parallelComponent(const btVector3& direction, const btVector3&
 }
 }
 
 
 /*
 /*
- * Returns the portion of 'direction' that is perpindicular to 'normal'.
+ * Returns the portion of 'direction' that is perpendicular to 'normal'.
  */
  */
 static btVector3 perpindicularComponent(const btVector3& direction, const btVector3& normal)
 static btVector3 perpindicularComponent(const btVector3& direction, const btVector3& normal)
 {
 {
@@ -572,7 +572,7 @@ bool PhysicsCharacter::fixCollision(btCollisionWorld* world)
     _node->getWorldMatrix().getTranslation(&startPosition);
     _node->getWorldMatrix().getTranslation(&startPosition);
     btVector3 currentPosition = BV(startPosition);
     btVector3 currentPosition = BV(startPosition);
 
 
-    // Handle all collisions/overlappign pairs.
+    // Handle all collisions/overlapping pairs.
     btScalar maxPenetration = btScalar(0.0);
     btScalar maxPenetration = btScalar(0.0);
     for (int i = 0, count = pairCache->getNumOverlappingPairs(); i < count; ++i)
     for (int i = 0, count = pairCache->getNumOverlappingPairs(); i < count; ++i)
     {
     {

+ 1 - 1
gameplay/src/PhysicsCollisionObject.h

@@ -251,7 +251,7 @@ protected:
         ScriptListener(const char* url);
         ScriptListener(const char* url);
 
 
         /**
         /**
-         * @see PhysicsColliionObject::CollisionListener
+         * @see PhysicsCollisionObject::CollisionListener
          */
          */
         void collisionEvent(PhysicsCollisionObject::CollisionListener::EventType type, const PhysicsCollisionObject::CollisionPair& collisionPair,
         void collisionEvent(PhysicsCollisionObject::CollisionListener::EventType type, const PhysicsCollisionObject::CollisionPair& collisionPair,
                                     const Vector3& contactPointA, const Vector3& contactPointB);
                                     const Vector3& contactPointA, const Vector3& contactPointB);

+ 1 - 1
gameplay/src/PhysicsController.cpp

@@ -1027,7 +1027,7 @@ PhysicsCollisionShape* PhysicsController::createHeightfield(Node* node, Image* i
         for (unsigned int y = 0, h = image->getHeight(); y < h; ++y)
         for (unsigned int y = 0, h = image->getHeight(); y < h; ++y)
         {
         {
             //
             //
-            // Orignially in GamePlay this was normalizedHeightGrayscale which generally yielded
+            // Originally in GamePlay this was normalizedHeightGrayscale which generally yielded
             // only 8-bit precision. This has been replaced by normalizedHeightPacked (with a
             // only 8-bit precision. This has been replaced by normalizedHeightPacked (with a
             // corresponding change in gameplay-encoder).
             // corresponding change in gameplay-encoder).
             //
             //

+ 10 - 0
gameplay/src/PhysicsRigidBody.cpp

@@ -43,6 +43,8 @@ PhysicsRigidBody::PhysicsRigidBody(Node* node, const PhysicsCollisionShape::Defi
     // Set other initially defined properties.
     // Set other initially defined properties.
     setKinematic(parameters.kinematic);
     setKinematic(parameters.kinematic);
     setAnisotropicFriction(parameters.anisotropicFriction);
     setAnisotropicFriction(parameters.anisotropicFriction);
+    setAngularFactor(parameters.angularFactor);
+    setLinearFactor(parameters.linearFactor);
 
 
     // Add ourself to the physics world.
     // Add ourself to the physics world.
     Game::getInstance()->getPhysicsController()->addCollisionObject(this);
     Game::getInstance()->getPhysicsController()->addCollisionObject(this);
@@ -223,6 +225,14 @@ PhysicsRigidBody* PhysicsRigidBody::create(Node* node, Properties* properties, c
             gravity = new Vector3();
             gravity = new Vector3();
             properties->getVector3(NULL, gravity);
             properties->getVector3(NULL, gravity);
         }
         }
+        else if (strcmp(name, "angularFactor") == 0)
+        {
+            properties->getVector3(NULL, &parameters.angularFactor);
+        }
+        else if (strcmp(name, "linearFactor") == 0)
+        {
+            properties->getVector3(NULL, &parameters.linearFactor);
+        }
         else
         else
         {
         {
             // Ignore this case (the attributes for the rigid body's collision shape would end up here).
             // Ignore this case (the attributes for the rigid body's collision shape would end up here).

+ 72 - 3
gameplay/src/PhysicsRigidBody.h

@@ -73,12 +73,26 @@ public:
          */
          */
         Vector3 anisotropicFriction;
         Vector3 anisotropicFriction;
 
 
+        /**
+         * Linear factor for the rigid body. x, y, z coordinates correspond to world 
+         * space motion along these axes. Use 1.0 to allow or 0.0 to disallow motion 
+         * along certain axis.
+         */
+        Vector3 linearFactor;
+
+        /**
+         * Angular factor for the rigid body. x, y, z coordinates correspond to world 
+         * space rotation along these axes. Use 1.0 to allow or 0.0 to disallow rotation
+         * along certain axis.
+         */
+        Vector3 angularFactor;
+
         /**
         /**
          * Constructor.
          * Constructor.
          */
          */
         Parameters() : mass(0.0f), friction(0.5f), restitution(0.0f),
         Parameters() : mass(0.0f), friction(0.5f), restitution(0.0f),
             linearDamping(0.0f), angularDamping(0.0f),
             linearDamping(0.0f), angularDamping(0.0f),
-            kinematic(false), anisotropicFriction(Vector3::one())
+            kinematic(false), anisotropicFriction(Vector3::one()), linearFactor(Vector3::one()), angularFactor(Vector3::one())
         {
         {
         }
         }
 
 
@@ -87,9 +101,10 @@ public:
          */
          */
         Parameters(float mass, float friction = 0.5f, float resititution = 0.0f,
         Parameters(float mass, float friction = 0.5f, float resititution = 0.0f,
             float linearDamping = 0.0f, float angularDamping = 0.0f, bool kinematic = false,
             float linearDamping = 0.0f, float angularDamping = 0.0f, bool kinematic = false,
-            const Vector3& anisotropicFriction = Vector3::one())
+            const Vector3& anisotropicFriction = Vector3::one(), const Vector3& linearFactor = Vector3::one(), 
+            const Vector3& angularFactor = Vector3::one())
             : mass(mass), friction(friction), restitution(restitution), linearDamping(linearDamping), angularDamping(angularDamping),
             : mass(mass), friction(friction), restitution(restitution), linearDamping(linearDamping), angularDamping(angularDamping),
-              kinematic(kinematic), anisotropicFriction(anisotropicFriction)
+              kinematic(kinematic), anisotropicFriction(anisotropicFriction), linearFactor(linearFactor), angularFactor(angularFactor)
         {
         {
         }
         }
     };
     };
@@ -249,6 +264,60 @@ public:
      */
      */
     inline void setGravity(float x, float y, float z);
     inline void setGravity(float x, float y, float z);
 
 
+    /**
+     * Gets the rigid body's angular factor.
+     * 
+     * @return The angular factor.
+     */
+    inline Vector3 getAngularFactor() const;
+
+    /**
+     * Sets the rigid body's angular factor.  x, y, z coordinates correspond to world 
+     * space rotation along these axes. Use 1.0 to allow or 0.0 to disallow rotation 
+     * along certain axis.
+     * 
+     * @param angularFactor angular factor vector
+     */
+    inline void setAngularFactor(const Vector3& angularFactor);
+
+    /**
+     * Sets the rigid body's angular factor.  x, y, z coordinates correspond to world 
+     * space rotation along these axes. Use 1.0 to allow or 0.0 to disallow rotation 
+     * along certain axis.
+     * 
+     * @param x The x coordinate of the angular factor vector.
+     * @param y The y coordinate of the angular factor vector.
+     * @param z The z coordinate of the angular factor vector.
+     */
+    inline void setAngularFactor(float x, float y, float z);
+
+    /**
+     * Gets the rigid body's linear factor.
+     * 
+     * @return The linear factor.
+     */
+    inline Vector3 getLinearFactor() const;
+
+    /**
+     * Sets the rigid body's linear factor.  x, y, z coordinates correspond to world 
+     * space motion along these axes. Use 1.0 to allow or 0.0 to disallow motion 
+     * along certain axis.
+     * 
+     * @param linearFactor linear factor vector
+     */
+    inline void setLinearFactor(const Vector3& linearFactor);
+
+    /**
+     * Sets the rigid body's linear factor.  x, y, z coordinates correspond to world 
+     * space motion along these axes. Use 1.0 to allow or 0.0 to disallow motion 
+     * along certain axis.
+     * 
+     * @param x The x coordinate of the linear factor vector.
+     * @param y The y coordinate of the linear factor vector.
+     * @param z The z coordinate of the linear factor vector.
+     */
+    inline void setLinearFactor(float x, float y, float z);
+
     /**
     /**
      * Sets whether the rigid body is a kinematic rigid body or not.
      * Sets whether the rigid body is a kinematic rigid body or not.
      * 
      * 

+ 38 - 0
gameplay/src/PhysicsRigidBody.inl

@@ -127,6 +127,44 @@ inline void PhysicsRigidBody::setGravity(float x, float y, float z)
     _body->setGravity(btVector3(x, y, z));
     _body->setGravity(btVector3(x, y, z));
 }
 }
 
 
+inline Vector3 PhysicsRigidBody::getAngularFactor() const
+{
+    GP_ASSERT(_body);
+    const btVector3& f = _body->getAngularFactor();
+    return Vector3(f.x(), f.y(), f.z());
+}
+
+inline void PhysicsRigidBody::setAngularFactor(const Vector3& angularFactor)
+{
+    GP_ASSERT(_body);
+    _body->setAngularFactor(BV(angularFactor));
+}
+
+inline void PhysicsRigidBody::setAngularFactor(float x, float y, float z)
+{
+    GP_ASSERT(_body);
+    _body->setAngularFactor(btVector3(x, y, z));
+}
+
+inline Vector3 PhysicsRigidBody::getLinearFactor() const
+{
+    GP_ASSERT(_body);
+    const btVector3& f = _body->getLinearFactor();
+    return Vector3(f.x(), f.y(), f.z());
+}
+
+inline void PhysicsRigidBody::setLinearFactor(const Vector3& angularFactor)
+{
+    GP_ASSERT(_body);
+    _body->setLinearFactor(BV(angularFactor));
+}
+
+inline void PhysicsRigidBody::setLinearFactor(float x, float y, float z)
+{
+    GP_ASSERT(_body);
+    _body->setLinearFactor(btVector3(x, y, z));
+}
+
 inline bool PhysicsRigidBody::isStatic() const
 inline bool PhysicsRigidBody::isStatic() const
 {
 {
     GP_ASSERT(_body);
     GP_ASSERT(_body);

+ 1 - 1
gameplay/src/PhysicsVehicleWheel.h

@@ -326,7 +326,7 @@ private:
 
 
     /**
     /**
      * Traverse up the visual scene graph. Upon finding the first ancestor node with an
      * Traverse up the visual scene graph. Upon finding the first ancestor node with an
-     * advertised descendant of collsion type VEHICLE, add this wheel onto the vehicle.
+     * advertised descendant of collision type VEHICLE, add this wheel onto the vehicle.
      */
      */
     // Note: Currently this method is silent on failure to find a host.
     // Note: Currently this method is silent on failure to find a host.
     void findAncestorAndBind();
     void findAncestorAndBind();

+ 6 - 9
gameplay/src/PlatformBlackBerry.cpp

@@ -566,8 +566,7 @@ Platform* Platform::create(Game* game, void* attachToWindow)
     sensor_request_events(SENSOR_TYPE_AZIMUTH_PITCH_ROLL);
     sensor_request_events(SENSOR_TYPE_AZIMUTH_PITCH_ROLL);
     navigator_request_events(0);
     navigator_request_events(0);
     navigator_rotation_lock(true);
     navigator_rotation_lock(true);
-    orientation_direction_t direction;
-    orientation_get(&direction, &__orientationAngle);
+    __orientationAngle = atoi(getenv("ORIENTATION"));
 
 
     int rc = 0;
     int rc = 0;
     int screenFormat = SCREEN_FORMAT_RGBA8888;
     int screenFormat = SCREEN_FORMAT_RGBA8888;
@@ -636,7 +635,7 @@ Platform* Platform::create(Game* game, void* attachToWindow)
         goto error;
         goto error;
     }
     }
 
 
-    // Set/get any window prooperties.
+    // Set/get any window properties.
     rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_FORMAT, &screenFormat);
     rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_FORMAT, &screenFormat);
     if (rc)
     if (rc)
     {
     {
@@ -658,8 +657,6 @@ Platform* Platform::create(Game* game, void* attachToWindow)
     }
     }
     else
     else
     {
     {
-        int angle = atoi(getenv("ORIENTATION"));
-
         screen_display_t screen_display;
         screen_display_t screen_display;
         rc = screen_get_window_property_pv(__screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&screen_display);
         rc = screen_get_window_property_pv(__screenWindow, SCREEN_PROPERTY_DISPLAY, (void **)&screen_display);
         if (rc)
         if (rc)
@@ -687,7 +684,7 @@ Platform* Platform::create(Game* game, void* attachToWindow)
         __screenWindowSize[0] = size[0];
         __screenWindowSize[0] = size[0];
         __screenWindowSize[1] = size[1];
         __screenWindowSize[1] = size[1];
 
 
-        if ((angle == 0) || (angle == 180))
+        if ((__orientationAngle == 0) || (__orientationAngle == 180))
         {
         {
             if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
             if (((screen_mode.width > screen_mode.height) && (size[0] < size[1])) ||
                 ((screen_mode.width < screen_mode.height) && (size[0] > size[1])))
                 ((screen_mode.width < screen_mode.height) && (size[0] > size[1])))
@@ -696,7 +693,7 @@ Platform* Platform::create(Game* game, void* attachToWindow)
                 __screenWindowSize[0] = size[1];
                 __screenWindowSize[0] = size[1];
             }
             }
         }
         }
-        else if ((angle == 90) || (angle == 270))
+        else if ((__orientationAngle == 90) || (__orientationAngle == 270))
         {
         {
             if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
             if (((screen_mode.width > screen_mode.height) && (size[0] > size[1])) ||
                 ((screen_mode.width < screen_mode.height) && (size[0] < size[1])))
                 ((screen_mode.width < screen_mode.height) && (size[0] < size[1])))
@@ -712,7 +709,7 @@ Platform* Platform::create(Game* game, void* attachToWindow)
         }
         }
 
 
 
 
-        rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_ROTATION, &angle);
+        rc = screen_set_window_property_iv(__screenWindow, SCREEN_PROPERTY_ROTATION, &__orientationAngle);
         if (rc)
         if (rc)
         {
         {
             perror("screen_set_window_property_iv(SCREEN_PROPERTY_ROTATION)");
             perror("screen_set_window_property_iv(SCREEN_PROPERTY_ROTATION)");
@@ -1316,7 +1313,7 @@ bool Platform::mouseEventInternal(Mouse::MouseEvent evt, int x, int y, int wheel
 
 
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 bool Platform::isGestureSupported(Gesture::GestureEvent evt)
 {
 {
-    // All are supported no need to test th bitset
+    // All are supported no need to test the bitset
     return true;
     return true;
 }
 }
 
 

+ 3 - 3
gameplay/src/PlatformWindows.cpp

@@ -1062,7 +1062,7 @@ int Platform::enterMessagePump()
             if (msg.message == WM_QUIT)
             if (msg.message == WM_QUIT)
             {
             {
                 _game->exit();
                 _game->exit();
-                break;
+                return msg.wParam;
             }
             }
         }
         }
         else
         else
@@ -1075,7 +1075,7 @@ int Platform::enterMessagePump()
         if (_game->getState() == Game::UNINITIALIZED)
         if (_game->getState() == Game::UNINITIALIZED)
             break;
             break;
     }
     }
-    return msg.wParam;
+    return 0;
 }
 }
 
 
 void Platform::signalShutdown() 
 void Platform::signalShutdown() 
@@ -1109,7 +1109,7 @@ double Platform::getAbsoluteTime()
     GP_ASSERT(__timeTicksPerMillis);
     GP_ASSERT(__timeTicksPerMillis);
     __timeAbsolute = queryTime.QuadPart / __timeTicksPerMillis;
     __timeAbsolute = queryTime.QuadPart / __timeTicksPerMillis;
 
 
-    return __timeAbsolute;
+    return __timeAbsolute - __timeStart;
 }
 }
 
 
 void Platform::setAbsoluteTime(double time)
 void Platform::setAbsoluteTime(double time)

+ 1 - 1
gameplay/src/Quaternion.cpp

@@ -389,7 +389,7 @@ void Quaternion::slerpForSquad(const Quaternion& q1, const Quaternion& q2, float
     // cos(omega) = q1 * q2;
     // cos(omega) = q1 * q2;
     // slerp(q1, q2, t) = (q1*sin((1-t)*omega) + q2*sin(t*omega))/sin(omega);
     // slerp(q1, q2, t) = (q1*sin((1-t)*omega) + q2*sin(t*omega))/sin(omega);
     // q1 = +- q2, slerp(q1,q2,t) = q1.
     // q1 = +- q2, slerp(q1,q2,t) = q1.
-    // This is a straight-foward implementation of the formula of slerp. It does not do any sign switching.
+    // This is a straight-forward implementation of the formula of slerp. It does not do any sign switching.
     float c = q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
     float c = q1.x * q2.x + q1.y * q2.y + q1.z * q2.z + q1.w * q2.w;
 
 
     if (fabs(c) >= 1.0f)
     if (fabs(c) >= 1.0f)

+ 1 - 1
gameplay/src/RadioButton.h

@@ -30,7 +30,7 @@ namespace gameplay
          text        = <string>
          text        = <string>
          group       = <string>
          group       = <string>
          iconSize    = <width, height>   // The size to draw the radio button icon, if different from its size in the texture.
          iconSize    = <width, height>   // The size to draw the radio button icon, if different from its size in the texture.
-         consumeEvents = <bool>          // Whether the radio button propogates input events to the Game's input event handler. Default is true.
+         consumeEvents = <bool>          // Whether the radio button propagates input events to the Game's input event handler. Default is true.
     }
     }
  @endverbatim
  @endverbatim
  */
  */

+ 125 - 135
gameplay/src/RenderState.cpp

@@ -16,6 +16,7 @@ namespace gameplay
 {
 {
 
 
 RenderState::StateBlock* RenderState::StateBlock::_defaultState = NULL;
 RenderState::StateBlock* RenderState::StateBlock::_defaultState = NULL;
+std::vector<RenderState::ResolveAutoBindingCallback> RenderState::_customAutoBindingResolvers;
 
 
 RenderState::RenderState()
 RenderState::RenderState()
     : _nodeBinding(NULL), _state(NULL), _parent(NULL)
     : _nodeBinding(NULL), _state(NULL), _parent(NULL)
@@ -46,6 +47,11 @@ void RenderState::finalize()
     SAFE_RELEASE(StateBlock::_defaultState);
     SAFE_RELEASE(StateBlock::_defaultState);
 }
 }
 
 
+void RenderState::registerAutoBindingResolver(ResolveAutoBindingCallback callback)
+{
+    _customAutoBindingResolvers.push_back(callback);
+}
+
 MaterialParameter* RenderState::getParameter(const char* name) const
 MaterialParameter* RenderState::getParameter(const char* name) const
 {
 {
     GP_ASSERT(name);
     GP_ASSERT(name);
@@ -69,91 +75,73 @@ MaterialParameter* RenderState::getParameter(const char* name) const
     return param;
     return param;
 }
 }
 
 
-void RenderState::setParameterAutoBinding(const char* name, AutoBinding autoBinding)
+const char* autoBindingToString(RenderState::AutoBinding autoBinding)
 {
 {
-    GP_ASSERT(name);
-
-    // Store the auto-binding.
-    if (autoBinding == NONE)
-    {
-        // Clear current auto binding.
-        std::map<std::string, AutoBinding>::iterator itr = _autoBindings.find(name);
-        if (itr != _autoBindings.end())
-        {
-            _autoBindings.erase(itr);
-        }
-    }
-    else
+    // NOTE: As new AutoBinding values are added, this switch statement must be updatd.
+    switch (autoBinding)
     {
     {
-        // Set new auto binding.
-        _autoBindings[name] = autoBinding;
-    }
+    case RenderState::NONE:
+        return NULL;
 
 
-    // If we have a currently set node binding, apply the auto binding immediately.
-    if (_nodeBinding)
-    {
-        applyAutoBinding(name, autoBinding);
+    case RenderState::VIEW_MATRIX:
+        return "VIEW_MATRIX";
+
+    case RenderState::PROJECTION_MATRIX:
+        return "PROJECTION_MATRIX";
+
+    case RenderState::WORLD_VIEW_MATRIX:
+        return "WORLD_VIEW_MATRIX";
+
+    case RenderState::VIEW_PROJECTION_MATRIX:
+        return "VIEW_PROJECTION_MATRIX";
+
+    case RenderState::WORLD_VIEW_PROJECTION_MATRIX:
+        return "WORLD_VIEW_PROJECTION_MATRIX";
+
+    case RenderState::INVERSE_TRANSPOSE_WORLD_MATRIX:
+        return "INVERSE_TRANSPOSE_WORLD_MATRIX";
+
+    case RenderState::INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX:
+        return "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX";
+
+    case RenderState::CAMERA_WORLD_POSITION:
+        return "CAMERA_WORLD_POSITION";
+
+    case RenderState::CAMERA_VIEW_POSITION:
+        return "CAMERA_VIEW_POSITION";
+
+    case RenderState::MATRIX_PALETTE:
+        return "MATRIX_PALETTE";
     }
     }
 }
 }
 
 
+void RenderState::setParameterAutoBinding(const char* name, AutoBinding autoBinding)
+{
+    setParameterAutoBinding(name, autoBindingToString(autoBinding));
+}
+
 void RenderState::setParameterAutoBinding(const char* name, const char* autoBinding)
 void RenderState::setParameterAutoBinding(const char* name, const char* autoBinding)
 {
 {
+    GP_ASSERT(name);
     GP_ASSERT(autoBinding);
     GP_ASSERT(autoBinding);
-    AutoBinding value = NONE;
 
 
-    // Parse the passed in autoBinding string.
-    if (strcmp(autoBinding, "WORLD_MATRIX") == 0)
+    if (autoBinding == NULL)
     {
     {
-        value = WORLD_MATRIX;
-    }
-    else if (strcmp(autoBinding, "VIEW_MATRIX") == 0)
-    {
-        value = VIEW_MATRIX;
-    }
-    else if (strcmp(autoBinding, "PROJECTION_MATRIX") == 0)
-    {
-        value = PROJECTION_MATRIX;
-    }
-    else if (strcmp(autoBinding, "WORLD_VIEW_MATRIX") == 0)
-    {
-        value = WORLD_VIEW_MATRIX;
-    }
-    else if (strcmp(autoBinding, "VIEW_PROJECTION_MATRIX") == 0)
-    {
-        value = VIEW_PROJECTION_MATRIX;
-    }
-    else if (strcmp(autoBinding, "WORLD_VIEW_PROJECTION_MATRIX") == 0)
-    {
-        value = WORLD_VIEW_PROJECTION_MATRIX;
-    }
-    else if (strcmp(autoBinding, "INVERSE_TRANSPOSE_WORLD_MATRIX") == 0)
-    {
-        value = INVERSE_TRANSPOSE_WORLD_MATRIX;
-    }
-    else if (strcmp(autoBinding, "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX") == 0)
-    {
-        value = INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX;
-    }
-    else if (strcmp(autoBinding, "CAMERA_WORLD_POSITION") == 0)
-    {
-        value = CAMERA_WORLD_POSITION;
-    }
-    else if (strcmp(autoBinding, "CAMERA_VIEW_POSITION") == 0)
-    {
-        value = CAMERA_VIEW_POSITION;
-    }
-    else if (strcmp(autoBinding, "MATRIX_PALETTE") == 0)
-    {
-        value = MATRIX_PALETTE;
+        // Remove an existing auto-binding
+        std::map<std::string, std::string>::iterator itr = _autoBindings.find(name);
+        if (itr != _autoBindings.end())
+            _autoBindings.erase(itr);
     }
     }
     else
     else
     {
     {
-        // Ignore all other cases (the value was previously set to the default of NONE).
+        // Add/update an auto-binding
+        _autoBindings[name] = autoBinding;
     }
     }
 
 
-    if (value != NONE)
+    // If we already have a node binding set, pass it to our handler now
+    if (_nodeBinding)
     {
     {
-        setParameterAutoBinding(name, value);
+        applyAutoBinding(name, autoBinding);
     }
     }
 }
 }
 
 
@@ -184,90 +172,92 @@ RenderState::StateBlock* RenderState::getStateBlock() const
 
 
 void RenderState::setNodeBinding(Node* node)
 void RenderState::setNodeBinding(Node* node)
 {
 {
-    _nodeBinding = node;
-
-    if (_nodeBinding)
+    if (_nodeBinding != node)
     {
     {
-        // Apply all existing auto-bindings using this node.
-        std::map<std::string, AutoBinding>::const_iterator itr = _autoBindings.begin();
-        while (itr != _autoBindings.end())
+        _nodeBinding = node;
+
+        if (_nodeBinding)
         {
         {
-            applyAutoBinding(itr->first.c_str(), itr->second);
-            ++itr;
+            // Apply all existing auto-bindings using this node.
+            std::map<std::string, std::string>::const_iterator itr = _autoBindings.begin();
+            while (itr != _autoBindings.end())
+            {
+                applyAutoBinding(itr->first.c_str(), itr->second.c_str());
+                ++itr;
+            }
         }
         }
     }
     }
 }
 }
 
 
-void RenderState::applyAutoBinding(const char* uniformName, AutoBinding autoBinding)
+void RenderState::applyAutoBinding(const char* uniformName, const char* autoBinding)
 {
 {
     MaterialParameter* param = getParameter(uniformName);
     MaterialParameter* param = getParameter(uniformName);
-    switch (autoBinding)
+    GP_ASSERT(param);
+
+    // First attempt to resolve the binding using custom registered resolvers.
+    if (_customAutoBindingResolvers.size() > 0)
     {
     {
-    case WORLD_MATRIX:
-        GP_ASSERT(param);
-        param->bindValue(_nodeBinding, &Node::getWorldMatrix);
-        break;
+        for (size_t i = 0, count = _customAutoBindingResolvers.size(); i < count; ++i)
+        {
+            if (_customAutoBindingResolvers[i](autoBinding, _nodeBinding, param))
+                return; // handled by custom resolver
+        }
+    }
 
 
-    case VIEW_MATRIX:
-        GP_ASSERT(param);
+    // Perform built-in resolution
+    if (strcmp(autoBinding, "WORLD_MATRIX") == 0)
+    {
+        param->bindValue(_nodeBinding, &Node::getWorldMatrix);
+    }
+    else if (strcmp(autoBinding, "VIEW_MATRIX") == 0)
+    {
         param->bindValue(_nodeBinding, &Node::getViewMatrix);
         param->bindValue(_nodeBinding, &Node::getViewMatrix);
-        break;
-
-    case PROJECTION_MATRIX:
-        GP_ASSERT(param);
+    }
+    else if (strcmp(autoBinding, "PROJECTION_MATRIX") == 0)
+    {
         param->bindValue(_nodeBinding, &Node::getProjectionMatrix);
         param->bindValue(_nodeBinding, &Node::getProjectionMatrix);
-        break;
-
-    case WORLD_VIEW_MATRIX:
-        GP_ASSERT(param);
+    }
+    else if (strcmp(autoBinding, "WORLD_VIEW_MATRIX") == 0)
+    {
         param->bindValue(_nodeBinding, &Node::getWorldViewMatrix);
         param->bindValue(_nodeBinding, &Node::getWorldViewMatrix);
-        break;
-
-    case VIEW_PROJECTION_MATRIX:
-        GP_ASSERT(param);
+    }
+    else if (strcmp(autoBinding, "VIEW_PROJECTION_MATRIX") == 0)
+    {
         param->bindValue(_nodeBinding, &Node::getViewProjectionMatrix);
         param->bindValue(_nodeBinding, &Node::getViewProjectionMatrix);
-        break;
-
-    case WORLD_VIEW_PROJECTION_MATRIX:
-        GP_ASSERT(param);
+    }
+    else if (strcmp(autoBinding, "WORLD_VIEW_PROJECTION_MATRIX") == 0)
+    {
         param->bindValue(_nodeBinding, &Node::getWorldViewProjectionMatrix);
         param->bindValue(_nodeBinding, &Node::getWorldViewProjectionMatrix);
-        break;
-
-    case INVERSE_TRANSPOSE_WORLD_MATRIX:
-        GP_ASSERT(param);
+    }
+    else if (strcmp(autoBinding, "INVERSE_TRANSPOSE_WORLD_MATRIX") == 0)
+    {
         param->bindValue(_nodeBinding, &Node::getInverseTransposeWorldMatrix);
         param->bindValue(_nodeBinding, &Node::getInverseTransposeWorldMatrix);
-        break;
-
-    case INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX:
-        GP_ASSERT(param);
+    }
+    else if (strcmp(autoBinding, "INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX") == 0)
+    {
         param->bindValue(_nodeBinding, &Node::getInverseTransposeWorldViewMatrix);
         param->bindValue(_nodeBinding, &Node::getInverseTransposeWorldViewMatrix);
-        break;
-
-    case CAMERA_WORLD_POSITION:
-        GP_ASSERT(param);
+    }
+    else if (strcmp(autoBinding, "CAMERA_WORLD_POSITION") == 0)
+    {
         param->bindValue(_nodeBinding, &Node::getActiveCameraTranslationWorld);
         param->bindValue(_nodeBinding, &Node::getActiveCameraTranslationWorld);
-        break;
-
-    case CAMERA_VIEW_POSITION:
-        GP_ASSERT(param);
+    }
+    else if (strcmp(autoBinding, "CAMERA_VIEW_POSITION") == 0)
+    {
         param->bindValue(_nodeBinding, &Node::getActiveCameraTranslationView);
         param->bindValue(_nodeBinding, &Node::getActiveCameraTranslationView);
-        break;
-
-    case MATRIX_PALETTE:
+    }
+    else if (strcmp(autoBinding, "MATRIX_PALETTE") == 0)
+    {
+        Model* model = _nodeBinding->getModel();
+        MeshSkin* skin = model ? model->getSkin() : NULL;
+        if (skin)
         {
         {
-            Model* model = _nodeBinding->getModel();
-            MeshSkin* skin = model ? model->getSkin() : NULL;
-            if (skin)
-            {
-                GP_ASSERT(param);
-                param->bindValue(skin, &MeshSkin::getMatrixPalette, &MeshSkin::getMatrixPaletteSize);
-            }
+            GP_ASSERT(param);
+            param->bindValue(skin, &MeshSkin::getMatrixPalette, &MeshSkin::getMatrixPaletteSize);
         }
         }
-        break;
-
-    default:
-        GP_ERROR("Unsupported auto binding type (%d).", autoBinding);
-        break;
+    }
+    else
+    {
+        GP_WARN("Unsupported auto binding type (%d).", autoBinding);
     }
     }
 }
 }
 
 
@@ -326,7 +316,7 @@ RenderState* RenderState::getTopmost(RenderState* below)
         }
         }
         rs = rs->_parent;
         rs = rs->_parent;
     }
     }
-
+    
     return NULL;
     return NULL;
 }
 }
 
 
@@ -334,9 +324,9 @@ void RenderState::cloneInto(RenderState* renderState, NodeCloneContext& context)
 {
 {
     GP_ASSERT(renderState);
     GP_ASSERT(renderState);
 
 
-    for (std::map<std::string, AutoBinding>::const_iterator it = _autoBindings.begin(); it != _autoBindings.end(); ++it)
+    for (std::map<std::string, std::string>::const_iterator it = _autoBindings.begin(); it != _autoBindings.end(); ++it)
     {
     {
-        renderState->setParameterAutoBinding(it->first.c_str(), it->second);
+        renderState->setParameterAutoBinding(it->first.c_str(), it->second.c_str());
     }
     }
     for (std::vector<MaterialParameter*>::const_iterator it = _parameters.begin(); it != _parameters.end(); ++it)
     for (std::vector<MaterialParameter*>::const_iterator it = _parameters.begin(); it != _parameters.end(); ++it)
     {
     {
@@ -485,7 +475,7 @@ void RenderState::StateBlock::enableDepthWrite()
     GP_ASSERT(_defaultState);
     GP_ASSERT(_defaultState);
 
 
     // Internal method used by Game::clear() to restore depth writing before a
     // Internal method used by Game::clear() to restore depth writing before a
-    // clear operation. This is neccessary if the last code to draw before the
+    // clear operation. This is necessary if the last code to draw before the
     // next frame leaves depth writing disabled.
     // next frame leaves depth writing disabled.
     if (!_defaultState->_depthWriteEnabled)
     if (!_defaultState->_depthWriteEnabled)
     {
     {

+ 64 - 6
gameplay/src/RenderState.h

@@ -87,6 +87,27 @@ public:
         MATRIX_PALETTE
         MATRIX_PALETTE
     };
     };
 
 
+    /**
+     * Callback function prototype for resolving material parameter auto bindings.
+     *
+     * Functions matching this callback signature can be registered via the 
+     * RenderState::registerAutoBindingResolver method to extend or override the set
+     * of built-in material paramter auto bindings.
+     *
+     * @param autoBinding Name of the auto binding to resolve.
+     * @param node Node that is bound to the material of the specified parameter.
+     * @param parameter Material parameter to set the binding on.
+     *
+     * @return True ONLY if the implementations explicitly handles the auto binding, false otherwise.
+     *      Returning true here will prevent any further code (including built-in resolving code) from
+     *      handling the auto binding.
+     *
+     * @see RenderState::registerAutoBindingResolver(const char*, RenderState::AutoBindingResolver)
+     *
+     * @script{ignore}
+     */
+    typedef bool (*ResolveAutoBindingCallback) (const char* autoBinding, Node* node, MaterialParameter* parameter);
+
     /**
     /**
      * Defines blend constants supported by the blend function.
      * Defines blend constants supported by the blend function.
      */
      */
@@ -286,6 +307,35 @@ public:
      */
      */
     StateBlock* getStateBlock() const;
     StateBlock* getStateBlock() const;
 
 
+    /**
+     * Registers a custom auto binding resolver.
+     *
+     * Implementing a custom auto binding reolver allows the set of built-in parameter auto
+     * bindings to be extended or overridden. Any parameter auto binding that is set on a
+     * material will be forwarded to any custom auto binding resolvers, in the order in which
+     * they are registered. If a registered resolver returns true (specifying that it handles
+     * the specified autoBinding), no further code will be exeucted for that autoBinding.
+     * This allows auto binding resolvers to not only implement new/custom binding strings,
+     * but it also lets them override existing/built-in ones. For this reason, you should
+     * ensure that you ONLY return true if you explicitly handle a custom auto binding; return
+     * false otherwise.
+     *
+     * Note that the custom resolver is called only once for a RenderState object when its
+     * node binding is initially set. This occurs when a material is initially bound to a
+     * Model that belongs to a Node. The resolver is NOT called each frame or each time
+     * the RenderState is bound. Therefore, when implementing custom auto bindings for values
+     * that change over time, the you should bind a method pointer onto the passed in
+     * MaterialParaemter using the MaterialParameter::bindValue mehtod. This way, the bound 
+     * method will be called each frame to set an updated value into the MaterialParameter.
+     *
+     * If no registered resolvers explicitly handle an auto binding, the binding will attempt
+     * to be resolved using the internal/built-in resolver, which is able to handle any
+     * auto bindings found in the RenderState::AutoBinding enumeration.
+     *
+     * @param callback Callback function for resolving parameter auto bindings.
+     */
+    static void registerAutoBindingResolver(ResolveAutoBindingCallback callback);
+
 protected:
 protected:
 
 
     /**
     /**
@@ -320,9 +370,12 @@ protected:
     void setNodeBinding(Node* node);
     void setNodeBinding(Node* node);
 
 
     /**
     /**
-     * Applies the specified auto-binding.
+     * Applies the specified custom auto-binding.
+     *
+     * @param uniformName Name of the shader uniform.
+     * @param autoBinding Name of the auto binding.s
      */
      */
-    void applyAutoBinding(const char* uniformName, AutoBinding binding);
+    void applyAutoBinding(const char* uniformName, const char* autoBinding);
 
 
     /**
     /**
      * Binds the render state for this RenderState and any of its parents, top-down, 
      * Binds the render state for this RenderState and any of its parents, top-down, 
@@ -358,14 +411,14 @@ private:
 protected:
 protected:
 
 
     /**
     /**
-     * Collection of MaterialParameter's to be applied to the gamplay::Effect.
+     * Collection of MaterialParameter's to be applied to the gameplay::Effect.
      */
      */
     mutable std::vector<MaterialParameter*> _parameters;
     mutable std::vector<MaterialParameter*> _parameters;
-    
+
     /**
     /**
-     * Map of IDs to AutoBindings.
+     * Map of parameter names to auto binding strings.
      */
      */
-    std::map<std::string, AutoBinding> _autoBindings;
+    std::map<std::string, std::string> _autoBindings;
 
 
     /**
     /**
      * The Node bound to the RenderState.
      * The Node bound to the RenderState.
@@ -381,6 +434,11 @@ protected:
      * The RenderState's parent.
      * The RenderState's parent.
      */
      */
     RenderState* _parent;
     RenderState* _parent;
+
+    /**
+     * Map of custom auto binding resolverss.
+     */
+    static std::vector<ResolveAutoBindingCallback> _customAutoBindingResolvers;
 };
 };
 
 
 }
 }

+ 20 - 1
gameplay/src/RenderTarget.cpp

@@ -33,8 +33,17 @@ RenderTarget* RenderTarget::create(const char* id, unsigned int width, unsigned
         return NULL;
         return NULL;
     }
     }
 
 
+    RenderTarget* rt = create(id, texture);
+    texture->release();
+
+    return rt;
+}
+
+RenderTarget* RenderTarget::create(const char* id, Texture* texture)
+{
     RenderTarget* renderTarget = new RenderTarget(id);
     RenderTarget* renderTarget = new RenderTarget(id);
     renderTarget->_texture = texture;
     renderTarget->_texture = texture;
+    renderTarget->_texture->addRef();
 
 
     __renderTargets.push_back(renderTarget);
     __renderTargets.push_back(renderTarget);
 
 
@@ -64,10 +73,20 @@ const char* RenderTarget::getId() const
 {
 {
     return _id.c_str();
     return _id.c_str();
 }
 }
-     
+
 Texture* RenderTarget::getTexture() const
 Texture* RenderTarget::getTexture() const
 {
 {
     return _texture;
     return _texture;
 }
 }
 
 
+unsigned int RenderTarget::getWidth() const
+{
+    return _texture->getWidth();
+}
+
+unsigned int RenderTarget::getHeight() const
+{
+    return _texture->getHeight();
+}
+
 }
 }

+ 30 - 0
gameplay/src/RenderTarget.h

@@ -13,6 +13,8 @@ namespace gameplay
  */
  */
 class RenderTarget : public Ref
 class RenderTarget : public Ref
 {
 {
+    friend class FrameBuffer;
+
 public:
 public:
  
  
     /**
     /**
@@ -29,6 +31,20 @@ public:
      */
      */
     static RenderTarget* create(const char* id, unsigned int width, unsigned int height);
     static RenderTarget* create(const char* id, unsigned int width, unsigned int height);
 
 
+    /**
+     * Create a RenderTarget from the given Texture and add it to the list of
+     * available RenderTargets.
+     *
+     * Note that different hardware and OpenGL versions have different capabilities
+     * and restrictions on what texture formats are supported as render targets.
+     *
+     * @param id The ID of the new RenderTarget.
+     *
+     * @return A newly created RenderTarget.
+     * @script{create}
+     */
+    static RenderTarget* create(const char* id, Texture* texture);
+
     /**
     /**
      * Get a named RenderTarget from its ID.
      * Get a named RenderTarget from its ID.
      *
      *
@@ -51,6 +67,20 @@ public:
      * @return The backing texture of this RenderTarget.
      * @return The backing texture of this RenderTarget.
      */
      */
     Texture* getTexture() const;
     Texture* getTexture() const;
+
+    /**
+     * Returns the width of the RenderTarget.
+     *
+     * @return The width.
+     */
+    unsigned int getWidth() const;
+
+    /**
+     * Returns the height of the RenderTarget.
+     *
+     * @return The height.
+     */
+    unsigned int getHeight() const;
  
  
 private:
 private:
 
 

+ 2 - 0
gameplay/src/ScriptController.cpp

@@ -550,6 +550,7 @@ static const char* lua_loadfile_function =
     "    local oldLoadfile = loadfile\n"
     "    local oldLoadfile = loadfile\n"
     "    loadfile = function(filename)\n"
     "    loadfile = function(filename)\n"
     "        if filename ~= nil and not FileSystem.isAbsolutePath(filename) then\n"
     "        if filename ~= nil and not FileSystem.isAbsolutePath(filename) then\n"
+    "            FileSystem.createFileFromAsset(filename)\n"
     "            filename = FileSystem.getResourcePath() .. filename\n"
     "            filename = FileSystem.getResourcePath() .. filename\n"
     "        end\n"
     "        end\n"
     "        return oldLoadfile(filename)\n"
     "        return oldLoadfile(filename)\n"
@@ -561,6 +562,7 @@ static const char* lua_dofile_function =
     "    local oldDofile = dofile\n"
     "    local oldDofile = dofile\n"
     "    dofile = function(filename)\n"
     "    dofile = function(filename)\n"
     "        if filename ~= nil and not FileSystem.isAbsolutePath(filename) then\n"
     "        if filename ~= nil and not FileSystem.isAbsolutePath(filename) then\n"
+    "            FileSystem.createFileFromAsset(filename)\n"
     "            filename = FileSystem.getResourcePath() .. filename\n"
     "            filename = FileSystem.getResourcePath() .. filename\n"
     "        end\n"
     "        end\n"
     "        return oldDofile(filename)\n"
     "        return oldDofile(filename)\n"

+ 1 - 1
gameplay/src/ScriptController.h

@@ -81,7 +81,7 @@ public:
     operator T* () const;
     operator T* () const;
 
 
     /**
     /**
-     * Overloades [] operator to get/set item value at index.
+     * Overloads [] operator to get/set item value at index.
      */
      */
     T& operator[] (int index);
     T& operator[] (int index);
 
 

+ 1 - 1
gameplay/src/Slider.h

@@ -25,7 +25,7 @@ namespace gameplay
         value       = <float>                   // The default position of the marker.
         value       = <float>                   // The default position of the marker.
         step        = <float>                   // If greater than 0, force the marker to snap to discrete multiples of 'step'.
         step        = <float>                   // If greater than 0, force the marker to snap to discrete multiples of 'step'.
         text        = <string>                  // Text to display above, below or alongside the slider (depending on the style).
         text        = <string>                  // Text to display above, below or alongside the slider (depending on the style).
-        consumeEvents = <bool>                  // Whether the slider propogates input events to the Game's input event handler. Default is true.
+        consumeEvents = <bool>                  // Whether the slider propagates input events to the Game's input event handler. Default is true.
         // TODO: orientation = <HORIZONTAL or VERTICAL>  // Determines whether a slider is stretched along its width or its height
         // TODO: orientation = <HORIZONTAL or VERTICAL>  // Determines whether a slider is stretched along its width or its height
     }
     }
  @endverbatim
  @endverbatim

+ 18 - 12
gameplay/src/Texture.cpp

@@ -43,8 +43,9 @@ namespace gameplay
 {
 {
 
 
 static std::vector<Texture*> __textureCache;
 static std::vector<Texture*> __textureCache;
+static TextureHandle __currentTextureId;
 
 
-Texture::Texture() : _handle(0), _format(RGBA), _width(0), _height(0), _mipmapped(false), _cached(false), _compressed(false)
+Texture::Texture() : _handle(0), _format(UNKNOWN), _width(0), _height(0), _mipmapped(false), _cached(false), _compressed(false)
 {
 {
 }
 }
 
 
@@ -162,7 +163,6 @@ Texture* Texture::create(Format format, unsigned int width, unsigned int height,
     GL_ASSERT( glPixelStorei(GL_UNPACK_ALIGNMENT, 1) );
     GL_ASSERT( glPixelStorei(GL_UNPACK_ALIGNMENT, 1) );
     GL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)format, width, height, 0, (GLenum)format, GL_UNSIGNED_BYTE, data) );
     GL_ASSERT( glTexImage2D(GL_TEXTURE_2D, 0, (GLenum)format, width, height, 0, (GLenum)format, GL_UNSIGNED_BYTE, data) );
 
 
-
     // Set initial minification filter based on whether or not mipmaping was enabled.
     // Set initial minification filter based on whether or not mipmaping was enabled.
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, generateMipmaps ? GL_NEAREST_MIPMAP_LINEAR : GL_LINEAR) );
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, generateMipmaps ? GL_NEAREST_MIPMAP_LINEAR : GL_LINEAR) );
 
 
@@ -174,9 +174,24 @@ Texture* Texture::create(Format format, unsigned int width, unsigned int height,
     if (generateMipmaps)
     if (generateMipmaps)
     {
     {
         texture->generateMipmaps();
         texture->generateMipmaps();
-        texture->_mipmapped = true;
     }
     }
 
 
+    // Restore the texture id
+    GL_ASSERT( glBindTexture(GL_TEXTURE_2D, __currentTextureId) );
+
+    return texture;
+}
+
+Texture* Texture::create(TextureHandle handle, int width, int height, Format format)
+{
+    GP_ASSERT(handle);
+
+    Texture* texture = new Texture();
+    texture->_handle = handle;
+    texture->_format = format;
+    texture->_width = width;
+    texture->_height = height;
+
     return texture;
     return texture;
 }
 }
 
 
@@ -760,33 +775,24 @@ TextureHandle Texture::getHandle() const
 
 
 void Texture::setWrapMode(Wrap wrapS, Wrap wrapT)
 void Texture::setWrapMode(Wrap wrapS, Wrap wrapT)
 {
 {
-    GLint currentTextureId;
-    GL_ASSERT( glGetIntegerv(GL_TEXTURE_BINDING_2D, &currentTextureId) );
     GL_ASSERT( glBindTexture(GL_TEXTURE_2D, _handle) );
     GL_ASSERT( glBindTexture(GL_TEXTURE_2D, _handle) );
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (GLenum)wrapS) );
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, (GLenum)wrapS) );
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (GLenum)wrapT) );
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, (GLenum)wrapT) );
-    GL_ASSERT( glBindTexture(GL_TEXTURE_2D, (GLuint)currentTextureId) );
 }
 }
 
 
 void Texture::setFilterMode(Filter minificationFilter, Filter magnificationFilter)
 void Texture::setFilterMode(Filter minificationFilter, Filter magnificationFilter)
 {
 {
-    GLint currentTextureId;
-    GL_ASSERT( glGetIntegerv(GL_TEXTURE_BINDING_2D, &currentTextureId) );
     GL_ASSERT( glBindTexture(GL_TEXTURE_2D, _handle) );
     GL_ASSERT( glBindTexture(GL_TEXTURE_2D, _handle) );
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLenum)minificationFilter) );
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, (GLenum)minificationFilter) );
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLenum)magnificationFilter) );
     GL_ASSERT( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, (GLenum)magnificationFilter) );
-    GL_ASSERT( glBindTexture(GL_TEXTURE_2D, (GLuint)currentTextureId) );
 }
 }
 
 
 void Texture::generateMipmaps()
 void Texture::generateMipmaps()
 {
 {
     if (!_mipmapped)
     if (!_mipmapped)
     {
     {
-        GLint currentTextureId;
-        GL_ASSERT( glGetIntegerv(GL_TEXTURE_BINDING_2D, &currentTextureId) );
         GL_ASSERT( glBindTexture(GL_TEXTURE_2D, _handle) );
         GL_ASSERT( glBindTexture(GL_TEXTURE_2D, _handle) );
         GL_ASSERT( glGenerateMipmap(GL_TEXTURE_2D) );
         GL_ASSERT( glGenerateMipmap(GL_TEXTURE_2D) );
-        GL_ASSERT( glBindTexture(GL_TEXTURE_2D, (GLuint)currentTextureId) );
 
 
         _mipmapped = true;
         _mipmapped = true;
     }
     }

+ 21 - 0
gameplay/src/Texture.h

@@ -22,6 +22,7 @@ public:
      */
      */
     enum Format
     enum Format
     {
     {
+        UNKNOWN = 0,
         RGB     = GL_RGB,
         RGB     = GL_RGB,
         RGBA    = GL_RGBA,
         RGBA    = GL_RGBA,
         ALPHA   = GL_ALPHA
         ALPHA   = GL_ALPHA
@@ -177,6 +178,26 @@ public:
      */
      */
     static Texture* create(Format format, unsigned int width, unsigned int height, unsigned char* data, bool generateMipmaps = false);
     static Texture* create(Format format, unsigned int width, unsigned int height, unsigned char* data, bool generateMipmaps = false);
 
 
+    /**
+     * Creates a texture object to wrap the specified pre-created native texture handle.
+     *
+     * The specified TextureHandle must represent a valid texture that has been created
+     * on the underlying renderer and it should not be referenced by any other Texture
+     * object. When the returned Texture object is destroyed, the passed in TextureHandle
+     * will also be destroyed.
+     *
+     * @param handle Native texture handle.
+     * @param width The width of the texture represented by 'handle'.
+     * @param height The height of the texture represented by 'handle'.
+     * @param format Optionally, the format of the texture represented by 'handle'.
+     *      If the format cannot be represented by any of the Texture::Format values,
+     *      use a value of UNKNOWN.
+     *
+     * @return The new texture.
+     * @script{create}
+     */
+    static Texture* create(TextureHandle handle, int width, int height, Format format = UNKNOWN);
+
     /**
     /**
      * Gets the format of the texture.
      * Gets the format of the texture.
      *
      *

+ 37 - 0
gameplay/src/lua/lua_FileSystem.cpp

@@ -16,6 +16,7 @@ void luaRegister_FileSystem()
     };
     };
     const luaL_Reg lua_statics[] = 
     const luaL_Reg lua_statics[] = 
     {
     {
+        {"createFileFromAsset", lua_FileSystem_static_createFileFromAsset},
         {"fileExists", lua_FileSystem_static_fileExists},
         {"fileExists", lua_FileSystem_static_fileExists},
         {"getResourcePath", lua_FileSystem_static_getResourcePath},
         {"getResourcePath", lua_FileSystem_static_getResourcePath},
         {"isAbsolutePath", lua_FileSystem_static_isAbsolutePath},
         {"isAbsolutePath", lua_FileSystem_static_isAbsolutePath},
@@ -77,6 +78,42 @@ int lua_FileSystem__gc(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_FileSystem_static_createFileFromAsset(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TSTRING || lua_type(state, 1) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<const char> param1 = ScriptUtil::getString(1, false);
+
+                FileSystem::createFileFromAsset(param1);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_FileSystem_static_createFileFromAsset - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_FileSystem_static_fileExists(lua_State* state)
 int lua_FileSystem_static_fileExists(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_FileSystem.h

@@ -6,6 +6,7 @@ namespace gameplay
 
 
 // Lua bindings for FileSystem.
 // Lua bindings for FileSystem.
 int lua_FileSystem__gc(lua_State* state);
 int lua_FileSystem__gc(lua_State* state);
+int lua_FileSystem_static_createFileFromAsset(lua_State* state);
 int lua_FileSystem_static_fileExists(lua_State* state);
 int lua_FileSystem_static_fileExists(lua_State* state);
 int lua_FileSystem_static_getResourcePath(lua_State* state);
 int lua_FileSystem_static_getResourcePath(lua_State* state);
 int lua_FileSystem_static_isAbsolutePath(lua_State* state);
 int lua_FileSystem_static_isAbsolutePath(lua_State* state);

+ 38 - 0
gameplay/src/lua/lua_Game.cpp

@@ -23,6 +23,7 @@ void luaRegister_Game()
 {
 {
     const luaL_Reg lua_members[] = 
     const luaL_Reg lua_members[] = 
     {
     {
+        {"canExit", lua_Game_canExit},
         {"clear", lua_Game_clear},
         {"clear", lua_Game_clear},
         {"displayKeyboard", lua_Game_displayKeyboard},
         {"displayKeyboard", lua_Game_displayKeyboard},
         {"exit", lua_Game_exit},
         {"exit", lua_Game_exit},
@@ -132,6 +133,43 @@ int lua_Game__gc(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Game_canExit(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                Game* instance = getInstance(state);
+                bool result = instance->canExit();
+
+                // Push the return value onto the stack.
+                lua_pushboolean(state, result);
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_Game_canExit - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Game_clear(lua_State* state)
 int lua_Game_clear(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Game.h

@@ -6,6 +6,7 @@ namespace gameplay
 
 
 // Lua bindings for Game.
 // Lua bindings for Game.
 int lua_Game__gc(lua_State* state);
 int lua_Game__gc(lua_State* state);
+int lua_Game_canExit(lua_State* state);
 int lua_Game_clear(lua_State* state);
 int lua_Game_clear(lua_State* state);
 int lua_Game_displayKeyboard(lua_State* state);
 int lua_Game_displayKeyboard(lua_State* state);
 int lua_Game_exit(lua_State* state);
 int lua_Game_exit(lua_State* state);

+ 229 - 0
gameplay/src/lua/lua_PhysicsRigidBody.cpp

@@ -33,6 +33,7 @@ void luaRegister_PhysicsRigidBody()
         {"applyTorqueImpulse", lua_PhysicsRigidBody_applyTorqueImpulse},
         {"applyTorqueImpulse", lua_PhysicsRigidBody_applyTorqueImpulse},
         {"collidesWith", lua_PhysicsRigidBody_collidesWith},
         {"collidesWith", lua_PhysicsRigidBody_collidesWith},
         {"getAngularDamping", lua_PhysicsRigidBody_getAngularDamping},
         {"getAngularDamping", lua_PhysicsRigidBody_getAngularDamping},
+        {"getAngularFactor", lua_PhysicsRigidBody_getAngularFactor},
         {"getAngularVelocity", lua_PhysicsRigidBody_getAngularVelocity},
         {"getAngularVelocity", lua_PhysicsRigidBody_getAngularVelocity},
         {"getAnisotropicFriction", lua_PhysicsRigidBody_getAnisotropicFriction},
         {"getAnisotropicFriction", lua_PhysicsRigidBody_getAnisotropicFriction},
         {"getCollisionShape", lua_PhysicsRigidBody_getCollisionShape},
         {"getCollisionShape", lua_PhysicsRigidBody_getCollisionShape},
@@ -40,6 +41,7 @@ void luaRegister_PhysicsRigidBody()
         {"getGravity", lua_PhysicsRigidBody_getGravity},
         {"getGravity", lua_PhysicsRigidBody_getGravity},
         {"getHeight", lua_PhysicsRigidBody_getHeight},
         {"getHeight", lua_PhysicsRigidBody_getHeight},
         {"getLinearDamping", lua_PhysicsRigidBody_getLinearDamping},
         {"getLinearDamping", lua_PhysicsRigidBody_getLinearDamping},
+        {"getLinearFactor", lua_PhysicsRigidBody_getLinearFactor},
         {"getLinearVelocity", lua_PhysicsRigidBody_getLinearVelocity},
         {"getLinearVelocity", lua_PhysicsRigidBody_getLinearVelocity},
         {"getMass", lua_PhysicsRigidBody_getMass},
         {"getMass", lua_PhysicsRigidBody_getMass},
         {"getNode", lua_PhysicsRigidBody_getNode},
         {"getNode", lua_PhysicsRigidBody_getNode},
@@ -51,6 +53,7 @@ void luaRegister_PhysicsRigidBody()
         {"isKinematic", lua_PhysicsRigidBody_isKinematic},
         {"isKinematic", lua_PhysicsRigidBody_isKinematic},
         {"isStatic", lua_PhysicsRigidBody_isStatic},
         {"isStatic", lua_PhysicsRigidBody_isStatic},
         {"removeCollisionListener", lua_PhysicsRigidBody_removeCollisionListener},
         {"removeCollisionListener", lua_PhysicsRigidBody_removeCollisionListener},
+        {"setAngularFactor", lua_PhysicsRigidBody_setAngularFactor},
         {"setAngularVelocity", lua_PhysicsRigidBody_setAngularVelocity},
         {"setAngularVelocity", lua_PhysicsRigidBody_setAngularVelocity},
         {"setAnisotropicFriction", lua_PhysicsRigidBody_setAnisotropicFriction},
         {"setAnisotropicFriction", lua_PhysicsRigidBody_setAnisotropicFriction},
         {"setDamping", lua_PhysicsRigidBody_setDamping},
         {"setDamping", lua_PhysicsRigidBody_setDamping},
@@ -58,6 +61,7 @@ void luaRegister_PhysicsRigidBody()
         {"setFriction", lua_PhysicsRigidBody_setFriction},
         {"setFriction", lua_PhysicsRigidBody_setFriction},
         {"setGravity", lua_PhysicsRigidBody_setGravity},
         {"setGravity", lua_PhysicsRigidBody_setGravity},
         {"setKinematic", lua_PhysicsRigidBody_setKinematic},
         {"setKinematic", lua_PhysicsRigidBody_setKinematic},
+        {"setLinearFactor", lua_PhysicsRigidBody_setLinearFactor},
         {"setLinearVelocity", lua_PhysicsRigidBody_setLinearVelocity},
         {"setLinearVelocity", lua_PhysicsRigidBody_setLinearVelocity},
         {"setRestitution", lua_PhysicsRigidBody_setRestitution},
         {"setRestitution", lua_PhysicsRigidBody_setRestitution},
         {NULL, NULL}
         {NULL, NULL}
@@ -441,6 +445,52 @@ int lua_PhysicsRigidBody_getAngularDamping(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_PhysicsRigidBody_getAngularFactor(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                PhysicsRigidBody* instance = getInstance(state);
+                void* returnPtr = (void*)new Vector3(instance->getAngularFactor());
+                if (returnPtr)
+                {
+                    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "Vector3");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_PhysicsRigidBody_getAngularFactor - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_PhysicsRigidBody_getAngularVelocity(lua_State* state)
 int lua_PhysicsRigidBody_getAngularVelocity(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -775,6 +825,53 @@ int lua_PhysicsRigidBody_getLinearDamping(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_PhysicsRigidBody_getLinearFactor(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 1:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA))
+            {
+                PhysicsRigidBody* instance = getInstance(state);
+                void* returnPtr = (void*)new Vector3(instance->getLinearFactor());
+                if (returnPtr)
+                {
+                    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "Vector3");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_PhysicsRigidBody_getLinearFactor - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 1).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
+
 int lua_PhysicsRigidBody_getLinearVelocity(lua_State* state)
 int lua_PhysicsRigidBody_getLinearVelocity(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -1251,6 +1348,72 @@ int lua_PhysicsRigidBody_removeCollisionListener(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_PhysicsRigidBody_setAngularFactor(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
+
+                PhysicsRigidBody* instance = getInstance(state);
+                instance->setAngularFactor(*param1);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_PhysicsRigidBody_setAngularFactor - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        case 4:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                float param1 = (float)luaL_checknumber(state, 2);
+
+                // Get parameter 2 off the stack.
+                float param2 = (float)luaL_checknumber(state, 3);
+
+                // Get parameter 3 off the stack.
+                float param3 = (float)luaL_checknumber(state, 4);
+
+                PhysicsRigidBody* instance = getInstance(state);
+                instance->setAngularFactor(param1, param2, param3);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_PhysicsRigidBody_setAngularFactor - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_PhysicsRigidBody_setAngularVelocity(lua_State* state)
 int lua_PhysicsRigidBody_setAngularVelocity(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.
@@ -1605,6 +1768,72 @@ int lua_PhysicsRigidBody_setKinematic(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_PhysicsRigidBody_setLinearFactor(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 2:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                (lua_type(state, 2) == LUA_TUSERDATA || lua_type(state, 2) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                ScriptUtil::LuaArray<Vector3> param1 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
+
+                PhysicsRigidBody* instance = getInstance(state);
+                instance->setLinearFactor(*param1);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_PhysicsRigidBody_setLinearFactor - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        case 4:
+        {
+            if ((lua_type(state, 1) == LUA_TUSERDATA) &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER)
+            {
+                // Get parameter 1 off the stack.
+                float param1 = (float)luaL_checknumber(state, 2);
+
+                // Get parameter 2 off the stack.
+                float param2 = (float)luaL_checknumber(state, 3);
+
+                // Get parameter 3 off the stack.
+                float param3 = (float)luaL_checknumber(state, 4);
+
+                PhysicsRigidBody* instance = getInstance(state);
+                instance->setLinearFactor(param1, param2, param3);
+                
+                return 0;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_PhysicsRigidBody_setLinearFactor - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 2 or 4).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_PhysicsRigidBody_setLinearVelocity(lua_State* state)
 int lua_PhysicsRigidBody_setLinearVelocity(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 4 - 0
gameplay/src/lua/lua_PhysicsRigidBody.h

@@ -23,6 +23,8 @@ int lua_PhysicsRigidBody_getLinearVelocity(lua_State* state);
 int lua_PhysicsRigidBody_getMass(lua_State* state);
 int lua_PhysicsRigidBody_getMass(lua_State* state);
 int lua_PhysicsRigidBody_getNode(lua_State* state);
 int lua_PhysicsRigidBody_getNode(lua_State* state);
 int lua_PhysicsRigidBody_getRestitution(lua_State* state);
 int lua_PhysicsRigidBody_getRestitution(lua_State* state);
+int lua_PhysicsRigidBody_getLinearFactor(lua_State* state);
+int lua_PhysicsRigidBody_getAngularFactor(lua_State* state);
 int lua_PhysicsRigidBody_getShapeType(lua_State* state);
 int lua_PhysicsRigidBody_getShapeType(lua_State* state);
 int lua_PhysicsRigidBody_getType(lua_State* state);
 int lua_PhysicsRigidBody_getType(lua_State* state);
 int lua_PhysicsRigidBody_isDynamic(lua_State* state);
 int lua_PhysicsRigidBody_isDynamic(lua_State* state);
@@ -39,6 +41,8 @@ int lua_PhysicsRigidBody_setGravity(lua_State* state);
 int lua_PhysicsRigidBody_setKinematic(lua_State* state);
 int lua_PhysicsRigidBody_setKinematic(lua_State* state);
 int lua_PhysicsRigidBody_setLinearVelocity(lua_State* state);
 int lua_PhysicsRigidBody_setLinearVelocity(lua_State* state);
 int lua_PhysicsRigidBody_setRestitution(lua_State* state);
 int lua_PhysicsRigidBody_setRestitution(lua_State* state);
+int lua_PhysicsRigidBody_setLinearFactor(lua_State* state);
+int lua_PhysicsRigidBody_setAngularFactor(lua_State* state);
 
 
 void luaRegister_PhysicsRigidBody();
 void luaRegister_PhysicsRigidBody();
 
 

+ 199 - 1
gameplay/src/lua/lua_PhysicsRigidBodyParameters.cpp

@@ -27,10 +27,12 @@ void luaRegister_PhysicsRigidBodyParameters()
     const luaL_Reg lua_members[] = 
     const luaL_Reg lua_members[] = 
     {
     {
         {"angularDamping", lua_PhysicsRigidBodyParameters_angularDamping},
         {"angularDamping", lua_PhysicsRigidBodyParameters_angularDamping},
+        {"angularFactor", lua_PhysicsRigidBodyParameters_angularFactor},
         {"anisotropicFriction", lua_PhysicsRigidBodyParameters_anisotropicFriction},
         {"anisotropicFriction", lua_PhysicsRigidBodyParameters_anisotropicFriction},
         {"friction", lua_PhysicsRigidBodyParameters_friction},
         {"friction", lua_PhysicsRigidBodyParameters_friction},
         {"kinematic", lua_PhysicsRigidBodyParameters_kinematic},
         {"kinematic", lua_PhysicsRigidBodyParameters_kinematic},
         {"linearDamping", lua_PhysicsRigidBodyParameters_linearDamping},
         {"linearDamping", lua_PhysicsRigidBodyParameters_linearDamping},
+        {"linearFactor", lua_PhysicsRigidBodyParameters_linearFactor},
         {"mass", lua_PhysicsRigidBodyParameters_mass},
         {"mass", lua_PhysicsRigidBodyParameters_mass},
         {"restitution", lua_PhysicsRigidBodyParameters_restitution},
         {"restitution", lua_PhysicsRigidBodyParameters_restitution},
         {NULL, NULL}
         {NULL, NULL}
@@ -410,9 +412,129 @@ int lua_PhysicsRigidBodyParameters__init(lua_State* state)
             }
             }
             break;
             break;
         }
         }
+        case 8:
+        {
+            if (lua_type(state, 1) == LUA_TNUMBER &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER &&
+                lua_type(state, 5) == LUA_TNUMBER &&
+                lua_type(state, 6) == LUA_TBOOLEAN &&
+                (lua_type(state, 7) == LUA_TUSERDATA || lua_type(state, 7) == LUA_TNIL) &&
+                (lua_type(state, 8) == LUA_TUSERDATA || lua_type(state, 8) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                float param1 = (float)luaL_checknumber(state, 1);
+
+                // Get parameter 2 off the stack.
+                float param2 = (float)luaL_checknumber(state, 2);
+
+                // Get parameter 3 off the stack.
+                float param3 = (float)luaL_checknumber(state, 3);
+
+                // Get parameter 4 off the stack.
+                float param4 = (float)luaL_checknumber(state, 4);
+
+                // Get parameter 5 off the stack.
+                float param5 = (float)luaL_checknumber(state, 5);
+
+                // Get parameter 6 off the stack.
+                bool param6 = ScriptUtil::luaCheckBool(state, 6);
+
+                // Get parameter 7 off the stack.
+                ScriptUtil::LuaArray<Vector3> param7 = ScriptUtil::getObjectPointer<Vector3>(7, "Vector3", true);
+
+                // Get parameter 8 off the stack.
+                ScriptUtil::LuaArray<Vector3> param8 = ScriptUtil::getObjectPointer<Vector3>(8, "Vector3", true);
+
+                void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2, param3, param4, param5, param6, *param7, *param8);
+                if (returnPtr)
+                {
+                    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "PhysicsRigidBodyParameters");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
+        case 9:
+        {
+            if (lua_type(state, 1) == LUA_TNUMBER &&
+                lua_type(state, 2) == LUA_TNUMBER &&
+                lua_type(state, 3) == LUA_TNUMBER &&
+                lua_type(state, 4) == LUA_TNUMBER &&
+                lua_type(state, 5) == LUA_TNUMBER &&
+                lua_type(state, 6) == LUA_TBOOLEAN &&
+                (lua_type(state, 7) == LUA_TUSERDATA || lua_type(state, 7) == LUA_TNIL) &&
+                (lua_type(state, 8) == LUA_TUSERDATA || lua_type(state, 8) == LUA_TNIL) &&
+                (lua_type(state, 9) == LUA_TUSERDATA || lua_type(state, 9) == LUA_TNIL))
+            {
+                // Get parameter 1 off the stack.
+                float param1 = (float)luaL_checknumber(state, 1);
+
+                // Get parameter 2 off the stack.
+                float param2 = (float)luaL_checknumber(state, 2);
+
+                // Get parameter 3 off the stack.
+                float param3 = (float)luaL_checknumber(state, 3);
+
+                // Get parameter 4 off the stack.
+                float param4 = (float)luaL_checknumber(state, 4);
+
+                // Get parameter 5 off the stack.
+                float param5 = (float)luaL_checknumber(state, 5);
+
+                // Get parameter 6 off the stack.
+                bool param6 = ScriptUtil::luaCheckBool(state, 6);
+
+                // Get parameter 7 off the stack.
+                ScriptUtil::LuaArray<Vector3> param7 = ScriptUtil::getObjectPointer<Vector3>(7, "Vector3", true);
+
+                // Get parameter 8 off the stack.
+                ScriptUtil::LuaArray<Vector3> param8 = ScriptUtil::getObjectPointer<Vector3>(8, "Vector3", true);
+                
+                // Get parameter 9 off the stack.
+                ScriptUtil::LuaArray<Vector3> param9 = ScriptUtil::getObjectPointer<Vector3>(9, "Vector3", true);
+
+                void* returnPtr = (void*)new PhysicsRigidBody::Parameters(param1, param2, param3, param4, param5, param6, *param7, *param8, *param9);
+                if (returnPtr)
+                {
+                    ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
+                    object->instance = returnPtr;
+                    object->owns = true;
+                    luaL_getmetatable(state, "PhysicsRigidBodyParameters");
+                    lua_setmetatable(state, -2);
+                }
+                else
+                {
+                    lua_pushnil(state);
+                }
+
+                return 1;
+            }
+            else
+            {
+                lua_pushstring(state, "lua_PhysicsRigidBodyParameters__init - Failed to match the given parameters to a valid function signature.");
+                lua_error(state);
+            }
+            break;
+        }
         default:
         default:
         {
         {
-            lua_pushstring(state, "Invalid number of parameters (expected 0, 1, 2, 3, 4, 5, 6 or 7).");
+            lua_pushstring(state, "Invalid number of parameters (expected 0, 1, 2, 3, 4, 5, 6, 7, 8 or 9).");
             lua_error(state);
             lua_error(state);
             break;
             break;
         }
         }
@@ -449,6 +571,44 @@ int lua_PhysicsRigidBodyParameters_angularDamping(lua_State* state)
     }
     }
 }
 }
 
 
+int lua_PhysicsRigidBodyParameters_angularFactor(lua_State* state)
+{
+    // Validate the number of parameters.
+    if (lua_gettop(state) > 2)
+    {
+        lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
+        lua_error(state);
+    }
+
+    PhysicsRigidBody::Parameters* instance = getInstance(state);
+    if (lua_gettop(state) == 2)
+    {
+        // Get parameter 2 off the stack.
+        ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
+
+        instance->angularFactor = *param2;
+        return 0;
+    }
+    else
+    {
+        void* returnPtr = (void*)new Vector3(instance->angularFactor);
+        if (returnPtr)
+        {
+            ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
+            object->instance = returnPtr;
+            object->owns = true;
+            luaL_getmetatable(state, "Vector3");
+            lua_setmetatable(state, -2);
+        }
+        else
+        {
+            lua_pushnil(state);
+        }
+
+        return 1;
+    }
+}
+
 int lua_PhysicsRigidBodyParameters_anisotropicFriction(lua_State* state)
 int lua_PhysicsRigidBodyParameters_anisotropicFriction(lua_State* state)
 {
 {
     // Validate the number of parameters.
     // Validate the number of parameters.
@@ -574,6 +734,44 @@ int lua_PhysicsRigidBodyParameters_linearDamping(lua_State* state)
     }
     }
 }
 }
 
 
+int lua_PhysicsRigidBodyParameters_linearFactor(lua_State* state)
+{
+    // Validate the number of parameters.
+    if (lua_gettop(state) > 2)
+    {
+        lua_pushstring(state, "Invalid number of parameters (expected 1 or 2).");
+        lua_error(state);
+    }
+
+    PhysicsRigidBody::Parameters* instance = getInstance(state);
+    if (lua_gettop(state) == 2)
+    {
+        // Get parameter 2 off the stack.
+        ScriptUtil::LuaArray<Vector3> param2 = ScriptUtil::getObjectPointer<Vector3>(2, "Vector3", true);
+
+        instance->linearFactor = *param2;
+        return 0;
+    }
+    else
+    {
+        void* returnPtr = (void*)new Vector3(instance->linearFactor);
+        if (returnPtr)
+        {
+            ScriptUtil::LuaObject* object = (ScriptUtil::LuaObject*)lua_newuserdata(state, sizeof(ScriptUtil::LuaObject));
+            object->instance = returnPtr;
+            object->owns = true;
+            luaL_getmetatable(state, "Vector3");
+            lua_setmetatable(state, -2);
+        }
+        else
+        {
+            lua_pushnil(state);
+        }
+
+        return 1;
+    }
+}
+
 int lua_PhysicsRigidBodyParameters_mass(lua_State* state)
 int lua_PhysicsRigidBodyParameters_mass(lua_State* state)
 {
 {
     // Validate the number of parameters.
     // Validate the number of parameters.

+ 2 - 0
gameplay/src/lua/lua_PhysicsRigidBodyParameters.h

@@ -8,10 +8,12 @@ namespace gameplay
 int lua_PhysicsRigidBodyParameters__gc(lua_State* state);
 int lua_PhysicsRigidBodyParameters__gc(lua_State* state);
 int lua_PhysicsRigidBodyParameters__init(lua_State* state);
 int lua_PhysicsRigidBodyParameters__init(lua_State* state);
 int lua_PhysicsRigidBodyParameters_angularDamping(lua_State* state);
 int lua_PhysicsRigidBodyParameters_angularDamping(lua_State* state);
+int lua_PhysicsRigidBodyParameters_angularFactor(lua_State* state);
 int lua_PhysicsRigidBodyParameters_anisotropicFriction(lua_State* state);
 int lua_PhysicsRigidBodyParameters_anisotropicFriction(lua_State* state);
 int lua_PhysicsRigidBodyParameters_friction(lua_State* state);
 int lua_PhysicsRigidBodyParameters_friction(lua_State* state);
 int lua_PhysicsRigidBodyParameters_kinematic(lua_State* state);
 int lua_PhysicsRigidBodyParameters_kinematic(lua_State* state);
 int lua_PhysicsRigidBodyParameters_linearDamping(lua_State* state);
 int lua_PhysicsRigidBodyParameters_linearDamping(lua_State* state);
+int lua_PhysicsRigidBodyParameters_linearFactor(lua_State* state);
 int lua_PhysicsRigidBodyParameters_mass(lua_State* state);
 int lua_PhysicsRigidBodyParameters_mass(lua_State* state);
 int lua_PhysicsRigidBodyParameters_restitution(lua_State* state);
 int lua_PhysicsRigidBodyParameters_restitution(lua_State* state);
 
 

+ 29 - 0
gameplay/src/lua/lua_Platform.cpp

@@ -19,6 +19,7 @@ void luaRegister_Platform()
     };
     };
     const luaL_Reg lua_statics[] = 
     const luaL_Reg lua_statics[] = 
     {
     {
+        {"canExit", lua_Platform_static_canExit},
         {"displayKeyboard", lua_Platform_static_displayKeyboard},
         {"displayKeyboard", lua_Platform_static_displayKeyboard},
         {"getAbsoluteTime", lua_Platform_static_getAbsoluteTime},
         {"getAbsoluteTime", lua_Platform_static_getAbsoluteTime},
         {"getAccelerometerValues", lua_Platform_static_getAccelerometerValues},
         {"getAccelerometerValues", lua_Platform_static_getAccelerometerValues},
@@ -147,6 +148,34 @@ int lua_Platform_enterMessagePump(lua_State* state)
     return 0;
     return 0;
 }
 }
 
 
+int lua_Platform_static_canExit(lua_State* state)
+{
+    // Get the number of parameters.
+    int paramCount = lua_gettop(state);
+
+    // Attempt to match the parameters to a valid binding.
+    switch (paramCount)
+    {
+        case 0:
+        {
+            bool result = Platform::canExit();
+
+            // Push the return value onto the stack.
+            lua_pushboolean(state, result);
+
+            return 1;
+            break;
+        }
+        default:
+        {
+            lua_pushstring(state, "Invalid number of parameters (expected 0).");
+            lua_error(state);
+            break;
+        }
+    }
+    return 0;
+}
+
 int lua_Platform_static_displayKeyboard(lua_State* state)
 int lua_Platform_static_displayKeyboard(lua_State* state)
 {
 {
     // Get the number of parameters.
     // Get the number of parameters.

+ 1 - 0
gameplay/src/lua/lua_Platform.h

@@ -7,6 +7,7 @@ namespace gameplay
 // Lua bindings for Platform.
 // Lua bindings for Platform.
 int lua_Platform__gc(lua_State* state);
 int lua_Platform__gc(lua_State* state);
 int lua_Platform_enterMessagePump(lua_State* state);
 int lua_Platform_enterMessagePump(lua_State* state);
+int lua_Platform_static_canExit(lua_State* state);
 int lua_Platform_static_displayKeyboard(lua_State* state);
 int lua_Platform_static_displayKeyboard(lua_State* state);
 int lua_Platform_static_getAbsoluteTime(lua_State* state);
 int lua_Platform_static_getAbsoluteTime(lua_State* state);
 int lua_Platform_static_getAccelerometerValues(lua_State* state);
 int lua_Platform_static_getAccelerometerValues(lua_State* state);