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

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

Darryl Gough 13 лет назад
Родитель
Сommit
4879c1194f

+ 7 - 7
gameplay.sln

@@ -25,7 +25,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample03-character", "gamep
 EndProject
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gameplay-encoder", "gameplay-encoder\gameplay-encoder.vcxproj", "{9D69B743-4872-4DD1-8E30-0087C64298D7}"
 EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample04-particles", "gameplay-samples\sample04-particles\sample04-particles.vcxproj", "{1D20D446-ED1A-C1A6-21EE-0A973D7DA6E3}"
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sample04-particles", "gameplay-samples\sample04-particles\sample04-particles.vcxproj", "{F47B5740-3C0C-BACE-4C2B-EE23A358D499}"
 	ProjectSection(ProjectDependencies) = postProject
 		{1032BA4B-57EB-4348-9E03-29DD63E80E4A} = {1032BA4B-57EB-4348-9E03-29DD63E80E4A}
 	EndProjectSection
@@ -73,12 +73,12 @@ Global
 		{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
-		{1D20D446-ED1A-C1A6-21EE-0A973D7DA6E3}.Debug|Win32.ActiveCfg = Debug|Win32
-		{1D20D446-ED1A-C1A6-21EE-0A973D7DA6E3}.Debug|Win32.Build.0 = Debug|Win32
-		{1D20D446-ED1A-C1A6-21EE-0A973D7DA6E3}.DebugMem|Win32.ActiveCfg = DebugMem|Win32
-		{1D20D446-ED1A-C1A6-21EE-0A973D7DA6E3}.DebugMem|Win32.Build.0 = DebugMem|Win32
-		{1D20D446-ED1A-C1A6-21EE-0A973D7DA6E3}.Release|Win32.ActiveCfg = Release|Win32
-		{1D20D446-ED1A-C1A6-21EE-0A973D7DA6E3}.Release|Win32.Build.0 = Release|Win32
+		{F47B5740-3C0C-BACE-4C2B-EE23A358D499}.Debug|Win32.ActiveCfg = Debug|Win32
+		{F47B5740-3C0C-BACE-4C2B-EE23A358D499}.Debug|Win32.Build.0 = Debug|Win32
+		{F47B5740-3C0C-BACE-4C2B-EE23A358D499}.DebugMem|Win32.ActiveCfg = DebugMem|Win32
+		{F47B5740-3C0C-BACE-4C2B-EE23A358D499}.DebugMem|Win32.Build.0 = DebugMem|Win32
+		{F47B5740-3C0C-BACE-4C2B-EE23A358D499}.Release|Win32.ActiveCfg = Release|Win32
+		{F47B5740-3C0C-BACE-4C2B-EE23A358D499}.Release|Win32.Build.0 = Release|Win32
 	EndGlobalSection
 	GlobalSection(SolutionProperties) = preSolution
 		HideSolutionNode = FALSE

+ 7 - 0
gameplay/res/shaders/bumped-specular.fsh

@@ -8,6 +8,9 @@ uniform vec3 u_ambientColor;                // Ambient color.
 uniform float u_specularExponent;           // Specular exponent or shininess property.
 uniform sampler2D u_diffuseTexture;         // Diffuse texture.
 uniform sampler2D u_normalMapTexture;       // Normal map texture.
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;                    // Global alpha value
+#endif
 
 // Inputs
 varying vec2 v_texCoord;                    // Texture Coordinate.
@@ -114,4 +117,8 @@ void main()
     // Light the pixel
     gl_FragColor.a = _baseColor.a;
     gl_FragColor.rgb = _ambientColor + _diffuseColor + _specularColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 7 - 0
gameplay/res/shaders/bumped.fsh

@@ -7,6 +7,9 @@ uniform vec3 u_lightColor;                   // Light color.
 uniform vec3 u_ambientColor;                 // Ambient color.
 uniform sampler2D u_diffuseTexture;          // Diffuse texture.
 uniform sampler2D u_normalMapTexture;        // Normal map texture.
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;                    // Global alpha value
+#endif
 
 // Inputs
 varying vec2 v_texCoord;                     // Texture Coordinate.
@@ -103,4 +106,8 @@ void main()
     // Light the pixel
     gl_FragColor.a = _baseColor.a;
     gl_FragColor.rgb = _ambientColor + _diffuseColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 7 - 0
gameplay/res/shaders/colored-specular.fsh

@@ -9,6 +9,9 @@ uniform float u_specularExponent;               // Specular exponent or shinines
 #if !defined(VERTEX_COLOR)
 uniform vec4 u_diffuseColor;                    // Diffuse color
 #endif
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;                    // Global alpha value
+#endif
 
 // Inputs
 varying vec3 v_normalVector;                    // NormalVector in view space
@@ -122,4 +125,8 @@ void main()
     // Light the pixel
     gl_FragColor.a = _baseColor.a;
     gl_FragColor.rgb = _ambientColor + _diffuseColor + _specularColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 7 - 0
gameplay/res/shaders/colored.fsh

@@ -6,6 +6,9 @@ precision highp float;
 uniform vec3 u_lightColor;                      // Light color
 uniform vec3 u_ambientColor;                    // Ambient color
 uniform vec4 u_diffuseColor;                    // Diffuse color
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;                    // Global alpha value
+#endif
 
 // Inputs
 varying vec3 v_normalVector;                    // NormalVector in view space.
@@ -101,4 +104,8 @@ void main()
     // Light the pixel
     gl_FragColor.a = _baseColor.a;
     gl_FragColor.rgb = _ambientColor + _diffuseColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 7 - 0
gameplay/res/shaders/diffuse-specular.fsh

@@ -7,6 +7,9 @@ uniform vec3 u_lightColor;                      // Light color
 uniform vec3 u_ambientColor;                    // Ambient color
 uniform float u_specularExponent;               // Specular exponent or shininess property.
 uniform sampler2D u_diffuseTexture;             // Diffuse texture.
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;                    // Global alpha value
+#endif
 
 // Inputs
 varying vec3 v_normalVector;                    // NormalVector in view space.
@@ -114,4 +117,8 @@ void main()
     // Light the pixel
     gl_FragColor.a = _baseColor.a;
     gl_FragColor.rgb = _ambientColor + _diffuseColor + _specularColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 7 - 0
gameplay/res/shaders/diffuse.fsh

@@ -6,6 +6,9 @@ precision highp float;
 uniform vec3 u_lightColor;                      // Light color
 uniform vec3 u_ambientColor;                    // Ambient color
 uniform sampler2D u_diffuseTexture;             // Diffuse texture.
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;                    // Global alpha value
+#endif
 
 // Inputs
 varying vec3 v_normalVector;                    // NormalVector in view space.
@@ -101,4 +104,8 @@ void main()
     // Light the pixel
     gl_FragColor.a = _baseColor.a;
     gl_FragColor.rgb = _ambientColor + _diffuseColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 7 - 0
gameplay/res/shaders/parallax-specular.fsh

@@ -10,6 +10,9 @@ uniform sampler2D u_diffuseTexture;             // Diffuse texture.
 uniform sampler2D u_bumpMapTexture;             // Height map texture
 uniform sampler2D u_normalMapTexture;           // Normal map texture.
 uniform float u_parallaxHeight;                 // Parallax height
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;                    // Global alpha value
+#endif
 
 // Inputs
 varying vec2 v_texCoord;                        // Texture Coordinate.
@@ -165,4 +168,8 @@ void main()
     // Light the pixel
     gl_FragColor.a = _baseColor.a;
     gl_FragColor.rgb = _ambientColor + _diffuseColor + _specularColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 7 - 0
gameplay/res/shaders/parallax.fsh

@@ -9,6 +9,9 @@ uniform sampler2D u_diffuseTexture;             // Diffuse texture.
 uniform sampler2D u_bumpMapTexture;             // Height map texture
 uniform sampler2D u_normalMapTexture;           // Normal map texture.
 uniform float u_parallaxHeight;                 // Parallax height
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;                    // Global alpha value
+#endif
 
 // Inputs
 varying vec2 v_texCoord;                        // Texture Coordinate.
@@ -157,4 +160,8 @@ void main()
     // Light the pixel
     gl_FragColor.a = _baseColor.a;
     gl_FragColor.rgb = _ambientColor + _diffuseColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 7 - 0
gameplay/res/shaders/solid.fsh

@@ -4,8 +4,15 @@ precision highp float;
 
 // Uniforms
 uniform vec4 u_diffuseColor;        // Diffuse color
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;        // Global alpha value
+#endif
 
 void main()
 {
     gl_FragColor = u_diffuseColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 7 - 0
gameplay/res/shaders/textured.fsh

@@ -5,6 +5,9 @@ precision highp float;
 // Uniforms
 uniform sampler2D u_diffuseTexture;     // Diffuse texture
 uniform vec4 u_diffuseColor;            // Diffuse color/tint
+#if defined(GLOBAL_ALPHA)
+uniform float u_globalAlpha;            // Global alpha value
+#endif
 
 // Inputs
 varying vec2 v_texCoord;                // Texture coordinate (u, v).
@@ -12,4 +15,8 @@ varying vec2 v_texCoord;                // Texture coordinate (u, v).
 void main()
 {
     gl_FragColor = texture2D(u_diffuseTexture, v_texCoord) * u_diffuseColor;
+
+#if defined(GLOBAL_ALPHA)
+    gl_FragColor.a *= u_globalAlpha;
+#endif
 }

+ 0 - 1
gameplay/src/PlatformMacOSX.mm

@@ -6,7 +6,6 @@
 #include "Game.h"
 #include "Form.h"
 #include <unistd.h>
-
 #import <Cocoa/Cocoa.h>
 #import <QuartzCore/CVDisplayLink.h>
 #import <OpenGL/OpenGL.h>

+ 25 - 12
gameplay/src/PlatformiOS.mm

@@ -4,9 +4,8 @@
 #include "Platform.h"
 #include "FileSystem.h"
 #include "Game.h"
-
+#include "Form.h"
 #include <unistd.h>
-
 #import <UIKit/UIKit.h>
 #import <QuartzCore/QuartzCore.h>
 #import <CoreMotion/CoreMotion.h>
@@ -307,15 +306,15 @@ int getKey(unichar keyCode);
     if([text length] == 0) return;
     assert([text length] == 1);
     unichar c = [text characterAtIndex:0];
-    int gpk = getKey(c);
-    Game::getInstance()->keyEvent(Keyboard::KEY_PRESS, gpk);    
-    Game::getInstance()->keyEvent(Keyboard::KEY_RELEASE, gpk);    
+    int key = getKey(c);
+    Platform::keyEventInternal(Keyboard::KEY_PRESS, key);    
+    Platform::keyEventInternal(Keyboard::KEY_RELEASE, key);    
 }
 
 - (void)deleteBackward 
 {
-    Game::getInstance()->keyEvent(Keyboard::KEY_PRESS, Keyboard::KEY_BACKSPACE);    
-    Game::getInstance()->keyEvent(Keyboard::KEY_RELEASE, Keyboard::KEY_BACKSPACE);    
+    Platform::keyEventInternal(Keyboard::KEY_PRESS, Keyboard::KEY_BACKSPACE);    
+    Platform::keyEventInternal(Keyboard::KEY_RELEASE, Keyboard::KEY_BACKSPACE);    
 }
 
 - (BOOL)hasText 
@@ -333,7 +332,7 @@ int getKey(unichar keyCode);
         {
             uniqueTouch = [t hash];
         }
-        Game::getInstance()->touchEvent(Touch::TOUCH_PRESS, touchLoc.x, touchLoc.y, uniqueTouch);
+        Platform::touchEventInternal(Touch::TOUCH_PRESS, touchLoc.x, touchLoc.y, uniqueTouch);
     }
 }
 
@@ -345,7 +344,7 @@ int getKey(unichar keyCode);
         CGPoint touchLoc = [t locationInView:self];
         if(self.multipleTouchEnabled == YES) 
             uniqueTouch = [t hash];
-        Game::getInstance()->touchEvent(Touch::TOUCH_RELEASE, touchLoc.x, touchLoc.y, uniqueTouch);
+        Platform::touchEventInternal(Touch::TOUCH_RELEASE, touchLoc.x, touchLoc.y, uniqueTouch);
     }
 }
 
@@ -363,7 +362,7 @@ int getKey(unichar keyCode);
         CGPoint touchLoc = [t locationInView:self];
         if(self.multipleTouchEnabled == YES) 
             uniqueTouch = [t hash];
-        Game::getInstance()->touchEvent(Touch::TOUCH_MOVE, touchLoc.x, touchLoc.y, uniqueTouch);
+        Platform::touchEventInternal(Touch::TOUCH_MOVE, touchLoc.x, touchLoc.y, uniqueTouch);
     }
 }
 
@@ -394,8 +393,7 @@ int getKey(unichar keyCode);
 
 - (void)didReceiveMemoryWarning
 {
-    [super didReceiveMemoryWarning];    
-    // Release any cached data, images, etc that aren't in use.
+    [super didReceiveMemoryWarning];
 }
 
 #pragma mark - View lifecycle
@@ -862,6 +860,21 @@ void Platform::displayKeyboard(bool display)
         }
     }
 }
+    
+void Platform::touchEventInternal(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex)
+{
+    if (!Form::touchEventInternal(evt, x, y, contactIndex))
+    {
+        Game::getInstance()->touchEvent(evt, x, y, contactIndex);
+    }
+}
+
+void Platform::keyEventInternal(Keyboard::KeyEvent evt, int key)
+{
+    gameplay::Game::getInstance()->keyEvent(evt, key);
+    Form::keyEventInternal(evt, key);
+}
+    
 
 void Platform::sleep(long ms)
 {