mono/MonoGame — Issue #311: iOS - SpriceBatch.cs
Author: mwo-dk
Created: 2012-02-21 19:09:13+00:00
State: open

I had problems building the iOS Fx. Looks like improper cast between OpenTK.Matrix4 and Xna.Matrix. Just added the extension method locally:

public static class MatrixConvert
{
public static Matrix ToXnaMatrix(this Matrix4 m)
{
return new Matrix(m.M11,m.M12,m.M13,m.M14,m.M21,m.M22,m.M23,m.M24,m.M31,m.M32,m.M33,m.M34,m.M41,m.M42,m.M43,m.M44);
}
}

And then corrected the multiplications to use it:

#if ANDROID
lastDisplayOrientation = DisplayOrientation.Unknown;
UpdateWorldMatrixOrientation();
#else
lastDisplayOrientation = graphicsDevice.PresentationParameters.DisplayOrientation;
matViewScreen = (Matrix4.CreateRotationZ((float)Math.PI)*
Matrix4.CreateRotationY((float)Math.PI)*
Matrix4.CreateTranslation(-this.graphicsDevice.Viewport.Width/2,
this.graphicsDevice.Viewport.Height/2,
1)).ToXnaMatrix(); // <---
matViewFramebuffer = Matrix4.CreateTranslation(-this.graphicsDevice.Viewport.Width/2,
-this.graphicsDevice.Viewport.Height/2,
1).ToXnaMatrix(); // <--
matProjection = Matrix4.CreateOrthographic(this.graphicsDevice.Viewport.Width,
this.graphicsDevice.Viewport.Height,
-1f,1f).ToXnaMatrix(); // <---

matWVPScreen = matViewScreen * matProjection;
matWVPFramebuffer = matViewFramebuffer * matProjection;
#endif