Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge branch 'develop3d' of https://github.com/mono/MonoGame into dev…

…elop3d
  • Loading branch information...
commit 19f1a9d30b80175bb6933d03b4a592aab1d9b53e 2 parents 3e9dd59 + 48759f7
@azchohfi azchohfi authored
View
1  MonoGame.ContentPipeline/ContentProcessors/Processors/MGEffectProcessor.cs
@@ -27,6 +27,7 @@ public override CompiledEffectContent Process(EffectContent input, ContentProces
var options = new Options();
options.SourceFile = input.Identity.SourceFilename;
options.DX11Profile = platform == MonoGamePlatform.Windows8 ? true : false;
+ options.Debug = DebugMode == EffectProcessorDebugMode.Debug;
options.OutputFile = context.OutputFilename;
// Parse the MGFX file expanding includes, macros, and returning the techniques.
View
100 MonoGame.Framework/BoundingBox.cs
@@ -37,16 +37,16 @@ Olivier Dufour (Duff)
namespace Microsoft.Xna.Framework
{
- #if WINRT
+#if WINRT
[DataContract]
- #else
+#else
[Serializable]
- #endif
+#endif
public struct BoundingBox : IEquatable<BoundingBox>
{
#region Public Fields
-
+
#if WINRT
[DataMember]
#endif
@@ -143,28 +143,81 @@ public ContainmentType Contains(BoundingFrustum frustum)
public ContainmentType Contains(BoundingSphere sphere)
{
- if (sphere.Center.X - Min.X > sphere.Radius
- && sphere.Center.Y - Min.Y > sphere.Radius
- && sphere.Center.Z - Min.Z > sphere.Radius
- && Max.X - sphere.Center.X > sphere.Radius
- && Max.Y - sphere.Center.Y > sphere.Radius
- && Max.Z - sphere.Center.Z > sphere.Radius)
+ if (sphere.Center.X - Min.X >= sphere.Radius
+ && sphere.Center.Y - Min.Y >= sphere.Radius
+ && sphere.Center.Z - Min.Z >= sphere.Radius
+ && Max.X - sphere.Center.X >= sphere.Radius
+ && Max.Y - sphere.Center.Y >= sphere.Radius
+ && Max.Z - sphere.Center.Z >= sphere.Radius)
return ContainmentType.Contains;
double dmin = 0;
- if (sphere.Center.X - Min.X <= sphere.Radius)
- dmin += (sphere.Center.X - Min.X) * (sphere.Center.X - Min.X);
- else if (Max.X - sphere.Center.X <= sphere.Radius)
- dmin += (sphere.Center.X - Max.X) * (sphere.Center.X - Max.X);
- if (sphere.Center.Y - Min.Y <= sphere.Radius)
- dmin += (sphere.Center.Y - Min.Y) * (sphere.Center.Y - Min.Y);
- else if (Max.Y - sphere.Center.Y <= sphere.Radius)
- dmin += (sphere.Center.Y - Max.Y) * (sphere.Center.Y - Max.Y);
- if (sphere.Center.Z - Min.Z <= sphere.Radius)
- dmin += (sphere.Center.Z - Min.Z) * (sphere.Center.Z - Min.Z);
- else if (Max.Z - sphere.Center.Z <= sphere.Radius)
- dmin += (sphere.Center.Z - Max.Z) * (sphere.Center.Z - Max.Z);
+ double e = sphere.Center.X - Min.X;
+ if (e < 0)
+ {
+ if (e < -sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ else
+ {
+ e = sphere.Center.X - Max.X;
+ if (e > 0)
+ {
+ if (e > sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ }
+
+ e = sphere.Center.Y - Min.Y;
+ if (e < 0)
+ {
+ if (e < -sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ else
+ {
+ e = sphere.Center.Y - Max.Y;
+ if (e > 0)
+ {
+ if (e > sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ }
+
+ e = sphere.Center.Z - Min.Z;
+ if (e < 0)
+ {
+ if (e < -sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ else
+ {
+ e = sphere.Center.Z - Max.Z;
+ if (e > 0)
+ {
+ if (e > sphere.Radius)
+ {
+ return ContainmentType.Disjoint;
+ }
+ dmin += e * e;
+ }
+ }
if (dmin <= sphere.Radius * sphere.Radius)
return ContainmentType.Intersects;
@@ -445,7 +498,7 @@ public void Intersects(ref Plane plane, out PlaneIntersectionType result)
result = PlaneIntersectionType.Back;
return;
}
-
+
result = PlaneIntersectionType.Intersecting;
}
@@ -477,4 +530,3 @@ public override string ToString()
#endregion Public Methods
}
}
-
View
36 MonoGame.Framework/Graphics/Effect/Effect.cs
@@ -431,10 +431,14 @@ private static EffectPassCollection ReadPasses(BinaryReader reader, Effect effec
private static EffectParameterCollection ReadParameters(BinaryReader reader)
{
var collection = new EffectParameterCollection();
- var count = (int)reader.ReadByte(); if (count == 0) return collection;
+ var count = (int)reader.ReadByte();
+ if (count == 0)
+ return collection;
+
for (var i = 0; i < count; i++)
{
- var class_ = (EffectParameterClass)reader.ReadByte(); var type = (EffectParameterType)reader.ReadByte();
+ var class_ = (EffectParameterClass)reader.ReadByte();
+ var type = (EffectParameterType)reader.ReadByte();
var name = reader.ReadString();
var semantic = reader.ReadString();
var annotations = ReadAnnotations(reader);
@@ -448,14 +452,36 @@ private static EffectParameterCollection ReadParameters(BinaryReader reader)
if (elements.Count == 0 && structMembers.Count == 0)
{
switch (type)
- { case EffectParameterType.Bool: case EffectParameterType.Int32: { var buffer = new int[rowCount * columnCount]; for (var j = 0; j < buffer.Length; j++) buffer[j] = reader.ReadInt32(); data = buffer; break; }
+ {
+ case EffectParameterType.Bool:
+ case EffectParameterType.Int32:
+#if DIRECTX
+ // Under DirectX we properly store integers and booleans
+ // in an integer type.
+ //
+ // MojoShader on the otherhand stores everything in float
+ // types which is why this code is disabled under OpenGL.
+ {
+ var buffer = new int[rowCount * columnCount];
+ for (var j = 0; j < buffer.Length; j++)
+ buffer[j] = reader.ReadInt32();
+ data = buffer;
+ break;
+ }
+#endif
+
case EffectParameterType.Single:
{
var buffer = new float[rowCount * columnCount];
- for (var j = 0; j < buffer.Length; j++) buffer[j] = reader.ReadSingle(); data = buffer; break; }
+ for (var j = 0; j < buffer.Length; j++)
+ buffer[j] = reader.ReadSingle();
+ data = buffer;
+ break;
+ }
case EffectParameterType.String:
throw new NotImplementedException();
- }; }
+ }
+ }
var param = new EffectParameter(
class_, type, name, rowCount, columnCount, semantic,
annotations, elements, structMembers, data);
View
185 MonoGame.Framework/Graphics/Effect/EffectParameter.cs
@@ -95,15 +95,19 @@ internal EffectParameter(EffectParameter cloneSource)
/// </summary>
internal ulong StateKey { get; private set; }
- public void SetValue (object value)
- {
- throw new NotImplementedException();
- }
- public bool GetValueBoolean ()
+ public bool GetValueBoolean ()
{
- throw new NotImplementedException();
- }
+ if (ParameterClass != EffectParameterClass.Scalar || ParameterType != EffectParameterType.Bool)
+ throw new InvalidCastException();
+
+#if DIRECTX
+ return ((int[])Data)[0] != 0;
+#else
+ // MojoShader encodes even booleans into a float.
+ return ((float[])Data)[0] != 0.0f;
+#endif
+ }
public bool[] GetValueBooleanArray ()
{
@@ -112,8 +116,16 @@ public bool[] GetValueBooleanArray ()
public int GetValueInt32 ()
{
- return (int)Data;
- }
+ if (ParameterClass != EffectParameterClass.Scalar || ParameterType != EffectParameterType.Int32)
+ throw new InvalidCastException();
+
+#if DIRECTX
+ return ((int[])Data)[0];
+#else
+ // MojoShader encodes integers into a float.
+ return (int)((float[])Data)[0];
+#endif
+ }
public int[] GetValueInt32Array ()
{
@@ -122,15 +134,18 @@ public int[] GetValueInt32Array ()
public Matrix GetValueMatrix ()
{
- if (RowCount == 4 && ColumnCount == 4)
- {
- float[] floatData = (float[])Data;
- return new Matrix(floatData[0], floatData[4], floatData[8], floatData[12],
- floatData[1], floatData[5], floatData[9], floatData[13],
- floatData[2], floatData[6], floatData[10], floatData[14],
- floatData[3], floatData[7], floatData[11], floatData[15]);
- }
- throw new Exception("Matrix data incorrect or missing!");
+ if (ParameterClass != EffectParameterClass.Matrix || ParameterType != EffectParameterType.Single)
+ throw new InvalidCastException();
+
+ if (RowCount != 4 || ColumnCount != 4)
+ throw new InvalidCastException();
+
+ var floatData = (float[])Data;
+
+ return new Matrix( floatData[0], floatData[4], floatData[8], floatData[12],
+ floatData[1], floatData[5], floatData[9], floatData[13],
+ floatData[2], floatData[6], floatData[10], floatData[14],
+ floatData[3], floatData[7], floatData[11], floatData[15]);
}
public Matrix[] GetValueMatrixArray (int count)
@@ -150,13 +165,11 @@ public Quaternion[] GetValueQuaternionArray ()
public Single GetValueSingle ()
{
- switch(ParameterType)
- {
- case EffectParameterType.Int32:
- return (Single)(int)Data;
- default:
- return (Single)Data;
- }
+ // TODO: Should this fetch int and bool as a float?
+ if (ParameterClass != EffectParameterClass.Scalar || ParameterType != EffectParameterType.Single)
+ throw new InvalidCastException();
+
+ return ((float[])Data)[0];
}
public Single[] GetValueSingleArray ()
@@ -190,19 +203,29 @@ public Single[] GetValueSingleArray ()
public string GetValueString ()
{
- throw new NotImplementedException();
+ if (ParameterClass != EffectParameterClass.Object || ParameterType != EffectParameterType.String)
+ throw new InvalidCastException();
+
+ return ((string[])Data)[0];
}
public Texture2D GetValueTexture2D ()
{
+ if (ParameterClass != EffectParameterClass.Object || ParameterType != EffectParameterType.Texture2D)
+ throw new InvalidCastException();
+
return (Texture2D)Data;
}
- // TODO: Add Texture3D support!
- // public Texture3D GetValueTexture3D ()
- // {
- // return new Texture3D ();
- // }
+#if !GLES
+ public Texture3D GetValueTexture3D ()
+ {
+ if (ParameterClass != EffectParameterClass.Object || ParameterType != EffectParameterType.Texture3D)
+ throw new InvalidCastException();
+
+ return (Texture3D)Data;
+ }
+#endif
public TextureCube GetValueTextureCube ()
{
@@ -211,6 +234,9 @@ public TextureCube GetValueTextureCube ()
public Vector2 GetValueVector2 ()
{
+ if (ParameterClass != EffectParameterClass.Vector || ParameterType != EffectParameterType.Single)
+ throw new InvalidCastException();
+
var vecInfo = (float[])Data;
return new Vector2(vecInfo[0],vecInfo[1]);
}
@@ -222,6 +248,9 @@ public Vector2[] GetValueVector2Array ()
public Vector3 GetValueVector3 ()
{
+ if (ParameterClass != EffectParameterClass.Vector || ParameterType != EffectParameterType.Single)
+ throw new InvalidCastException();
+
var vecInfo = (float[])Data;
return new Vector3(vecInfo[0],vecInfo[1],vecInfo[2]);
}
@@ -233,6 +262,9 @@ public Vector3[] GetValueVector3Array ()
public Vector4 GetValueVector4 ()
{
+ if (ParameterClass != EffectParameterClass.Vector || ParameterType != EffectParameterType.Single)
+ throw new InvalidCastException();
+
var vecInfo = (float[])Data;
return new Vector4(vecInfo[0],vecInfo[1],vecInfo[2],vecInfo[3]);
}
@@ -244,7 +276,18 @@ public Vector4[] GetValueVector4Array ()
public void SetValue (bool value)
{
- throw new NotImplementedException();
+ if (ParameterClass != EffectParameterClass.Scalar || ParameterType != EffectParameterType.Bool)
+ throw new InvalidCastException();
+
+#if DIRECTX
+ // We store the bool as an integer as that
+ // is what the constant buffers expect.
+ ((int[])Data)[0] = value ? 1 : 0;
+#else
+ // MojoShader encodes even booleans into a float.
+ ((float[])Data)[0] = value ? 1 : 0;
+#endif
+ StateKey = unchecked(NextStateKey++);
}
public void SetValue (bool[] value)
@@ -254,7 +297,15 @@ public void SetValue (bool[] value)
public void SetValue (int value)
{
- Data = value;
+ if (ParameterClass != EffectParameterClass.Scalar || ParameterType != EffectParameterType.Int32)
+ throw new InvalidCastException();
+
+#if DIRECTX
+ ((int[])Data)[0] = value;
+#else
+ // MojoShader encodes integers into a float.
+ ((float[])Data)[0] = value;
+#endif
StateKey = unchecked(NextStateKey++);
}
@@ -269,7 +320,7 @@ public void SetValue(Matrix value)
// These unrolled loops do the transpose during assignment.
if (RowCount == 4 && ColumnCount == 4)
{
- float[] fData = (float[])Data;
+ var fData = (float[])Data;
fData[0] = value.M11;
fData[1] = value.M21;
@@ -293,7 +344,7 @@ public void SetValue(Matrix value)
}
else if (RowCount == 4 && ColumnCount == 3)
{
- float[] fData = (float[])Data;
+ var fData = (float[])Data;
fData[0] = value.M11;
fData[1] = value.M21;
@@ -312,7 +363,7 @@ public void SetValue(Matrix value)
}
else if (RowCount == 3 && ColumnCount == 4)
{
- float[] fData = (float[])Data;
+ var fData = (float[])Data;
fData[0] = value.M11;
fData[1] = value.M21;
@@ -332,7 +383,7 @@ public void SetValue(Matrix value)
}
else if (RowCount == 3 && ColumnCount == 3)
{
- float[] fData = (float[])Data;
+ var fData = (float[])Data;
fData[0] = value.M11;
fData[1] = value.M21;
@@ -356,7 +407,7 @@ public void SetValueTranspose(Matrix value)
// from the in-memory version effectively transposes them back to row-major.
if (RowCount == 4 && ColumnCount == 4)
{
- float[] fData = (float[])Data;
+ var fData = (float[])Data;
fData[0] = value.M11;
fData[1] = value.M12;
@@ -380,7 +431,7 @@ public void SetValueTranspose(Matrix value)
}
else if (RowCount == 4 && ColumnCount == 3)
{
- float[] fData = (float[])Data;
+ var fData = (float[])Data;
fData[0] = value.M11;
fData[1] = value.M12;
@@ -400,7 +451,7 @@ public void SetValueTranspose(Matrix value)
}
else if (RowCount == 3 && ColumnCount == 4)
{
- float[] fData = (float[])Data;
+ var fData = (float[])Data;
fData[0] = value.M11;
fData[1] = value.M12;
@@ -419,7 +470,7 @@ public void SetValueTranspose(Matrix value)
}
else if (RowCount == 3 && ColumnCount == 3)
{
- float[] fData = (float[])Data;
+ var fData = (float[])Data;
fData[0] = value.M11;
fData[1] = value.M12;
@@ -457,19 +508,10 @@ public void SetValue (Quaternion[] value)
public void SetValue (Single value)
{
- switch (ParameterClass)
- {
- case EffectParameterClass.Matrix:
- case EffectParameterClass.Vector:
- ((float[])Data)[0] = value;
- break;
- case EffectParameterClass.Scalar:
- Data = value;
- break;
- default:
- throw new NotImplementedException();
- }
+ if (ParameterType != EffectParameterType.Single)
+ throw new InvalidCastException();
+ ((float[])Data)[0] = value;
StateKey = unchecked(NextStateKey++);
}
@@ -488,13 +530,38 @@ public void SetValue (string value)
public void SetValue (Texture value)
{
+ if (ParameterClass != EffectParameterClass.Object)
+ throw new InvalidCastException();
+
+ if (value is Texture2D)
+ {
+ if ( ParameterType != EffectParameterType.Texture1D &&
+ ParameterType != EffectParameterType.Texture2D)
+ throw new InvalidCastException();
+ }
+#if !GLES
+ else if (value is Texture3D)
+ {
+ if (ParameterType != EffectParameterType.Texture3D)
+ throw new InvalidCastException();
+ }
+#endif
+ else
+ {
+ if (!(value is TextureCube) || ParameterType != EffectParameterType.TextureCube)
+ throw new InvalidCastException();
+ }
+
Data = value;
StateKey = unchecked(NextStateKey++);
}
public void SetValue (Vector2 value)
{
- float[] fData = (float[])Data;
+ if (ParameterClass != EffectParameterClass.Vector || ParameterType != EffectParameterType.Single)
+ throw new InvalidCastException();
+
+ var fData = (float[])Data;
fData[0] = value.X;
fData[1] = value.Y;
StateKey = unchecked(NextStateKey++);
@@ -509,7 +576,10 @@ public void SetValue (Vector2[] value)
public void SetValue (Vector3 value)
{
- float[] fData = (float[])Data;
+ if (ParameterClass != EffectParameterClass.Vector || ParameterType != EffectParameterType.Single)
+ throw new InvalidCastException();
+
+ var fData = (float[])Data;
fData[0] = value.X;
fData[1] = value.Y;
fData[2] = value.Z;
@@ -525,7 +595,10 @@ public void SetValue (Vector3[] value)
public void SetValue (Vector4 value)
{
- float[] fData = (float[])Data;
+ if (ParameterClass != EffectParameterClass.Vector || ParameterType != EffectParameterType.Single)
+ throw new InvalidCastException();
+
+ var fData = (float[])Data;
fData[0] = value.X;
fData[1] = value.Y;
fData[2] = value.Z;
View
12 MonoGame.Framework/Graphics/GraphicsDevice.cs
@@ -2047,15 +2047,17 @@ private int SetUserIndexBuffer<T>(T[] indexData, int indexOffset, int indexCount
{
DynamicIndexBuffer buffer;
- var indexSize = typeof(T) == typeof(short) ? IndexElementSize.SixteenBits : IndexElementSize.ThirtyTwoBits;
+ var indexType = typeof(T);
+ var indexSize = Marshal.SizeOf(indexType);
+ var indexElementSize = indexSize == 2 ? IndexElementSize.SixteenBits : IndexElementSize.ThirtyTwoBits;
- if (!_userIndexBuffers.TryGetValue(indexSize, out buffer) || buffer.IndexCount < indexCount)
+ if (!_userIndexBuffers.TryGetValue(indexElementSize, out buffer) || buffer.IndexCount < indexCount)
{
if (buffer != null)
buffer.Dispose();
- buffer = new DynamicIndexBuffer(this, indexSize, Math.Max(indexCount, 6000), BufferUsage.WriteOnly);
- _userIndexBuffers[indexSize] = buffer;
+ buffer = new DynamicIndexBuffer(this, indexElementSize, Math.Max(indexCount, 6000), BufferUsage.WriteOnly);
+ _userIndexBuffers[indexElementSize] = buffer;
}
var startIndex = buffer.UserOffset;
@@ -2063,7 +2065,7 @@ private int SetUserIndexBuffer<T>(T[] indexData, int indexOffset, int indexCount
if ((indexCount + buffer.UserOffset) < buffer.IndexCount)
{
buffer.UserOffset += indexCount;
- buffer.SetData(startIndex * 2, indexData, indexOffset, indexCount, SetDataOptions.NoOverwrite);
+ buffer.SetData(startIndex * indexSize, indexData, indexOffset, indexCount, SetDataOptions.NoOverwrite);
}
else
{
View
34 MonoGame.Framework/Graphics/Shader/ConstantBuffer.cs
@@ -119,38 +119,35 @@ internal void Clear()
private void SetData(int offset, int rows, int columns, object data)
{
- // TODO: Should i pass the element size in?
+ // Shader registers are always 4 bytes and all the
+ // incoming data objects should be 4 bytes per element.
const int elementSize = 4;
const int rowSize = elementSize * 4;
- // Take care of a single data type.
+ // Take care of a single element.
if (rows == 1 && columns == 1)
{
- // TODO: Consider storing all data in arrays to avoid
- // having to generate this temp array on every set.
- byte[] bytes;
-
- if (data is float)
- bytes = BitConverter.GetBytes((float)data);
- else if (data is int)
- // Integer values are treated as floats after the shader is converted, so we convert them.
- bytes = BitConverter.GetBytes((float)((int)data));
- else
- bytes = BitConverter.GetBytes(((float[])data)[0]);
-
- Buffer.BlockCopy(bytes, 0, _buffer, offset, elementSize);
+ // EffectParameter stores all values in arrays by default.
+ if (data is Array)
+ Buffer.BlockCopy(data as Array, 0, _buffer, offset, elementSize);
+ else
+ {
+ // TODO: When we eventually expose the internal Shader
+ // API then we will need to deal with non-array elements.
+ throw new NotImplementedException();
+ }
}
// Take care of the single copy case!
else if (rows == 1 || (rows == 4 && columns == 4))
- Buffer.BlockCopy(data as Array, 0, _buffer, offset, rows * columns * elementSize);
+ Buffer.BlockCopy(data as Array, 0, _buffer, offset, rows*columns*elementSize);
else
{
var source = data as Array;
- var stride = (columns * elementSize);
+ var stride = (columns*elementSize);
for (var y = 0; y < rows; y++)
- Buffer.BlockCopy(source, stride * y, _buffer, offset + (rowSize * y), columns * elementSize);
+ Buffer.BlockCopy(source, stride*y, _buffer, offset + (rowSize*y), columns*elementSize);
}
}
@@ -177,6 +174,7 @@ private int SetParameter(int offset, EffectParameter param)
{
case EffectParameterType.Single:
case EffectParameterType.Int32:
+ case EffectParameterType.Bool:
// HLSL assumes matrices are column-major, whereas in-memory we use row-major.
// TODO: HLSL can be told to use row-major. We should handle that too.
if (param.ParameterClass == EffectParameterClass.Matrix)
View
13 MonoGame.Framework/Graphics/Texture3D.cs
@@ -6,7 +6,6 @@
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif GLES
#endif
#elif DIRECTX
// TODO!
@@ -38,13 +37,17 @@ public Texture3D (GraphicsDevice graphicsDevice, int width, int height, int dept
#if OPENGL
this.glTarget = TextureTarget.Texture3D;
+
+ GL.GenTextures(1, out this.glTexture);
+ GraphicsExtensions.CheckGLError();
- GL.GenTextures (1, out this.glTexture);
GL.BindTexture (glTarget, glTexture);
+ GraphicsExtensions.CheckGLError();
format.GetGLFormat (out glInternalFormat, out glFormat, out glType);
GL.TexImage3D (glTarget, 0, glInternalFormat, width, height, depth, 0, glFormat, glType, IntPtr.Zero);
+ GraphicsExtensions.CheckGLError();
if (mipMap) {
throw new NotImplementedException ();
@@ -52,7 +55,7 @@ public Texture3D (GraphicsDevice graphicsDevice, int width, int height, int dept
#elif DIRECTX
#endif
- }
+ }
public void SetData<T> (T[] data) where T : struct
{
@@ -77,11 +80,13 @@ public Texture3D (GraphicsDevice graphicsDevice, int width, int height, int dept
#if OPENGL
GL.BindTexture(glTarget, glTexture);
+ GraphicsExtensions.CheckGLError();
GL.TexSubImage3D(glTarget, level, left, top, front, right-left, bottom-top, back-front, glFormat, glType, dataPtr);
+ GraphicsExtensions.CheckGLError();
#elif DIRECTX
#endif
- dataHandle.Free ();
+ dataHandle.Free ();
}
View
1  MonoGame.Framework/MonoGame.Framework.Linux.csproj
@@ -386,6 +386,7 @@
<Compile Include="Graphics\SpriteBatcher.cs" />
<Compile Include="Graphics\SpriteFont.cs" />
<Compile Include="Graphics\Texture2D.cs" />
+ <Compile Include="Graphics\Texture3D.cs" />
<Compile Include="Graphics\TextureCube.cs" />
<Compile Include="GameWindow.cs" />
<Compile Include="Input\MouseState.cs" />
View
1  MonoGame.Framework/MonoGame.Framework.PSMobile.csproj
@@ -303,6 +303,7 @@
<Compile Include="PSSuite\Input\Keyboard.cs" />
<Compile Include="Input\Mouse.cs" />
<Compile Include="Graphics\Texture2D.cs" />
+ <Compile Include="Graphics\Texture3D.cs" />
<Compile Include="Graphics\SpriteFont.cs" />
<Compile Include="Graphics\Effect\EffectParameter.cs" />
<Compile Include="Graphics\Effect\EffectPass.cs" />
View
1  MonoGame.Framework/MonoGame.Framework.Windows8.csproj
@@ -108,6 +108,7 @@
<Compile Include="Graphics\SpriteBatch.cs" />
<Compile Include="Graphics\SpriteBatcher.cs" />
<Compile Include="Graphics\Texture2D.cs" />
+ <Compile Include="Graphics\Texture3D.cs" />
<Compile Include="Graphics\TextureCube.cs" />
<Compile Include="Graphics\Vertices\DynamicIndexBuffer.cs" />
<Compile Include="Graphics\Vertices\DynamicVertexBuffer.cs" />
View
1  MonoGame.Framework/MonoGame.Framework.WindowsPhone.csproj
@@ -163,6 +163,7 @@
<Compile Include="Graphics\SpriteBatch.cs" />
<Compile Include="Graphics\SpriteBatcher.cs" />
<Compile Include="Graphics\Texture2D.cs" />
+ <Compile Include="Graphics\Texture3D.cs" />
<Compile Include="Graphics\TextureCube.cs" />
<Compile Include="Graphics\Vertices\DynamicIndexBuffer.cs" />
<Compile Include="Graphics\Vertices\DynamicVertexBuffer.cs" />
View
17 MonoGame.Framework/Windows/WinFormsGameWindow.cs
@@ -39,13 +39,14 @@ 1. Definitions
#endregion License
using System;
+using System.Collections.Generic;
using System.Drawing;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Windows.Forms;
-using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Input;
+using Microsoft.Xna.Framework.Input.Touch;
using ButtonState = Microsoft.Xna.Framework.Input.ButtonState;
using Rectangle = Microsoft.Xna.Framework.Rectangle;
using XnaKey = Microsoft.Xna.Framework.Input.Keys;
@@ -142,12 +143,26 @@ private void OnDeactivate(object sender, EventArgs eventArgs)
private void OnMouseState(object sender, MouseEventArgs mouseEventArgs)
{
+ var previousState = Mouse.State.LeftButton;
+
Mouse.State.X = mouseEventArgs.X;
Mouse.State.Y = mouseEventArgs.Y;
Mouse.State.LeftButton = (mouseEventArgs.Button & MouseButtons.Left) == MouseButtons.Left ? ButtonState.Pressed : ButtonState.Released;
Mouse.State.MiddleButton = (mouseEventArgs.Button & MouseButtons.Middle) == MouseButtons.Middle ? ButtonState.Pressed : ButtonState.Released;
Mouse.State.RightButton = (mouseEventArgs.Button & MouseButtons.Right) == MouseButtons.Right ? ButtonState.Pressed : ButtonState.Released;
Mouse.State.ScrollWheelValue = mouseEventArgs.Delta;
+
+ TouchLocationState? touchState = null;
+ if (Mouse.State.LeftButton == ButtonState.Pressed)
+ if (previousState == ButtonState.Released)
+ touchState = TouchLocationState.Pressed;
+ else
+ touchState = TouchLocationState.Moved;
+ else if (previousState == ButtonState.Pressed)
+ touchState = TouchLocationState.Released;
+
+ if (touchState.HasValue)
+ TouchPanel.AddEvent(0, touchState.Value, new Vector2(Mouse.State.X, Mouse.State.Y), true);
}
private void OnKeyDown(object sender, KeyEventArgs keyEventArgs)
View
19 MonoGame.Framework/iOS/GamerServices/Guide.cs
@@ -333,10 +333,23 @@ public static Nullable<int> EndShowMessageBox (IAsyncResult result)
public static void ShowMarketplace (PlayerIndex player)
{
- AssertInitialised ();
+ AssertInitialised();
+
+ string bundleName = NSBundle.MainBundle.InfoDictionary[new NSString("CFBundleName")].ToString();
+ StringBuilder output = new StringBuilder();
+ foreach (char c in bundleName)
+ {
+ // Ampersand gets converted to "and"!!
+ if (c == '&')
+ output.Append("and");
- NSUrl url = new NSUrl("http://phobos.apple.com/WebObjects/MZStore.woa/wa/viewSoftware?id=306469222&mt=8");
- if (!UIApplication.SharedApplication.OpenUrl(url)) {
+ // All alphanumeric characters are added
+ if (char.IsLetterOrDigit(c))
+ output.Append(c);
+ }
+ NSUrl url = new NSUrl("itms-apps://itunes.com/app/" + output.ToString());
+ if (!UIApplication.SharedApplication.OpenUrl(url))
+ {
// Error
}
}
View
60 MonoGame.Framework/iOS/GamerServices/SignedInGamer.cs
@@ -298,15 +298,19 @@ public void AwardAchievement( string achievementId )
public void DoAwardAchievement( string achievementId, double percentageComplete )
{
- GKAchievement a = new GKAchievement(achievementId);
- a.PercentComplete = percentageComplete;
- a.ReportAchievement( delegate(NSError error){
- if (error != null)
- {
- // Retain the achievement object and try again later (not shown).
- }
-
- } );
+ UIApplication.SharedApplication.InvokeOnMainThread(delegate
+ {
+ GKAchievement a = new GKAchievement(achievementId);
+ a.PercentComplete = percentageComplete;
+ a.ReportAchievement(delegate(NSError error)
+ {
+ if (error != null)
+ {
+ // Retain the achievement object and try again later (not shown).
+ }
+
+ });
+ });
}
public void AwardAchievement( string achievementId, double percentageComplete )
@@ -321,15 +325,18 @@ public void UpdateScore( string aCategory, long aScore )
{
if (IsSignedInToLive)
{
- GKScore score = new GKScore(aCategory);
- score.Value = aScore;
- score.ReportScore(delegate (NSError error)
- {
- if (error != null)
- {
- // Oh oh something went wrong.
- }
- });
+ UIApplication.SharedApplication.InvokeOnMainThread(delegate
+ {
+ GKScore score = new GKScore(aCategory);
+ score.Value = aScore;
+ score.ReportScore(delegate(NSError error)
+ {
+ if (error != null)
+ {
+ // Oh oh something went wrong.
+ }
+ });
+ });
}
}
@@ -337,13 +344,16 @@ public void ResetAchievements()
{
if (IsSignedInToLive)
{
- GKAchievement.ResetAchivements(delegate (NSError error)
- {
- if (error != null)
- {
- // Oh oh something went wrong.
- }
- });
+ UIApplication.SharedApplication.InvokeOnMainThread(delegate
+ {
+ GKAchievement.ResetAchivements(delegate(NSError error)
+ {
+ if (error != null)
+ {
+ // Oh oh something went wrong.
+ }
+ });
+ });
}
}
View
7 Tools/2MGFX/DXEffectObject.cs
@@ -582,11 +582,6 @@ static public EffectParameterType ToXNAParameterType(D3DXPARAMETER_TYPE type)
{
switch (type)
{
- default:
- //throw new NotImplementedException();
-
- case DXEffectObject.D3DXPARAMETER_TYPE.VOID:
- return EffectParameterType.Void;
case DXEffectObject.D3DXPARAMETER_TYPE.BOOL:
return EffectParameterType.Bool;
case DXEffectObject.D3DXPARAMETER_TYPE.INT:
@@ -605,6 +600,8 @@ static public EffectParameterType ToXNAParameterType(D3DXPARAMETER_TYPE type)
return EffectParameterType.Texture3D;
case DXEffectObject.D3DXPARAMETER_TYPE.TEXTURECUBE:
return EffectParameterType.TextureCube;
+ default:
+ throw new NotImplementedException();
}
}
View
4 Tools/2MGFX/DXShaderData.mojo.cs
@@ -84,6 +84,10 @@ public static DXShaderData CreateGLSL (byte[] byteCode, List<DXConstantBufferDat
}
);//(a, b) => ((int)(a.info.elements > 1))a.register_index.CompareTo(b.register_index));
+ // NOTE: It seems the latest versions of MojoShader only
+ // output vec4 register sets. We leave the code below, but
+ // the runtime has been optimized for this case.
+
// For whatever reason the register indexing is
// incorrect from MojoShader.
{
Please sign in to comment.
Something went wrong with that request. Please try again.