Ver Fonte

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

Steve Grenier há 13 anos atrás
pai
commit
8bbd80bc1b

+ 23 - 0
gameplay-encoder/gameplay-encoder.sln

@@ -0,0 +1,23 @@
+
+Microsoft Visual Studio Solution File, Format Version 11.00
+# Visual Studio 2010
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gameplay-encoder", "gameplay-encoder.vcxproj", "{9D69B743-4872-4DD1-8E30-0087C64298D7}"
+EndProject
+Global
+	GlobalSection(SolutionConfigurationPlatforms) = preSolution
+		Debug|Win32 = Debug|Win32
+		DebugMem|Win32 = DebugMem|Win32
+		Release|Win32 = Release|Win32
+	EndGlobalSection
+	GlobalSection(ProjectConfigurationPlatforms) = postSolution
+		{9D69B743-4872-4DD1-8E30-0087C64298D7}.Debug|Win32.ActiveCfg = Debug|Win32
+		{9D69B743-4872-4DD1-8E30-0087C64298D7}.Debug|Win32.Build.0 = Debug|Win32
+		{9D69B743-4872-4DD1-8E30-0087C64298D7}.DebugMem|Win32.ActiveCfg = Debug|Win32
+		{9D69B743-4872-4DD1-8E30-0087C64298D7}.DebugMem|Win32.Build.0 = Debug|Win32
+		{9D69B743-4872-4DD1-8E30-0087C64298D7}.Release|Win32.ActiveCfg = Release|Win32
+		{9D69B743-4872-4DD1-8E30-0087C64298D7}.Release|Win32.Build.0 = Release|Win32
+	EndGlobalSection
+	GlobalSection(SolutionProperties) = preSolution
+		HideSolutionNode = FALSE
+	EndGlobalSection
+EndGlobal

+ 2 - 2
gameplay-template/android/template.build.xml

@@ -64,8 +64,8 @@
     <target name="-post-compile">
         <copy file="../res/box.gpb" tofile="assets/res/box.gpb"/>
         <copy file="../res/box.material" tofile="assets/res/box.material"/>
-        <copy file="../res/colored.vsh" tofile="assets/res/colored.vsh"/>
-        <copy file="../res/colored.fsh" tofile="assets/res/colored.fsh"/>
+        <copy file="../res/colored.vert" tofile="assets/res/colored.vert"/>
+        <copy file="../res/colored.frag" tofile="assets/res/colored.frag"/>
     </target>
 
     <!-- Import the actual build file.

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

@@ -18,10 +18,10 @@
     <None Include="res\box.material">
       <Filter>res</Filter>
     </None>
-    <None Include="res\colored.fsh">
+    <None Include="res\colored.frag">
       <Filter>res</Filter>
     </None>
-    <None Include="res\colored.vsh">
+    <None Include="res\colored.vert">
       <Filter>res</Filter>
     </None>
   </ItemGroup>

+ 4 - 4
gameplay-template/res/box.material

@@ -2,17 +2,17 @@ material box
 {
     technique
     {
-        pass 0
+        pass
         {
             // shaders
-            vertexShader = res/colored.vsh
-            fragmentShader = res/colored.fsh
+            vertexShader = res/colored.vert
+            fragmentShader = res/colored.frag
             
             // uniforms
             u_worldViewProjectionMatrix = WORLD_VIEW_PROJECTION_MATRIX
             u_inverseTransposeWorldViewMatrix = INVERSE_TRANSPOSE_WORLD_VIEW_MATRIX
             u_ambientColor = 0.2, 0.2, 0.2
-            u_baseColor = 1.0, 1.0, 1.0, 1.0
+            u_diffuseColor = 1.0, 1.0, 1.0, 1.0
 
             // render state
             renderState

+ 4 - 4
gameplay-template/res/colored.fsh → gameplay-template/res/colored.frag

@@ -3,10 +3,10 @@ precision highp float;
 #endif
 
 // Uniforms
-uniform vec3 u_lightDirection;       	        // Light direction
-uniform vec3 u_lightColor;                      // Light color
+uniform vec4 u_diffuseColor;                    // Diffuse color
 uniform vec3 u_ambientColor;                    // Ambient color
-uniform vec4 u_baseColor;                    	// Base color
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_lightDirection;       	        // Light direction
 
 // Inputs
 varying vec3 v_normalVector;                    // Normal vector in view space.
@@ -14,7 +14,7 @@ varying vec3 v_normalVector;                    // Normal vector in view space.
 void main()
 {
 	// Base color
-    vec4 baseColor = u_baseColor;
+    vec4 baseColor = u_diffuseColor;
 
     // Normalize the vectors.
     vec3 lightDirection = normalize(u_lightDirection);

+ 5 - 4
gameplay-template/res/colored.vsh → gameplay-template/res/colored.vert

@@ -1,16 +1,17 @@
-// Uniforms
-uniform mat4 u_worldViewProjectionMatrix;           // Matrix to transform a position to clip space.
-uniform mat4 u_inverseTransposeWorldViewMatrix;     // Matrix to transform a normal to view space.
-
 // Inputs
 attribute vec4 a_position;                          // Vertex Position (x, y, z, w)
 attribute vec3 a_normal;                            // Vertex Normal (x, y, z)
 
+// Uniforms
+uniform mat4 u_worldViewProjectionMatrix;           // Matrix to transform a position to clip space.
+uniform mat4 u_inverseTransposeWorldViewMatrix;     // Matrix to transform a normal to view space.
+
 // Outputs
 varying vec3 v_normalVector;                        // Normal vector in view space.
 
 void main()
 {
+	// Vertex attributes
     vec4 position = a_position;
     vec3 normal = a_normal;
         

+ 1 - 1
gameplay/android/jni/Android.mk

@@ -16,7 +16,7 @@ LOCAL_PATH := $(call my-dir)/../../src
 
 include $(CLEAR_VARS)
 LOCAL_MODULE    := libgameplay
-LOCAL_SRC_FILES := AbsoluteLayout.cpp Animation.cpp AnimationClip.cpp AnimationController.cpp AnimationTarget.cpp AnimationValue.cpp AudioBuffer.cpp AudioController.cpp AudioListener.cpp AudioSource.cpp BoundingBox.cpp BoundingSphere.cpp Bundle.cpp Button.cpp Camera.cpp CheckBox.cpp Container.cpp Control.cpp Curve.cpp DebugNew.cpp DepthStencilTarget.cpp Effect.cpp FileSystem.cpp FlowLayout.cpp Font.cpp Form.cpp FrameBuffer.cpp Frustum.cpp Game.cpp gameplay-main-android.cpp Image.cpp Joint.cpp Joystick.cpp Label.cpp Layout.cpp Light.cpp Material.cpp MaterialParameter.cpp Matrix.cpp Mesh.cpp MeshBatch.cpp MeshPart.cpp MeshSkin.cpp Model.cpp Node.cpp ParticleEmitter.cpp Pass.cpp PhysicsCharacter.cpp PhysicsCollisionObject.cpp PhysicsCollisionShape.cpp PhysicsConstraint.cpp PhysicsController.cpp PhysicsFixedConstraint.cpp PhysicsGenericConstraint.cpp PhysicsGhostObject.cpp PhysicsHingeConstraint.cpp PhysicsRigidBody.cpp PhysicsSocketConstraint.cpp PhysicsSpringConstraint.cpp Plane.cpp PlatformAndroid.cpp Properties.cpp Quaternion.cpp RadioButton.cpp Ray.cpp Rectangle.cpp Ref.cpp RenderState.cpp RenderTarget.cpp Scene.cpp SceneLoader.cpp Slider.cpp SpriteBatch.cpp Technique.cpp TextBox.cpp Texture.cpp Theme.cpp ThemeStyle.cpp Transform.cpp Vector2.cpp Vector3.cpp Vector4.cpp VertexAttributeBinding.cpp VertexFormat.cpp VerticalLayout.cpp
+LOCAL_SRC_FILES := AbsoluteLayout.cpp Animation.cpp AnimationClip.cpp AnimationController.cpp AnimationTarget.cpp AnimationValue.cpp AudioBuffer.cpp AudioController.cpp AudioListener.cpp AudioSource.cpp BoundingBox.cpp BoundingSphere.cpp Bundle.cpp Button.cpp Camera.cpp CheckBox.cpp Container.cpp Control.cpp Curve.cpp DebugNew.cpp DepthStencilTarget.cpp Effect.cpp FileSystem.cpp FlowLayout.cpp Font.cpp Form.cpp FrameBuffer.cpp Frustum.cpp Game.cpp Gamepad.cpp gameplay-main-android.cpp Image.cpp Joint.cpp Joystick.cpp Label.cpp Layout.cpp Light.cpp Material.cpp MaterialParameter.cpp Matrix.cpp Mesh.cpp MeshBatch.cpp MeshPart.cpp MeshSkin.cpp Model.cpp Node.cpp ParticleEmitter.cpp Pass.cpp PhysicsCharacter.cpp PhysicsCollisionObject.cpp PhysicsCollisionShape.cpp PhysicsConstraint.cpp PhysicsController.cpp PhysicsFixedConstraint.cpp PhysicsGenericConstraint.cpp PhysicsGhostObject.cpp PhysicsHingeConstraint.cpp PhysicsRigidBody.cpp PhysicsSocketConstraint.cpp PhysicsSpringConstraint.cpp Plane.cpp PlatformAndroid.cpp Properties.cpp Quaternion.cpp RadioButton.cpp Ray.cpp Rectangle.cpp Ref.cpp RenderState.cpp RenderTarget.cpp Scene.cpp SceneLoader.cpp Slider.cpp SpriteBatch.cpp Technique.cpp TextBox.cpp Texture.cpp Theme.cpp ThemeStyle.cpp Transform.cpp Vector2.cpp Vector3.cpp Vector4.cpp VertexAttributeBinding.cpp VertexFormat.cpp VerticalLayout.cpp
 LOCAL_CFLAGS := -D__ANDROID__ -I"../../external-deps/bullet/include" -I"../../external-deps/libpng/include" -I"../../external-deps/oggvorbis/include" -I"../../external-deps/openal/include"
 LOCAL_STATIC_LIBRARIES := android_native_app_glue
 

+ 12 - 0
gameplay/gameplay.xcodeproj/project.pbxproj

@@ -171,6 +171,10 @@
 		42CD0EC8147D8FF60000361E /* VertexAttributeBinding.h in Headers */ = {isa = PBXBuildFile; fileRef = 42CD0E41147D8FF50000361E /* VertexAttributeBinding.h */; };
 		42CD0EC9147D8FF60000361E /* VertexFormat.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CD0E42147D8FF50000361E /* VertexFormat.cpp */; };
 		42CD0ECA147D8FF60000361E /* VertexFormat.h in Headers */ = {isa = PBXBuildFile; fileRef = 42CD0E43147D8FF50000361E /* VertexFormat.h */; };
+		42F4B7D715994CED00B5A78D /* Gamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42F4B7D515994CED00B5A78D /* Gamepad.cpp */; };
+		42F4B7D815994CED00B5A78D /* Gamepad.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42F4B7D515994CED00B5A78D /* Gamepad.cpp */; };
+		42F4B7D915994CED00B5A78D /* Gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 42F4B7D615994CED00B5A78D /* Gamepad.h */; };
+		42F4B7DA15994CED00B5A78D /* Gamepad.h in Headers */ = {isa = PBXBuildFile; fileRef = 42F4B7D615994CED00B5A78D /* Gamepad.h */; };
 		5B04C52D14BFCFE100EB0071 /* Animation.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CD0DB1147D8FF50000361E /* Animation.cpp */; };
 		5B04C52E14BFCFE100EB0071 /* AnimationClip.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CD0DB3147D8FF50000361E /* AnimationClip.cpp */; };
 		5B04C52F14BFCFE100EB0071 /* AnimationController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 42CD0DB5147D8FF50000361E /* AnimationController.cpp */; };
@@ -565,6 +569,8 @@
 		42CD0E41147D8FF50000361E /* VertexAttributeBinding.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VertexAttributeBinding.h; path = src/VertexAttributeBinding.h; sourceTree = SOURCE_ROOT; };
 		42CD0E42147D8FF50000361E /* VertexFormat.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = VertexFormat.cpp; path = src/VertexFormat.cpp; sourceTree = SOURCE_ROOT; };
 		42CD0E43147D8FF50000361E /* VertexFormat.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = VertexFormat.h; path = src/VertexFormat.h; sourceTree = SOURCE_ROOT; };
+		42F4B7D515994CED00B5A78D /* Gamepad.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = Gamepad.cpp; path = src/Gamepad.cpp; sourceTree = SOURCE_ROOT; };
+		42F4B7D615994CED00B5A78D /* Gamepad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = Gamepad.h; path = src/Gamepad.h; sourceTree = SOURCE_ROOT; };
 		5B04C5CA14BFCFE100EB0071 /* libgameplay.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libgameplay.a; sourceTree = BUILT_PRODUCTS_DIR; };
 		5B04C5CB14BFD48500EB0071 /* gameplay-main-ios.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = "gameplay-main-ios.mm"; path = "src/gameplay-main-ios.mm"; sourceTree = SOURCE_ROOT; };
 		5B04C5CC14BFD48500EB0071 /* PlatformiOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PlatformiOS.mm; path = src/PlatformiOS.mm; sourceTree = SOURCE_ROOT; };
@@ -755,6 +761,8 @@
 				42CD0DDC147D8FF50000361E /* Game.cpp */,
 				42CD0DDD147D8FF50000361E /* Game.h */,
 				42C932AF14919FD10098216A /* Game.inl */,
+				42F4B7D515994CED00B5A78D /* Gamepad.cpp */,
+				42F4B7D615994CED00B5A78D /* Gamepad.h */,
 				5BD5266A150F8257004C9099 /* gameplay.dox */,
 				42CD0DE1147D8FF50000361E /* gameplay.h */,
 				5BB0823814C6FEB10019975F /* gameplay-main-android.cpp */,
@@ -1075,6 +1083,7 @@
 				426878AE153F4BB300844500 /* FlowLayout.h in Headers */,
 				4239DDEE157545A1005EA3F6 /* Joystick.h in Headers */,
 				4239DDF4157545C1005EA3F6 /* MathUtil.h in Headers */,
+				42F4B7D915994CED00B5A78D /* Gamepad.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1173,6 +1182,7 @@
 				426878AF153F4BB300844500 /* FlowLayout.h in Headers */,
 				4239DDEF157545A1005EA3F6 /* Joystick.h in Headers */,
 				4239DDF5157545C1005EA3F6 /* MathUtil.h in Headers */,
+				42F4B7DA15994CED00B5A78D /* Gamepad.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1329,6 +1339,7 @@
 				422260D61537790F0011E3AB /* Bundle.cpp in Sources */,
 				426878AC153F4BB300844500 /* FlowLayout.cpp in Sources */,
 				4239DDEC157545A1005EA3F6 /* Joystick.cpp in Sources */,
+				42F4B7D715994CED00B5A78D /* Gamepad.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -1421,6 +1432,7 @@
 				422260D71537790F0011E3AB /* Bundle.cpp in Sources */,
 				426878AD153F4BB300844500 /* FlowLayout.cpp in Sources */,
 				4239DDED157545A1005EA3F6 /* Joystick.cpp in Sources */,
+				42F4B7D815994CED00B5A78D /* Gamepad.cpp in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

+ 7 - 8
gameplay/res/shaders/bumped.frag

@@ -1,5 +1,6 @@
 #define LIGHTING
 #define BUMPED
+
 #ifdef OPENGL_ES
 precision highp float;
 #endif
@@ -7,9 +8,6 @@ precision highp float;
 // Inputs
 varying vec3 v_normalVector;					// Normal vector in view space
 varying vec2 v_texCoord;						// Texture Coordinate
-#if defined(SPECULAR)
-varying vec3 v_cameraDirection;                 // Camera direction
-#endif
 #if defined(POINT_LIGHT)
 varying vec3 v_vertexToPointLightDirection;		// Light direction w.r.t current vertex in tangent space.
 varying float v_pointLightAttenuation;			// Attenuation of point light.
@@ -25,11 +23,11 @@ varying vec3 v_cameraDirection;                 // Camera direction
 #endif
 
 // Uniforms
-uniform sampler2D u_textureDiffuse;        		// Diffuse map texture
-uniform sampler2D u_textureNormal;       		// Normal map texture
-uniform vec3 u_lightDirection;					// Light direction
-uniform vec3 u_lightColor;                      // Light color
+uniform sampler2D u_diffuseTexture;        		// Diffuse map texture
+uniform sampler2D u_normalmapTexture;       	// Normalmap texture
 uniform vec3 u_ambientColor;                    // Ambient color
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_lightDirection;					// Light direction
 #if defined(SPECULAR)
 uniform float u_specularExponent;				// Specular exponent.
 #endif
@@ -50,10 +48,11 @@ uniform float u_spotLightOuterAngleCos;			// The soft outer part [0.0 - 1.0]
 #include "lib/lighting-directional.frag"
 #endif
 
+// Fragment program
 void main()
 {
     // Fetch diffuse color from texture.
-    _baseColor = texture2D(u_textureDiffuse, v_texCoord);
+    _baseColor = texture2D(u_diffuseTexture, v_texCoord);
 
     // Light the pixel
     gl_FragColor.a = _baseColor.a;

+ 23 - 15
gameplay/res/shaders/bumped.vert

@@ -1,16 +1,27 @@
 #define LIGHTING
 #define BUMPED
 
+// Inputs
+attribute vec4 a_position;									// Vertex Position							(x, y, z, w)
+attribute vec3 a_normal;									// Vertex Normal							(x, y, z)
+attribute vec2 a_texCoord;									// Vertex Texture Coordinate				(u, v)
+attribute vec3 a_tangent;									// Vertex Tangent							(x, y, z)
+attribute vec3 a_binormal;									// Vertex Binormal/Bitangent				(x, y, z)
+#if defined(SKINNING)
+attribute vec4 a_blendWeights;								// Vertex blend weight, up to 4				(0, 1, 2, 3) 
+attribute vec4 a_blendIndices;								// Vertex blend index int u_matrixPalette	(0, 1, 2, 3)
+#endif
+
 // Uniforms
 uniform mat4 u_worldViewProjectionMatrix;					// Matrix to transform a position to clip space
 uniform mat4 u_inverseTransposeWorldViewMatrix;				// Matrix to transform a normal to view space
 #if defined(SKINNING)
-uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];		// Array of 4x3 matrices as an array of floats
+uniform vec4 u_matrixPalette[SKINNING_JOINT_COUNT * 3];		// Array of 4x3 matrices
 #endif
 #if defined(SPECULAR)
 uniform mat4 u_worldViewMatrix;								// Matrix to tranform a position to view space
 uniform vec3 u_cameraPosition;                 				// Position of the camera in view space
-#endi
+#endif
 #if defined(TEXTURE_REPEAT)
 uniform vec2 u_textureRepeat;
 #endif
@@ -18,26 +29,22 @@ uniform vec2 u_textureRepeat;
 uniform vec2 u_textureOffset;
 #endif
 #if defined(POINT_LIGHT)
-uniform vec3 u_pointLightPosition;							// Position
+uniform vec3 u_pointLightPosition;							// Position of light
 uniform float u_pointLightRangeInverse;						// Inverse of light range
 #elif defined(SPOT_LIGHT)
-uniform vec3 u_spotLightPosition;							// Position
+uniform vec3 u_spotLightPosition;							// Position of light
 uniform float u_spotLightRangeInverse;						// Inverse of light range
-uniform vec3 u_spotLightDirection;							// Direction
+uniform vec3 u_spotLightDirection;							// Direction of light
 #else
-uniform vec3 u_lightDirection;								// Direction
+uniform vec3 u_lightDirection;								// Direction of light
 #endif
 
-// Inputs
-attribute vec4 a_position;									// Vertex Position              (x, y, z, w)
-attribute vec3 a_normal;									// Vertex Normal                (x, y, z)
-attribute vec2 a_texCoord;									// Vertex Texture Coordinate    (u, v)
-attribute vec3 a_tangent;									// Vertex Tangent               (x, y, z)
-attribute vec3 a_binormal;									// Vertex Binormal/Bitangent    (x, y, z)
-
 // Outputs
 varying vec3 v_normalVector;								// Normal vector in view space
-varying vec2 v_texCoord;									// Output Texture Coordinate     (u,v)
+varying vec2 v_texCoord;									// Texture Coordinate
+#if defined(SPECULAR)
+varying vec3 v_cameraDirection;								// Direction the camera is looking at in tangent space
+#endif
 // Lighting
 #if defined(POINT_LIGHT)
 varying vec3 v_vertexToPointLightDirection;					// Direction of point light w.r.t current vertex in tangent space
@@ -49,7 +56,7 @@ varying float v_spotLightAttenuation;						// Attenuation of spot light
 varying vec3 v_spotLightDirection;							// Direction of spot light in tangent space
 #include "lib/lighting-spot.vert"
 #else
-uniform vec3 u_lightDirection;								// Direction of light
+uniform vec3 v_lightDirection;								// Direction of light
 #include "lib/lighting-directional.vert"
 #endif
 
@@ -60,6 +67,7 @@ uniform vec3 u_lightDirection;								// Direction of light
 #include "lib/attributes.vert" 
 #endif
 
+// Vertex program
 void main()
 {
     // Get the position, normal, tangents and binormals.

+ 2 - 2
gameplay/res/shaders/colored-unlit.frag

@@ -7,7 +7,7 @@ precision highp float;
 varying vec3 v_color;						// Input Vertex color ( r g b )
 #endif
 
-uniform vec4 u_baseColor;               	// Base color
+uniform vec4 u_diffuseColor;               	// Diffuse color
 
 // Uniforms
 #if defined(MODULATE_COLOR)
@@ -24,7 +24,7 @@ void main()
     #if defined(VERTEX_COLOR)
 	gl_FragColor.rgb = v_color;
 	#else
-	gl_FragColor = u_baseColor;
+	gl_FragColor = u_diffuseColor;
     #endif
 	
 	// Global color modulation

+ 4 - 4
gameplay/res/shaders/colored.frag

@@ -23,10 +23,10 @@ varying vec3 v_cameraDirection;                 // Camera direction
 #endif
 
 // Uniforms
-uniform vec4 u_baseColor;               		// Base color
-uniform vec3 u_lightDirection;					// Light direction
-uniform vec3 u_lightColor;                      // Light color
+uniform vec4 u_diffuseColor;               		// Diffuse color
 uniform vec3 u_ambientColor;                    // Ambient color
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_lightDirection;					// Light direction
 #if defined(SPECULAR)
 uniform float u_specularExponent;				// Specular exponent
 #endif
@@ -54,7 +54,7 @@ void main()
     #if defined(VERTEX_COLOR)
 	_baseColor.rgb = v_color;
 	#else
-	_baseColor = u_baseColor;
+	_baseColor = u_diffuseColor;
 	#endif
 
     // Light the pixel

+ 1 - 1
gameplay/res/shaders/lib/lighting-directional.frag

@@ -3,7 +3,7 @@
 vec3 getLitPixel()
 {
     // Fetch normals from the normal map
-    vec3 normalVector = normalize(texture2D(u_textureNormal, v_texCoord).rgb * 2.0 - 1.0);
+    vec3 normalVector = normalize(texture2D(u_normalmapTexture, v_texCoord).rgb * 2.0 - 1.0);
     vec3 lightDirection = normalize(v_lightDirection);
     
     #if defined(SPECULAR)

+ 1 - 1
gameplay/res/shaders/lib/lighting-point.frag

@@ -3,7 +3,7 @@
 vec3 getLitPixel()
 {
     // Fetch normals from the normal map and normalize the vectors
-    vec3 normalVector = normalize(texture2D(u_textureNormal, v_texCoord).rgb * 2.0 - 1.0);
+    vec3 normalVector = normalize(texture2D(u_normalmapTexture, v_texCoord).rgb * 2.0 - 1.0);
     vec3 vertexToPointLightDirection = normalize(v_vertexToPointLightDirection);
     
     float pointLightAttenuation = clamp(v_pointLightAttenuation, 0.0, 1.0);

+ 1 - 1
gameplay/res/shaders/lib/lighting-spot.frag

@@ -8,7 +8,7 @@ float lerpstep( float lower, float upper, float s)
 vec3 getLitPixel()
 {
     // Fetch normals from the normal map.
-    vec3 normalVector = normalize(texture2D(u_textureNormal, v_texCoord).rgb * 2.0 - 1.0);
+    vec3 normalVector = normalize(texture2D(u_normalmapTexture, v_texCoord).rgb * 2.0 - 1.0);
     vec3 spotLightDirection = normalize(v_spotLightDirection);
     vec3 vertexToSpotLightDirection = normalize(v_vertexToSpotLightDirection);
     

+ 4 - 4
gameplay/res/shaders/textured-unlit.frag

@@ -3,9 +3,9 @@ precision highp float;
 #endif
 
 // Uniforms
-uniform sampler2D u_textureDiffuse;     	// Diffuse texture
+uniform sampler2D u_diffuseTexture;     	// Diffuse texture
 #if defined(TEXTURE_LIGHT)
-uniform sampler2D u_textureLight;     		// Lightmap texture
+uniform sampler2D u_lightmapTexture;     	// Lightmap texture
 #endif
 #if defined(MODULATE_COLOR)
 uniform vec4 u_modulateColor;               // Modulation color
@@ -21,9 +21,9 @@ varying vec2 v_texCoord;                	// Texture coordinate(u, v)
 void main()
 {
     // Sample the texture for the color
-    gl_FragColor = texture2D(u_textureDiffuse, v_texCoord);
+    gl_FragColor = texture2D(u_diffuseTexture, v_texCoord);
 	#if defined(TEXTURE_LIGHT)
-	vec4 lightColor = texture2D(u_textureLight, v_texCoord);
+	vec4 lightColor = texture2D(u_lightTexture, v_texCoord);
 	gl_FragColor.a *= lightColor.a;
 	#endif
 	// Global color modulation

+ 5 - 4
gameplay/res/shaders/textured.frag

@@ -22,10 +22,11 @@ varying vec3 v_cameraDirection;                 // Camera direction
 #endif
 
 // Uniforms
-uniform sampler2D u_textureDiffuse;             // Diffuse map texture
-uniform vec3 u_lightDirection;					// Light direction
-uniform vec3 u_lightColor;                      // Light color
+uniform sampler2D u_diffuseTexture;             // Diffuse map texture
 uniform vec3 u_ambientColor;                    // Ambient color
+uniform vec3 u_lightColor;                      // Light color
+uniform vec3 u_lightDirection;					// Light direction
+
 #if defined(SPECULAR)
 uniform float u_specularExponent;				// Specular exponent
 #endif
@@ -50,7 +51,7 @@ uniform float u_spotLightOuterAngleCos;			// The soft outer part [0.0 - 1.0]
 void main()
 {
     // Sample the diffuse texture for base color
-    _baseColor = texture2D(u_textureDiffuse, v_texCoord);
+    _baseColor = texture2D(u_diffuseTexture, v_texCoord);
 
     // Light the pixel
     gl_FragColor.a = _baseColor.a;

+ 4 - 12
gameplay/src/Container.cpp

@@ -271,7 +271,6 @@ Control* Container::getControl(const char* id) const
             }
         }
     }
-
     return NULL;
 }
 
@@ -381,13 +380,10 @@ void Container::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needs
     if (needsClear)
     {
         GL_ASSERT( glEnable(GL_SCISSOR_TEST) );
-        GL_ASSERT( glClearColor(0, 0, 0, 0) );
         float clearY = targetHeight - _clearBounds.y - _clearBounds.height;
-        GL_ASSERT( glScissor(_clearBounds.x, clearY,
-            _clearBounds.width, _clearBounds.height) );
-        GL_ASSERT( glClear(GL_COLOR_BUFFER_BIT) );
+        GL_ASSERT( glScissor(_clearBounds.x, clearY, _clearBounds.width, _clearBounds.height) );
+        Game::getInstance()->clear(Game::CLEAR_COLOR, Vector4::zero(), 1.0f, 0);
         GL_ASSERT( glDisable(GL_SCISSOR_TEST) );
-
         needsClear = false;
         cleared = true;
     }
@@ -440,9 +436,7 @@ void Container::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needs
 
             clipRegion.width += verticalRegion.width;
 
-            Rectangle bounds(_viewportBounds.x + _viewportBounds.width - verticalRegion.width,
-                             _viewportBounds.y + _scrollBarBounds.y,
-                             topRegion.width, topRegion.height);
+            Rectangle bounds(_viewportBounds.x + _viewportBounds.width - verticalRegion.width, _viewportBounds.y + _scrollBarBounds.y, topRegion.width, topRegion.height);
             spriteBatch->draw(bounds.x, bounds.y, bounds.width, bounds.height, topUVs.u1, topUVs.v1, topUVs.u2, topUVs.v2, topColor, clipRegion);
 
             bounds.y += topRegion.height;
@@ -474,9 +468,7 @@ void Container::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needs
 
             clipRegion.height += horizontalRegion.height;
         
-            Rectangle bounds(_viewportBounds.x + _scrollBarBounds.x,
-                             _viewportBounds.y + _viewportBounds.height - horizontalRegion.height,
-                             leftRegion.width, leftRegion.height);
+            Rectangle bounds(_viewportBounds.x + _scrollBarBounds.x, _viewportBounds.y + _viewportBounds.height - horizontalRegion.height, leftRegion.width, leftRegion.height);
             spriteBatch->draw(bounds.x, bounds.y, bounds.width, bounds.height, leftUVs.u1, leftUVs.v1, leftUVs.u2, leftUVs.v2, leftColor, clipRegion);
 
             bounds.x += leftRegion.width;

+ 2 - 4
gameplay/src/Control.cpp

@@ -977,10 +977,8 @@ void Control::draw(SpriteBatch* spriteBatch, const Rectangle& clip, bool needsCl
     if (needsClear)
     {
         GL_ASSERT( glEnable(GL_SCISSOR_TEST) );
-        GL_ASSERT( glClearColor(0, 0, 0, 0) );
-        GL_ASSERT( glScissor(_clearBounds.x, targetHeight - _clearBounds.y - _clearBounds.height,
-            _clearBounds.width, _clearBounds.height) );
-        GL_ASSERT( glClear(GL_COLOR_BUFFER_BIT) );
+        GL_ASSERT( glScissor(_clearBounds.x, targetHeight - _clearBounds.y - _clearBounds.height, _clearBounds.width, _clearBounds.height) );
+        Game::getInstance()->clear(Game::CLEAR_COLOR, Vector4::zero(), 1.0f, 0);
         GL_ASSERT( glDisable(GL_SCISSOR_TEST) );
     }
 

+ 3 - 6
gameplay/src/Form.cpp

@@ -240,9 +240,7 @@ void Form::setSize(float width, float height)
         Rectangle prevViewport = game->getViewport();
         game->setViewport(Rectangle(0, 0, width, height));
         _theme->setProjectionMatrix(_projectionMatrix);
-        GL_ASSERT( glClearColor(0, 0, 0, 0) );
-        GL_ASSERT( glClear(GL_COLOR_BUFFER_BIT) );
-        GL_ASSERT( glClearColor(0, 0, 0, 1) );
+        game->clear(Game::CLEAR_COLOR, Vector4::zero(), 1.0, 0);
         _theme->setProjectionMatrix(_defaultProjectionMatrix);
         FrameBuffer::bindDefault();
         game->setViewport(prevViewport);
@@ -290,7 +288,6 @@ void Form::setAutoHeight(bool autoHeight)
 void Form::setQuad(const Vector3& p1, const Vector3& p2, const Vector3& p3, const Vector3& p4)
 {
     Mesh* mesh = Mesh::createQuad(p1, p2, p3, p4);
-
     initializeQuad(mesh);
     SAFE_RELEASE(mesh);
 }
@@ -536,7 +533,7 @@ void Form::initializeQuad(Mesh* mesh)
     _quad = Model::create(mesh);
 
     // Create the material.
-    Material* material = _quad->setMaterial("res/shaders/textured.vsh", "res/shaders/textured.fsh");
+    Material* material = _quad->setMaterial("res/shaders/textured-unlit.vert", "res/shaders/textured-unlit.frag");
     GP_ASSERT(material);
 
     // Set the common render state block for the material.
@@ -545,6 +542,7 @@ void Form::initializeQuad(Mesh* mesh)
     RenderState::StateBlock* stateBlock = _theme->getSpriteBatch()->getStateBlock();
     GP_ASSERT(stateBlock);
     stateBlock->setDepthWrite(true);
+    stateBlock->setDepthTest(false);
     material->setStateBlock(stateBlock);
 
     // Bind the WorldViewProjection matrix.
@@ -555,7 +553,6 @@ void Form::initializeQuad(Mesh* mesh)
     GP_ASSERT(sampler);
     sampler->setWrapMode(Texture::CLAMP, Texture::CLAMP);
     material->getParameter("u_diffuseTexture")->setValue(sampler);
-    material->getParameter("u_diffuseColor")->setValue(Vector4::one());
 
     SAFE_RELEASE(sampler);
 }

+ 23 - 23
gameplay/src/SpriteBatch.cpp

@@ -9,7 +9,7 @@
 #define SPRITE_BATCH_GROW_FACTOR 2.0f
 
 // Macro for adding a sprite to the batch
-#define ADD_SPRITE_VERTEX(vtx, vx, vy, vz, vu, vv, vr, vg, vb, va) \
+#define SPRITE_ADD_VERTEX(vtx, vx, vy, vz, vu, vv, vr, vg, vb, va) \
     vtx.x = vx; vtx.y = vy; vtx.z = vz; \
     vtx.u = vu; vtx.v = vv; \
     vtx.r = vr; vtx.g = vg; vtx.b = vb; vtx.a = va
@@ -45,7 +45,6 @@
 namespace gameplay
 {
 
-// Shared sprite effects
 static Effect* __spriteEffect = NULL;
 
 SpriteBatch::SpriteBatch()
@@ -69,7 +68,9 @@ SpriteBatch::~SpriteBatch()
             __spriteEffect = NULL;
         }
         else
+        {
             __spriteEffect->release();
+        }
     }
 }
 
@@ -97,7 +98,6 @@ SpriteBatch* SpriteBatch::create(Texture* texture, Effect* effect, unsigned int
                 GP_ERROR("Unable to load sprite effect.");
                 return NULL;
             }
-
             effect = __spriteEffect;
         }
         else
@@ -242,10 +242,10 @@ void SpriteBatch::draw(float x, float y, float z, float width, float height, flo
 
     // Write sprite vertex data.
     static SpriteVertex v[4];
-    ADD_SPRITE_VERTEX(v[0], downLeft.x, downLeft.y, z, u1, v1, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(v[1], upLeft.x, upLeft.y, z, u1, v2, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(v[2], downRight.x, downRight.y, z, u2, v1, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(v[3], upRight.x, upRight.y, z, u2, v2, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[0], downLeft.x, downLeft.y, z, u1, v1, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[1], upLeft.x, upLeft.y, z, u1, v2, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[2], downRight.x, downRight.y, z, u2, v1, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[3], upRight.x, upRight.y, z, u2, v2, color.x, color.y, color.z, color.w);
     
     static unsigned short indices[4] = { 0, 1, 2, 3 };
 
@@ -308,10 +308,10 @@ void SpriteBatch::draw(const Vector3& position, const Vector3& right, const Vect
 
     // Add the sprite vertex data to the batch.
     static SpriteVertex v[4];
-    ADD_SPRITE_VERTEX(v[0], p0.x, p0.y, p0.z, u1, v1, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(v[1], p1.x, p1.y, p1.z, u2, v1, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(v[2], p2.x, p2.y, p2.z, u1, v2, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(v[3], p3.x, p3.y, p3.z, u2, v2, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[0], p0.x, p0.y, p0.z, u1, v1, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[1], p1.x, p1.y, p1.z, u2, v1, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[2], p2.x, p2.y, p2.z, u1, v2, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[3], p3.x, p3.y, p3.z, u2, v2, color.x, color.y, color.z, color.w);
     
     static const unsigned short indices[4] = { 0, 1, 2, 3 };
     _batch->add(v, 4, const_cast<unsigned short*>(indices), 4);
@@ -335,10 +335,10 @@ void SpriteBatch::addSprite(float x, float y, float width, float height, float u
 
     const float x2 = x + width;
     const float y2 = y + height;
-    ADD_SPRITE_VERTEX(vertices[0], x, y, 0, u1, v1, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(vertices[1], x, y2, 0, u1, v2, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(vertices[2], x2, y, 0, u2, v1, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(vertices[3], x2, y2, 0, u2, v2, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(vertices[0], x, y, 0, u1, v1, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(vertices[1], x, y2, 0, u1, v2, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(vertices[2], x2, y, 0, u2, v1, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(vertices[3], x2, y2, 0, u2, v2, color.x, color.y, color.z, color.w);
 }
 
 void SpriteBatch::addSprite(float x, float y, float width, float height, float u1, float v1, float u2, float v2, const Vector4& color, const Rectangle& clip, SpriteBatch::SpriteVertex* vertices)
@@ -350,10 +350,10 @@ void SpriteBatch::addSprite(float x, float y, float width, float height, float u
     {
         const float x2 = x + width;
         const float y2 = y + height;
-        ADD_SPRITE_VERTEX(vertices[0], x, y, 0, u1, v1, color.x, color.y, color.z, color.w);
-        ADD_SPRITE_VERTEX(vertices[1], x, y2, 0, u1, v2, color.x, color.y, color.z, color.w);
-        ADD_SPRITE_VERTEX(vertices[2], x2, y, 0, u2, v1, color.x, color.y, color.z, color.w);
-        ADD_SPRITE_VERTEX(vertices[3], x2, y2, 0, u2, v2, color.x, color.y, color.z, color.w);
+        SPRITE_ADD_VERTEX(vertices[0], x, y, 0, u1, v1, color.x, color.y, color.z, color.w);
+        SPRITE_ADD_VERTEX(vertices[1], x, y2, 0, u1, v2, color.x, color.y, color.z, color.w);
+        SPRITE_ADD_VERTEX(vertices[2], x2, y, 0, u2, v1, color.x, color.y, color.z, color.w);
+        SPRITE_ADD_VERTEX(vertices[3], x2, y2, 0, u2, v2, color.x, color.y, color.z, color.w);
     }
 }
 
@@ -378,10 +378,10 @@ void SpriteBatch::draw(float x, float y, float z, float width, float height, flo
     const float x2 = x + width;
     const float y2 = y + height;
     static SpriteVertex v[4];
-    ADD_SPRITE_VERTEX(v[0], x, y, z, u1, v1, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(v[1], x, y2, z, u1, v2, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(v[2], x2, y, z, u2, v1, color.x, color.y, color.z, color.w);
-    ADD_SPRITE_VERTEX(v[3], x2, y2, z, u2, v2, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[0], x, y, z, u1, v1, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[1], x, y2, z, u1, v2, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[2], x2, y, z, u2, v1, color.x, color.y, color.z, color.w);
+    SPRITE_ADD_VERTEX(v[3], x2, y2, z, u2, v2, color.x, color.y, color.z, color.w);
 
     static unsigned short indices[4] = { 0, 1, 2, 3 };