Skip to content

Commit

Permalink
Merge.
Browse files Browse the repository at this point in the history
  • Loading branch information
Ray Batts authored and Ray Batts committed Mar 28, 2014
1 parent 0109064 commit 17e4cdf
Show file tree
Hide file tree
Showing 14 changed files with 83 additions and 35 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,12 @@
<Import file="MonoGame.Framework.Content.Pipeline.dll"/>
<Import file="MonoGame.Framework.dll"/>
<!--Import file="MonoMac.dll"/-->
<Import file="NAudio.dll"/>
<!--
This isn't available for MonoMac or Linux builds, but is
for Windows builds. So how do we fix this correctly?
<Import file="NAudio.dll"/>
-->
<Import file="Nvidia.TextureTools.dll"/>
<Import file="Nvidia.TextureTools.dll.config"/>
<Import file="SharpFont.dll"/>
Expand Down
13 changes: 12 additions & 1 deletion MonoGame.Framework/Color.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
#endregion License

using System;
using System.Text;
using System.Runtime.Serialization;

namespace Microsoft.Xna.Framework
Expand Down Expand Up @@ -1773,7 +1774,17 @@ public UInt32 PackedValue
/// <returns>The string representation of the color value of this instance.</returns>
public override string ToString ()
{
return string.Format("[Color: R={0}, G={1}, B={2}, A={3}, PackedValue={4}]", R, G, B, A, PackedValue);
StringBuilder sb = new StringBuilder(25);
sb.Append("{R:");
sb.Append(R);
sb.Append(" G:");
sb.Append(G);
sb.Append(" B:");
sb.Append(B);
sb.Append(" A:");
sb.Append(A);
sb.Append("}");
return sb.ToString();
}

/// <summary>
Expand Down
2 changes: 2 additions & 0 deletions MonoGame.Framework/Graphics/GraphicsDevice.OpenGL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,8 @@ private void ActivateShaderProgram()

internal void PlatformApplyState(bool applyShaders)
{
Threading.EnsureUIThread();

if ( _scissorRectangleDirty )
{
var scissorRect = _scissorRectangle;
Expand Down
5 changes: 4 additions & 1 deletion MonoGame.Framework/Graphics/GraphicsDevice.PSM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,9 @@ private IRenderTarget PlatformApplyRenderTargets()

internal void PlatformApplyState(bool applyShaders)
{
// TODO: This was on both the OpenGL and PSM path previously - is it necessary?
Threading.EnsureUIThread();

if ( _scissorRectangleDirty )
_scissorRectangleDirty = false;

Expand Down Expand Up @@ -125,7 +128,7 @@ internal void PlatformApplyState(bool applyShaders)
//}

Textures.SetTextures(this);
SamplerStates.SetSamplers(this);
SamplerStates.PlatformSetSamplers(this);
}

private void PlatformDrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int startIndex, int primitiveCount)
Expand Down
12 changes: 9 additions & 3 deletions MonoGame.Framework/Graphics/RenderTarget2D.OpenGL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,15 @@ private void PlatformDispose(bool disposing)
GraphicsDevice.AddDisposeAction(() =>
{
if (this.glStencilBuffer != 0 && this.glStencilBuffer != this.glDepthBuffer)
GL.DeleteRenderbuffers(1, ref this.glStencilBuffer);
GL.DeleteRenderbuffers(1, ref this.glDepthBuffer);
GraphicsExtensions.CheckGLError();
{
GL.DeleteRenderbuffers(1, ref this.glStencilBuffer);
GraphicsExtensions.CheckGLError();
}
if (this.glDepthBuffer != 0)
{
GL.DeleteRenderbuffers(1, ref this.glDepthBuffer);
GraphicsExtensions.CheckGLError();
}
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion MonoGame.Framework/Graphics/SpriteBatch.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public void End ()
Setup();
#if PSM
GraphicsDevice.BlendState = _blendState;
_blendState.ApplyState(GraphicsDevice);
_blendState.PlatformApplyState(GraphicsDevice);
#endif

_batcher.DrawBatch(_sortMode);
Expand Down
2 changes: 1 addition & 1 deletion MonoGame.Framework/Graphics/Texture2D.PSM.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

namespace Microsoft.Xna.Framework.Graphics
{
public partial class Texture2D : Texture
public partial class Texture2D
{
internal PssTexture2D _texture2D;

Expand Down
4 changes: 0 additions & 4 deletions MonoGame.Framework/Graphics/TextureCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -104,10 +104,6 @@ internal void Dirty()

internal void SetTextures(GraphicsDevice device)
{
#if !DIRECTX
Threading.EnsureUIThread();
#endif

// Skip out if nothing has changed.
if (_dirty == 0)
return;
Expand Down
3 changes: 3 additions & 0 deletions MonoGame.Framework/Media/Song.Tao.SDL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,14 @@ namespace Microsoft.Xna.Framework.Media
public sealed partial class Song : IEquatable<Song>, IDisposable
{
private IntPtr _audioData;
private int _volume = 128; // in SDL units from 0 to 128

private void PlatformInitialize(string fileName)
{
_audioData = Tao.Sdl.SdlMixer.Mix_LoadMUS(fileName);
}

internal void SetEventHandler(FinishedPlayingHandler handler) { }

internal void OnFinishedPlaying()
{
Expand Down
30 changes: 8 additions & 22 deletions MonoGame.Framework/iOS/iOSGameViewController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -138,27 +138,13 @@ public override void DidRotate (UIInterfaceOrientation fromInterfaceOrientation)
var handler = InterfaceOrientationChanged;
if (handler != null)
handler (this, EventArgs.Empty);
}

public override void TouchesBegan (NSSet touches, UIEvent evt)
{
base.TouchesBegan (touches, evt);
}

public override void TouchesEnded (NSSet touches, UIEvent evt)
{
base.TouchesEnded (touches, evt);

}

public override void TouchesMoved (NSSet touches, UIEvent evt)
{
base.TouchesMoved (touches, evt);
}
}

public override void TouchesCancelled (NSSet touches, UIEvent evt)
{
base.TouchesCancelled (touches, evt);
}
}
#region Hide statusbar for iOS 7 or newer
public override bool PrefersStatusBarHidden()
{
return _platform.Game.graphicsDeviceManager.IsFullScreen;
}
#endregion
}
}
30 changes: 30 additions & 0 deletions ProjectTemplates/VisualStudio2010/OUYA/Game1.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,12 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Ouya.Console.Api;

// There are three things that need to be done for each new OUYA project:
// 1. Insert your OUYA developer key in the Initialize method below.
// 2. Replace Resources\Raw\key.der with your application key downloaded from the OUYA dev portal.
// 3. Replace the product IDs in the call to RequestProductListAsync with your product IDs.

namespace $safeprojectname$
{
Expand All @@ -12,6 +18,7 @@ public class Game1 : Microsoft.Xna.Framework.Game
GraphicsDeviceManager graphics;
SpriteBatch spriteBatch;
SpriteFont font;
OuyaFacade facade;

public Game1()
{
Expand All @@ -34,8 +41,13 @@ public Game1()
protected override void Initialize()
{
// TODO: Add your initialization logic here
facade = OuyaFacade.Instance;
facade.Init(Activity, "insert your developer key here");

base.Initialize();

// Start the IAP test as an async task so it runs in the background.
DoIapTest();
}

/// <summary>
Expand Down Expand Up @@ -82,5 +94,23 @@ protected override void Draw(GameTime gameTime)

base.Draw (gameTime);
}

async void DoIapTest()
{
// Retrieve the receipts to see what items the user has previously purchased.
var receipts = await facade.RequestReceiptsAsync();
// Retrieve the known products from the OUYA Store.
var products = await facade.RequestProductListAsync("__TEST__01", "__TEST__02");
// Make a purchase of the first product in the list.
// NOTE: This would usually be initiated by a user action such as a button press.
var purchaseResult = await facade.RequestPurchaseAsync(products[0]);
// If the purchase was successful...
if (purchaseResult)
{
// ...retrieve the receipts again from the OUYA Store.
// This will include the new purchase.
receipts = await facade.RequestReceiptsAsync();
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<VSTemplate Version="3.0.0" xmlns="http://schemas.microsoft.com/developer/vstemplate/2005" Type="Project">
<TemplateData>
<Name>MonoGame OUYA Project</Name>
<Description>A MonoGame game project for OUYA which requires "Mono for Android" by Xamarin.</Description>
<Description>A MonoGame game project for OUYA using Xamarin.Android 4.8.2 or greater.</Description>
<ProjectType>CSharp</ProjectType>
<ProjectSubType>
</ProjectSubType>
Expand Down Expand Up @@ -37,6 +37,9 @@
<ProjectItem ReplaceParameters="false" TargetFileName="ouya_icon.png">ouya_icon.png</ProjectItem>
</Folder>
<Folder Name="Layout" TargetFolderName="Layout" />
<Folder Name="Raw" TargetFolderName="Raw">
<ProjectItem ReplaceParameters="false" TargetFileName="key.der">key.der</ProjectItem>
</Folder>
<ProjectItem ReplaceParameters="true" TargetFileName="Resource.Designer.cs">Resource.Designer.cs</ProjectItem>
<Folder Name="Values" TargetFolderName="Values">
<ProjectItem ReplaceParameters="true" TargetFileName="Strings.xml">Strings.xml</ProjectItem>
Expand Down
3 changes: 3 additions & 0 deletions ProjectTemplates/VisualStudio2010/OUYA/OuyaGame1.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@
<ItemGroup>
<AndroidResource Include="Resources\Values\Styles.xml" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\Raw\key.der" />
</ItemGroup>
<ItemGroup>
<AndroidResource Include="Resources\Drawable-xhdpi\ouya_icon.png" />
</ItemGroup>
Expand Down
Binary file not shown.

0 comments on commit 17e4cdf

Please sign in to comment.