Browse files

First pass at a new Windows DirectX platform.

  • Loading branch information...
1 parent 2af9a73 commit 4886ffd4401d639b211ab5d12bb47e11d2dfc596 @tomspilman tomspilman committed Dec 9, 2012
Showing with 695 additions and 253 deletions.
  1. +20 −0 MonoGame.Framework.Windows.sln
  2. +39 −27 MonoGame.Framework/Audio/SoundEffect.cs
  3. +62 −62 MonoGame.Framework/Audio/SoundEffectInstance.cs
  4. +1 −1 MonoGame.Framework/Content/ContentManager.cs
  5. +1 −1 MonoGame.Framework/Content/ContentReaders/SoundEffectReader.cs
  6. +1 −1 MonoGame.Framework/Game.cs
  7. +3 −1 MonoGame.Framework/GamePlatform.cs
  8. +0 −13 MonoGame.Framework/Graphics/Effect/AlphaTestEffect.cs
  9. +2 −15 MonoGame.Framework/Graphics/Effect/EffectPass.cs
  10. +0 −16 MonoGame.Framework/Graphics/Effect/SpriteEffect.cs
  11. +2 −2 MonoGame.Framework/Graphics/GraphicsAdapter.cs
  12. +31 −24 MonoGame.Framework/Graphics/GraphicsDevice.cs
  13. +4 −3 MonoGame.Framework/Graphics/GraphicsExtensions.cs
  14. +2 −0 MonoGame.Framework/Graphics/OcclusionQuery.cs
  15. +2 −0 MonoGame.Framework/Graphics/RenderTarget2D.cs
  16. +2 −0 MonoGame.Framework/Graphics/SamplerStateCollection.cs
  17. +2 −0 MonoGame.Framework/Graphics/Shader/ConstantBuffer.cs
  18. +1 −1 MonoGame.Framework/Graphics/Shader/ConstantBufferCollection.cs
  19. +10 −8 MonoGame.Framework/Graphics/Shader/Shader.cs
  20. +4 −2 MonoGame.Framework/Graphics/States/BlendState.cs
  21. +4 −2 MonoGame.Framework/Graphics/States/DepthStencilState.cs
  22. +4 −2 MonoGame.Framework/Graphics/States/RasterizerState.cs
  23. +2 −2 MonoGame.Framework/Graphics/States/SamplerState.cs
  24. +2 −3 MonoGame.Framework/Graphics/Texture.cs
  25. +4 −3 MonoGame.Framework/Graphics/Texture2D.cs
  26. +18 −3 MonoGame.Framework/Graphics/Texture3D.cs
  27. +3 −1 MonoGame.Framework/Graphics/TextureCollection.cs
  28. +16 −16 MonoGame.Framework/Graphics/TextureCube.cs
  29. +5 −3 MonoGame.Framework/Graphics/Vertices/IndexBuffer.cs
  30. +4 −3 MonoGame.Framework/Graphics/Vertices/VertexBuffer.cs
  31. +4 −2 MonoGame.Framework/Graphics/Vertices/VertexDeclaration.cs
  32. +11 −8 MonoGame.Framework/Input/Mouse.cs
  33. +22 −13 MonoGame.Framework/Media/MediaPlayer.cs
  34. +3 −3 MonoGame.Framework/Media/MediaQueue.cs
  35. +10 −10 MonoGame.Framework/Media/Song.cs
  36. +383 −0 MonoGame.Framework/MonoGame.Framework.Windows.csproj
  37. +4 −2 MonoGame.Framework/Windows/GamerServices/Guide.cs
  38. +7 −0 MonoGame.Framework/Windows8/SharpDXHelper.cs
View
20 MonoGame.Framework.Windows.sln
@@ -0,0 +1,20 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio 2012
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MonoGame.Framework.Windows", "MonoGame.Framework\MonoGame.Framework.Windows.csproj", "{7DE47032-A904-4C29-BD22-2D235E8D91BA}"
+EndProject
+Global
+ GlobalSection(SolutionConfigurationPlatforms) = preSolution
+ Debug|Any CPU = Debug|Any CPU
+ Release|Any CPU = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(ProjectConfigurationPlatforms) = postSolution
+ {7DE47032-A904-4C29-BD22-2D235E8D91BA}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {7DE47032-A904-4C29-BD22-2D235E8D91BA}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {7DE47032-A904-4C29-BD22-2D235E8D91BA}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {7DE47032-A904-4C29-BD22-2D235E8D91BA}.Release|Any CPU.Build.0 = Release|Any CPU
+ EndGlobalSection
+ GlobalSection(SolutionProperties) = preSolution
+ HideSolutionNode = FALSE
+ EndGlobalSection
+EndGlobal
View
66 MonoGame.Framework/Audio/SoundEffect.cs
@@ -46,7 +46,7 @@ 1. Definitions
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
-#if WINRT
+#if DIRECTX
using SharpDX;
using SharpDX.XAudio2;
using SharpDX.Multimedia;
@@ -57,7 +57,7 @@ namespace Microsoft.Xna.Framework.Audio
{
public sealed class SoundEffect : IDisposable
{
-#if WINRT
+#if DIRECTX
internal DataStream _dataStream;
internal AudioBuffer _buffer;
internal AudioBuffer _loopedBuffer;
@@ -69,17 +69,17 @@ public sealed class SoundEffect : IDisposable
private List<SoundEffectInstance> _availableInstances;
private List<SoundEffectInstance> _toBeRecycledInstances;
#else
- private Sound _sound;
+ private Sound _sound;
private SoundEffectInstance _instance;
#endif
private string _name;
-#if !WINRT
- private string _filename = "";
+#if !DIRECTX
+ private string _filename = "";
private byte[] _data;
#endif
-#if WINRT
+#if DIRECTX
internal SoundEffect()
{
}
@@ -107,11 +107,11 @@ internal SoundEffect(string name, byte[] data)
#endif
public SoundEffect(byte[] buffer, int sampleRate, AudioChannels channels)
- {
-#if WINRT
+ {
+#if DIRECTX
Initialize(new WaveFormat(sampleRate, (int)channels), buffer, 0, buffer.Length, 0, buffer.Length);
#else
- //buffer should contain 16-bit PCM wave data
+ //buffer should contain 16-bit PCM wave data
short bitsPerSample = 16;
_name = "";
@@ -146,15 +146,15 @@ public SoundEffect(byte[] buffer, int sampleRate, AudioChannels channels)
}
public SoundEffect(byte[] buffer, int offset, int count, int sampleRate, AudioChannels channels, int loopStart, int loopLength)
- {
-#if WINRT
+ {
+#if DIRECTX
Initialize(new WaveFormat(sampleRate, (int)channels), buffer, offset, count, loopStart, loopLength);
#else
throw new NotImplementedException();
#endif
}
-#if WINRT
+#if DIRECTX
// Extended constructor which supports custom formats / compression.
internal SoundEffect(WaveFormat format, byte[] buffer, int offset, int count, int loopStart, int loopLength)
@@ -192,15 +192,15 @@ private void Initialize(WaveFormat format, byte[] buffer, int offset, int count,
};
}
#endif
-
+
public bool Play()
{
return Play(1.0f, 0.0f, 0.0f);
}
public bool Play(float volume, float pitch, float pan)
{
-#if WINRT
+#if DIRECTX
if (MasterVolume > 0.0f)
{
if (_playingInstances == null)
@@ -256,7 +256,7 @@ public bool Play(float volume, float pitch, float pan)
// has been reached. However, there is no limit on PC.
return true;
#else
- if ( MasterVolume > 0.0f )
+ if ( MasterVolume > 0.0f )
{
if(_instance == null)
_instance = CreateInstance();
@@ -273,14 +273,14 @@ public bool Play(float volume, float pitch, float pan)
public TimeSpan Duration
{
get
- {
-#if WINRT
+ {
+#if DIRECTX
var sampleCount = _buffer.PlayLength;
var avgBPS = _format.AverageBytesPerSecond;
return TimeSpan.FromSeconds((float)sampleCount / (float)avgBPS);
#else
- if ( _sound != null )
+ if ( _sound != null )
{
return new TimeSpan(0,0,(int)_sound.Duration);
}
@@ -305,8 +305,8 @@ public string Name
}
public SoundEffectInstance CreateInstance()
- {
-#if WINRT
+ {
+#if DIRECTX
SourceVoice voice = null;
if (Device != null)
voice = new SourceVoice(Device, _format, VoiceFlags.None, XAudio2.MaximumFrequencyRatio);
@@ -323,10 +323,10 @@ public SoundEffectInstance CreateInstance()
public void Dispose()
{
-#if WINRT
+#if DIRECTX
_dataStream.Dispose();
#else
- _sound.Dispose();
+ _sound.Dispose();
#endif
}
@@ -345,10 +345,10 @@ public static float MasterVolume
if ( _masterVolume != value )
_masterVolume = value;
-#if WINRT
+#if DIRECTX
MasterVoice.SetVolume(_masterVolume, 0);
#endif
- }
+ }
}
static float _distanceScale = 1f;
@@ -393,7 +393,7 @@ public static float MasterVolume
}
}
-#if WINRT
+#if DIRECTX
internal static XAudio2 Device { get; private set; }
internal static MasteringVoice MasterVoice { get; private set; }
@@ -436,19 +436,31 @@ internal static X3DAudio Device3D
static SoundEffect()
{
+ var flags = XAudio2Flags.None;
+#if DEBUG
+ flags |= XAudio2Flags.DebugEngine;
+#endif
// This cannot fail.
- Device = new XAudio2();
+ Device = new XAudio2(flags, ProcessorSpecifier.DefaultProcessor);
try
{
Device.StartEngine();
+ // Just use the default device.
+ const int deviceIndex = 0;
+
// Let windows autodetect number of channels and sample rate.
- MasterVoice = new MasteringVoice(Device, XAudio2.DefaultChannels, XAudio2.DefaultSampleRate);
+ MasterVoice = new MasteringVoice(Device, XAudio2.DefaultChannels, XAudio2.DefaultSampleRate, deviceIndex);
MasterVoice.SetVolume(_masterVolume, 0);
// The autodetected value of MasterVoice.ChannelMask corresponds to the speaker layout.
+#if WINRT
Speakers = (Speakers)MasterVoice.ChannelMask;
+#else
+ var deviceDetails = Device.GetDeviceDetails(deviceIndex);
+ Speakers = deviceDetails.OutputFormat.ChannelMask;
+#endif
}
catch
{
View
124 MonoGame.Framework/Audio/SoundEffectInstance.cs
@@ -40,7 +40,7 @@
#region Using Statements
using System;
-#if WINRT
+#if DIRECTX
using SharpDX.XAudio2;
using SharpDX.X3DAudio;
using SharpDX.Multimedia;
@@ -52,14 +52,14 @@ namespace Microsoft.Xna.Framework.Audio
public sealed class SoundEffectInstance : IDisposable
{
private bool isDisposed = false;
-#if !WINRT
- private SoundState soundState = SoundState.Stopped;
+#if !DIRECTX
+ private SoundState soundState = SoundState.Stopped;
#endif
#if ANDROID
private int _streamId = -1;
#endif
-#if WINRT
+#if DIRECTX
private SourceVoice _voice { get; set; }
private SoundEffect _effect { get; set; }
@@ -81,17 +81,17 @@ internal Sound Sound
}
#endif
-#if WINRT
+#if DIRECTX
internal SoundEffectInstance(SoundEffect effect, SourceVoice voice)
{
_effect = effect;
_voice = voice;
}
#endif
- public void Dispose()
- {
-#if WINRT
+ public void Dispose()
+ {
+#if DIRECTX
if (_voice != null)
{
_voice.DestroyVoice();
@@ -111,8 +111,8 @@ public void Dispose()
}
public void Apply3D (AudioListener listener, AudioEmitter emitter)
- {
-#if WINRT
+ {
+#if DIRECTX
// If we have no voice then nothing to do.
if (_voice == null)
return;
@@ -142,7 +142,7 @@ public void Apply3D (AudioListener listener, AudioEmitter emitter)
// Apply Pitch settings (from doppler) ...
_voice.SetFrequencyRatio(dpsSettings.DopplerFactor);
#endif
- }
+ }
public void Apply3D (AudioListener[] listeners,AudioEmitter emitter)
{
@@ -151,8 +151,8 @@ public void Apply3D (AudioListener[] listeners,AudioEmitter emitter)
}
public void Pause ()
- {
-#if WINRT
+ {
+#if DIRECTX
if (_voice != null)
_voice.Stop();
_paused = true;
@@ -170,8 +170,8 @@ public void Pause ()
}
public void Play ()
- {
-#if WINRT
+ {
+#if DIRECTX
if (_voice != null)
{
// Choose the correct buffer depending on if we are looped.
@@ -189,7 +189,7 @@ public void Play ()
_paused = false;
#else
- if ( _sound != null )
+ if ( _sound != null )
{
#if ANDROID
if (soundState == SoundState.Paused)
@@ -208,13 +208,13 @@ public void Play ()
}
public void Resume()
- {
-#if WINRT
+ {
+#if DIRECTX
if (_voice != null)
_voice.Start();
_paused = false;
#else
- if ( _sound != null )
+ if ( _sound != null )
{
if (soundState == SoundState.Paused)
{
@@ -230,8 +230,8 @@ public void Resume()
}
public void Stop()
- {
-#if WINRT
+ {
+#if DIRECTX
if (_voice != null)
{
_voice.Stop(0);
@@ -240,7 +240,7 @@ public void Stop()
_paused = false;
#else
- if ( _sound != null )
+ if ( _sound != null )
{
#if ANDROID
_sound.Stop(_streamId);
@@ -255,13 +255,13 @@ public void Stop()
public void Stop(bool immediate)
{
-#if WINRT
+#if DIRECTX
if (_voice != null)
_voice.Stop(immediate ? 0 : (int)PlayFlags.Tails);
_paused = false;
#else
- if ( _sound != null )
+ if ( _sound != null )
{
#if ANDROID
_sound.Stop(_streamId);
@@ -285,11 +285,11 @@ public bool IsDisposed
public bool IsLooped
{
get
- {
-#if WINRT
+ {
+#if DIRECTX
return _loop;
#else
- if ( _sound != null )
+ if ( _sound != null )
{
return _sound.Looping;
}
@@ -301,11 +301,11 @@ public bool IsLooped
}
set
- {
-#if WINRT
+ {
+#if DIRECTX
_loop = value;
#else
- if ( _sound != null )
+ if ( _sound != null )
{
if ( _sound.Looping != value )
{
@@ -315,17 +315,17 @@ public bool IsLooped
#endif
}
}
-
-#if WINRT
+
+#if DIRECTX
private float _pan;
private static float[] _panMatrix;
#endif
- public float Pan
+ public float Pan
{
get
- {
-#if WINRT
+ {
+#if DIRECTX
return _pan;
#else
if ( _sound != null )
@@ -340,8 +340,8 @@ public float Pan
}
set
- {
-#if WINRT
+ {
+#if DIRECTX
// According to XNA documentation:
// "Panning, ranging from -1.0f (full left) to 1.0f (full right). 0.0f is centered."
_pan = MathHelper.Clamp(value, -1.0f, 1.0f);
@@ -390,38 +390,38 @@ public float Pan
var lVal = 1.0f - _pan;
var rVal = 1.0f + _pan;
- switch (SoundEffect.MasterVoice.ChannelMask)
+ switch (SoundEffect.Speakers)
{
- case ((int)Speakers.Stereo):
- case ((int)Speakers.TwoPointOne):
- case ((int)Speakers.Surround):
+ case Speakers.Stereo:
+ case Speakers.TwoPointOne:
+ case Speakers.Surround:
_panMatrix[0] = lVal;
_panMatrix[1] = rVal;
break;
- case ((int)Speakers.Quad):
+ case Speakers.Quad:
_panMatrix[0] = _panMatrix[2] = lVal;
_panMatrix[1] = _panMatrix[3] = rVal;
break;
- case ((int)Speakers.FourPointOne):
+ case Speakers.FourPointOne:
_panMatrix[0] = _panMatrix[3] = lVal;
_panMatrix[1] = _panMatrix[4] = rVal;
break;
- case ((int)Speakers.FivePointOne):
- case ((int)Speakers.SevenPointOne):
- case ((int)Speakers.FivePointOneSurround):
+ case Speakers.FivePointOne:
+ case Speakers.SevenPointOne:
+ case Speakers.FivePointOneSurround:
_panMatrix[0] = _panMatrix[4] = lVal;
_panMatrix[1] = _panMatrix[5] = rVal;
break;
- case ((int)Speakers.SevenPointOneSurround):
+ case Speakers.SevenPointOneSurround:
_panMatrix[0] = _panMatrix[4] = _panMatrix[6] = lVal;
_panMatrix[1] = _panMatrix[5] = _panMatrix[7] = rVal;
break;
- case ((int)Speakers.Mono):
+ case Speakers.Mono:
default:
// don't do any panning here
break;
@@ -444,8 +444,8 @@ public float Pan
public float Pitch
{
get
- {
-#if WINRT
+ {
+#if DIRECTX
if (_voice == null)
return 0.0f;
@@ -458,16 +458,16 @@ public float Pitch
return (float)pitch;
#else
- if ( _sound != null)
+ if ( _sound != null)
{
return _sound.Rate;
}
return 0.0f;
#endif
}
set
- {
-#if WINRT
+ {
+#if DIRECTX
if (_voice == null)
return;
@@ -476,7 +476,7 @@ public float Pitch
var ratio = Math.Pow(2.0, value);
_voice.SetFrequencyRatio((float)ratio);
#else
- if ( _sound != null && _sound.Rate != value)
+ if ( _sound != null && _sound.Rate != value)
{
_sound.Rate = value;
}
@@ -487,8 +487,8 @@ public float Pitch
public SoundState State
{
get
- {
-#if WINRT
+ {
+#if DIRECTX
// If no voice or no buffers queued the sound is stopped.
if (_voice == null || _voice.State.BuffersQueued == 0)
return SoundState.Stopped;
@@ -526,14 +526,14 @@ public SoundState State
public float Volume
{
get
- {
-#if WINRT
+ {
+#if DIRECTX
if (_voice == null)
return 0.0f;
else
return _voice.Volume;
#else
- if (_sound != null)
+ if (_sound != null)
{
return _sound.Volume;
}
@@ -545,12 +545,12 @@ public float Volume
}
set
- {
-#if WINRT
+ {
+#if DIRECTX
if (_voice != null)
_voice.SetVolume(value, XAudio2.CommitNow);
#else
- if ( _sound != null )
+ if ( _sound != null )
{
if ( _sound.Volume != value )
{
View
2 MonoGame.Framework/Content/ContentManager.cs
@@ -381,7 +381,7 @@ protected virtual object ReadRawAsset<T>(string assetName, string originalAssetN
//result = new SpriteFont(Texture2D.FromFile(graphicsDeviceService.GraphicsDevice,assetName), null, null, null, 0, 0.0f, null, null);
throw new NotImplementedException();
}
-#if !WINRT
+#if !DIRECTX
else if ((typeof(T) == typeof(Song)))
{
return new Song(assetName);
View
2 MonoGame.Framework/Content/ContentReaders/SoundEffectReader.cs
@@ -92,7 +92,7 @@ protected internal override SoundEffect Read(ContentReader input, SoundEffect ex
int loopLength = input.ReadInt32();
int num = input.ReadInt32();
-#if WINRT
+#if DIRECTX
var count = data.Length;
var format = (int)BitConverter.ToUInt16(header, 0);
var sampleRate = (int)BitConverter.ToUInt16(header, 4);
View
2 MonoGame.Framework/Game.cs
@@ -697,7 +697,7 @@ internal void DoExiting()
internal void ResizeWindow(bool changed)
{
-#if LINUX || WINDOWS
+#if LINUX || (WINDOWS && OPENGL)
((OpenTKGamePlatform)Platform).ResetWindowBounds(changed);
#endif
}
View
4 MonoGame.Framework/GamePlatform.cs
@@ -92,12 +92,14 @@ public static GamePlatform Create(Game game)
return new iOSGamePlatform(game);
#elif MONOMAC
return new MacGamePlatform(game);
-#elif WINDOWS || LINUX
+#elif (WINDOWS && OPENGL) || LINUX
return new OpenTKGamePlatform(game);
#elif ANDROID
return new AndroidGamePlatform(game);
#elif PSM
return new PSSGamePlatform(game);
+#elif WINDOWS && DIRECTX
+ return null; // TODO!
#elif WINDOWS_PHONE
return new MonoGame.Framework.WindowsPhone.WindowsPhoneGamePlatform(game);
#elif WINRT
View
13 MonoGame.Framework/Graphics/Effect/AlphaTestEffect.cs
@@ -11,19 +11,6 @@
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using System;
-
-
-#if IPHONE || ANDROID
-using OpenTK.Graphics.ES20;
-using ActiveUniformType = OpenTK.Graphics.ES20.All;
-#elif MONOMAC
-using MonoMac.OpenGL;
-#elif PSM
-using Sce.PlayStation.Core;
-#elif !WINRT
-using OpenTK.Graphics.OpenGL;
-
-#endif
#endregion
namespace Microsoft.Xna.Framework.Graphics
View
17 MonoGame.Framework/Graphics/Effect/EffectPass.cs
@@ -4,24 +4,11 @@
using System.Text;
using System.Diagnostics;
-#if MONOMAC
-using MonoMac.OpenGL;
-#elif WINDOWS || LINUX
-using OpenTK.Graphics.OpenGL;
-#elif PSM
+#if PSM
using Sce.PlayStation.Core.Graphics;
-#elif WINRT
-
-#else
-using OpenTK.Graphics.ES20;
-
-#if IPHONE || ANDROID
-using ActiveUniformType = OpenTK.Graphics.ES20.All;
-using ShaderType = OpenTK.Graphics.ES20.All;
-using ProgramParameter = OpenTK.Graphics.ES20.All;
-#endif
#endif
+
namespace Microsoft.Xna.Framework.Graphics
{
public class EffectPass
View
16 MonoGame.Framework/Graphics/Effect/SpriteEffect.cs
@@ -10,23 +10,7 @@
#region Using Statements
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
-
-
-
-
using System;
-
-#if ANDROID || IPHONE
-using OpenTK.Graphics.ES20;
-using ActiveUniformType = OpenTK.Graphics.ES20.All;
-#elif MONOMAC
-using MonoMac.OpenGL;
-#elif PSM
-using Sce.PlayStation.Core.Graphics;
-#elif !WINRT
-using OpenTK.Graphics.OpenGL;
-#endif
-
#endregion
namespace Microsoft.Xna.Framework.Graphics
View
4 MonoGame.Framework/Graphics/GraphicsAdapter.cs
@@ -106,7 +106,7 @@ public DisplayMode CurrentDisplayMode
SurfaceFormat.Color);
#elif ANDROID
return new DisplayMode(_view.Width, _view.Height, 60, SurfaceFormat.Color);
-#elif WINDOWS || LINUX
+#elif (WINDOWS && OPENGL) || LINUX
return new DisplayMode(OpenTK.DisplayDevice.Default.Width, OpenTK.DisplayDevice.Default.Height, (int)OpenTK.DisplayDevice.Default.RefreshRate, SurfaceFormat.Color);
#else
@@ -254,7 +254,7 @@ public DisplayModeCollection SupportedDisplayModes
if (supportedDisplayModes == null)
{
List<DisplayMode> modes = new List<DisplayMode>(new DisplayMode[] { CurrentDisplayMode, });
-#if WINDOWS || LINUX
+#if (WINDOWS && OPENGL) || LINUX
IList<OpenTK.DisplayDevice> displays = OpenTK.DisplayDevice.AvailableDisplays;
if (displays.Count > 0)
{
View
55 MonoGame.Framework/Graphics/GraphicsDevice.cs
@@ -46,26 +46,11 @@ 1. Definitions
using Microsoft.Xna.Framework.Input.Touch;
using System.Diagnostics;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif WINRT
-using SharpDX;
-using SharpDX.Direct3D;
-#if WINDOWS_PHONE
-using SharpDX.Direct3D11;
-using Windows.Foundation;
-using MonoGame.Framework.WindowsPhone;
-#else
-using Windows.UI.Xaml.Controls;
-using Windows.Graphics.Display;
-using Windows.UI.Core;
-using SharpDX.DXGI;
-#endif
-#elif PSM
-using Sce.PlayStation.Core.Graphics;
-using PssVertexBuffer = Sce.PlayStation.Core.Graphics.VertexBuffer;
#elif GLES
using OpenTK.Graphics.ES20;
using BeginMode = OpenTK.Graphics.ES20.All;
@@ -81,6 +66,24 @@ 1. Definitions
using RenderbufferTarget = OpenTK.Graphics.ES20.All;
using RenderbufferStorage = OpenTK.Graphics.ES20.All;
#endif
+#elif DIRECTX
+using SharpDX;
+using SharpDX.Direct3D;
+#if WINDOWS_PHONE
+using SharpDX.Direct3D11;
+using Windows.Foundation;
+using MonoGame.Framework.WindowsPhone;
+#elif WINDOWS_STOREAPP
+using Windows.UI.Xaml.Controls;
+using Windows.Graphics.Display;
+using Windows.UI.Core;
+using SharpDX.DXGI;
+#elif WINDOWS
+#endif
+#elif PSM
+using Sce.PlayStation.Core.Graphics;
+using PssVertexBuffer = Sce.PlayStation.Core.Graphics.VertexBuffer;
+#endif
namespace Microsoft.Xna.Framework.Graphics
@@ -147,7 +150,7 @@ public class GraphicsDevice : IDisposable
protected SharpDX.Direct3D11.RenderTargetView _renderTargetView;
protected SharpDX.Direct3D11.DepthStencilView _depthStencilView;
-#if !WINDOWS_PHONE
+#if WINDOWS_STOREAPP
// Declare Direct2D Objects
protected SharpDX.Direct2D1.Factory1 _d2dFactory;
@@ -239,7 +242,7 @@ public class GraphicsDevice : IDisposable
internal int MaxTextureSlots;
-#if DIRECTX && !WINDOWS_PHONE
+#if WINDOWS_STOREAPP
internal float Dpi
{
@@ -257,7 +260,7 @@ internal float Dpi
}
}
-#endif // DIRECTX
+#endif
#if OPENGL
@@ -379,13 +382,15 @@ internal void Initialize()
DrawingSurfaceState.Context = null;
DrawingSurfaceState.RenderTargetView = null;
-#else
+#elif WINDOWS_STOREAPP
CreateDeviceIndependentResources();
CreateDeviceResources();
Dpi = DisplayProperties.LogicalDpi;
CreateSizeDependentResources();
+#elif WINDOWS
+
#endif
#elif PSM
@@ -499,7 +504,7 @@ internal void UpdateTarget(RenderTargetView renderTargetView)
}
}
-#else
+#elif WINDOWS_STOREAPP
/// <summary>
/// Creates resources not tied the active graphics device.
@@ -1000,7 +1005,8 @@ protected virtual void Dispose(bool disposing)
_d3dContext = null;
}
-#if !WINDOWS_PHONE
+#if WINDOWS_STOREAPP
+
if (_swapChain != null)
{
_swapChain.Dispose();
@@ -1037,7 +1043,8 @@ protected virtual void Dispose(bool disposing)
_wicFactory.Dispose();
_wicFactory = null;
}
-#endif
+
+#endif // WINDOWS_STOREAPP
#endif // DIRECTX
@@ -1085,7 +1092,7 @@ static internal void AddDisposeAction(Action disposeAction)
public void Present()
{
-#if DIRECTX && !WINDOWS_PHONE
+#if WINDOWS_STOREAPP
// The application may optionally specify "dirty" or "scroll" rects to improve efficiency
// in certain scenarios. In this sample, however, we do not utilize those features.
var parameters = new SharpDX.DXGI.PresentParameters();
View
7 MonoGame.Framework/Graphics/GraphicsExtensions.cs
@@ -3,11 +3,11 @@
using System.Linq;
using System.Text;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif WINRT
#elif GLES
using OpenTK.Graphics.ES20;
using BlendEquationMode = OpenTK.Graphics.ES20.All;
@@ -24,12 +24,13 @@
using GetPName = OpenTK.Graphics.ES20.All;
using System.Diagnostics;
#endif
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
public static class GraphicsExtensions
{
-#if !WINRT && !PSM
+#if OPENGL
public static All OpenGL11(CullMode cull)
{
switch (cull)
@@ -528,7 +529,7 @@ public static BlendingFactorDest GetBlendFactorDest (this Blend blend)
}
}
-#endif
+#endif // OPENGL
public static int Size(this SurfaceFormat surfaceFormat)
{
View
2 MonoGame.Framework/Graphics/OcclusionQuery.cs
@@ -2,11 +2,13 @@
using System.Runtime.InteropServices;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
#endif
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
2 MonoGame.Framework/Graphics/RenderTarget2D.cs
@@ -40,6 +40,7 @@
using System;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
@@ -49,6 +50,7 @@
using RenderbufferTarget = OpenTK.Graphics.ES20.All;
using RenderbufferStorage = OpenTK.Graphics.ES20.All;
#endif
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
2 MonoGame.Framework/Graphics/SamplerStateCollection.cs
@@ -44,6 +44,7 @@
using System;
using System.Collections.Generic;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
@@ -53,6 +54,7 @@
using TextureUnit = OpenTK.Graphics.ES20.All;
using TextureTarget = OpenTK.Graphics.ES20.All;
#endif
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
2 MonoGame.Framework/Graphics/Shader/ConstantBuffer.cs
@@ -5,12 +5,14 @@
using System.Text;
using System.Threading.Tasks;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
#elif GLES
using OpenTK.Graphics.ES20;
+#endif
#elif PSM
using Sce.PlayStation.Core.Graphics;
#endif
View
2 MonoGame.Framework/Graphics/Shader/ConstantBufferCollection.cs
@@ -2,7 +2,7 @@
#if MONOMAC
using MonoMac.OpenGL;
-#elif WINDOWS || LINUX
+#elif (WINDOWS && !DIRECTX) || LINUX
using OpenTK.Graphics.OpenGL;
#elif PSM
using Sce.PlayStation.Core.Graphics;
View
18 MonoGame.Framework/Graphics/Shader/Shader.cs
@@ -2,11 +2,20 @@
using System.Runtime.InteropServices;
using System.IO;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif WINRT
+#elif GLES
+using System.Text;
+using OpenTK.Graphics.ES20;
+using ShaderType = OpenTK.Graphics.ES20.All;
+using ShaderParameter = OpenTK.Graphics.ES20.All;
+using TextureUnit = OpenTK.Graphics.ES20.All;
+using TextureTarget = OpenTK.Graphics.ES20.All;
+#endif
+#elif DIRECTX
using SharpDX;
using SharpDX.Direct3D;
using SharpDX.Direct3D11;
@@ -17,13 +26,6 @@ enum ShaderType //FIXME: Major Hack
VertexShader,
FragmentShader
}
-#elif GLES
-using System.Text;
-using OpenTK.Graphics.ES20;
-using ShaderType = OpenTK.Graphics.ES20.All;
-using ShaderParameter = OpenTK.Graphics.ES20.All;
-using TextureUnit = OpenTK.Graphics.ES20.All;
-using TextureTarget = OpenTK.Graphics.ES20.All;
#endif
namespace Microsoft.Xna.Framework.Graphics
View
6 MonoGame.Framework/Graphics/States/BlendState.cs
@@ -41,19 +41,21 @@
using System;
using System.Diagnostics;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif PSM
-using Sce.PlayStation.Core.Graphics;
#elif GLES
using OpenTK.Graphics.ES20;
using EnableCap = OpenTK.Graphics.ES20.All;
using BlendEquationMode = OpenTK.Graphics.ES20.All;
using BlendingFactorSrc = OpenTK.Graphics.ES20.All;
using BlendingFactorDest = OpenTK.Graphics.ES20.All;
#endif
+#elif PSM
+using Sce.PlayStation.Core.Graphics;
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
6 MonoGame.Framework/Graphics/States/DepthStencilState.cs
@@ -1,21 +1,23 @@
using System;
using System.Diagnostics;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
using GLStencilFunction = MonoMac.OpenGL.StencilFunction;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
using GLStencilFunction = OpenTK.Graphics.OpenGL.StencilFunction;
-#elif PSM
-using Sce.PlayStation.Core.Graphics;
#elif GLES
using OpenTK.Graphics.ES20;
using EnableCap = OpenTK.Graphics.ES20.All;
using GLStencilFunction = OpenTK.Graphics.ES20.All;
using StencilOp = OpenTK.Graphics.ES20.All;
using DepthFunction = OpenTK.Graphics.ES20.All;
#endif
+#elif PSM
+using Sce.PlayStation.Core.Graphics;
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
6 MonoGame.Framework/Graphics/States/RasterizerState.cs
@@ -1,18 +1,20 @@
using System;
using System.Diagnostics;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif PSM
-using Sce.PlayStation.Core.Graphics;
#elif GLES
using OpenTK.Graphics.ES20;
using EnableCap = OpenTK.Graphics.ES20.All;
using FrontFaceDirection = OpenTK.Graphics.ES20.All;
using CullFaceMode = OpenTK.Graphics.ES20.All;
#endif
+#elif PSM
+using Sce.PlayStation.Core.Graphics;
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
4 MonoGame.Framework/Graphics/States/SamplerState.cs
@@ -41,18 +41,18 @@
using System;
using System.Diagnostics;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif WINRT
-// TODO
#elif GLES
using OpenTK.Graphics.ES20;
using TextureTarget = OpenTK.Graphics.ES20.All;
using TextureMinFilter = OpenTK.Graphics.ES20.All;
using TextureParameterName = OpenTK.Graphics.ES20.All;
#endif
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
5 MonoGame.Framework/Graphics/Texture.cs
@@ -41,18 +41,17 @@
using System;
using System.Diagnostics;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif WINRT
-// TODO
#elif GLES
using OpenTK.Graphics.ES20;
using TextureTarget = OpenTK.Graphics.ES20.All;
using TextureUnit = OpenTK.Graphics.ES20.All;
#endif
-
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
7 MonoGame.Framework/Graphics/Texture2D.cs
@@ -55,15 +55,14 @@ 1. Definitions
using MonoTouch.Foundation;
#endif
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
using GLPixelFormat = MonoMac.OpenGL.PixelFormat;
#elif WINDOWS || LINUX
using System.Drawing.Imaging;
using OpenTK.Graphics.OpenGL;
using GLPixelFormat = OpenTK.Graphics.OpenGL.PixelFormat;
-#elif PSM
-using PssTexture2D = Sce.PlayStation.Core.Graphics.Texture2D;
#elif GLES
using OpenTK.Graphics.ES20;
using GLPixelFormat = OpenTK.Graphics.ES20.All;
@@ -74,7 +73,9 @@ 1. Definitions
using PixelType = OpenTK.Graphics.ES20.All;
using PixelStoreParameter = OpenTK.Graphics.ES20.All;
using ErrorCode = OpenTK.Graphics.ES20.All;
-
+#endif
+#elif PSM
+using PssTexture2D = Sce.PlayStation.Core.Graphics.Texture2D;
#endif
using Microsoft.Xna.Framework.Content;
View
21 MonoGame.Framework/Graphics/Texture3D.cs
@@ -1,13 +1,18 @@
using System;
using System.Runtime.InteropServices;
-
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
#elif GLES
#endif
+#elif DIRECTX
+// TODO!
+#elif PSM
+// TODO!
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
@@ -17,17 +22,21 @@ public class Texture3D : Texture
public int Height { get; private set; }
public int Depth { get; private set; }
+#if OPENGL
PixelInternalFormat glInternalFormat;
PixelFormat glFormat;
PixelType glType;
-
+#elif DIRECTX
+#endif
+
public Texture3D (GraphicsDevice graphicsDevice, int width, int height, int depth, bool mipMap, SurfaceFormat format)
{
this.GraphicsDevice = graphicsDevice;
Width = width;
Height = height;
Depth = depth;
+#if OPENGL
this.glTarget = TextureTarget.Texture3D;
GL.GenTextures (1, out this.glTexture);
@@ -40,6 +49,9 @@ public Texture3D (GraphicsDevice graphicsDevice, int width, int height, int dept
if (mipMap) {
throw new NotImplementedException ();
}
+#elif DIRECTX
+
+#endif
}
public void SetData<T> (T[] data) where T : struct
@@ -63,9 +75,12 @@ public Texture3D (GraphicsDevice graphicsDevice, int width, int height, int dept
var dataHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
var dataPtr = (IntPtr)(dataHandle.AddrOfPinnedObject().ToInt64() + startIndex * elementSizeInByte);
+#if OPENGL
GL.BindTexture(glTarget, glTexture);
GL.TexSubImage3D(glTarget, level, left, top, front, right-left, bottom-top, back-front, glFormat, glType, dataPtr);
-
+#elif DIRECTX
+
+#endif
dataHandle.Free ();
}
View
4 MonoGame.Framework/Graphics/TextureCollection.cs
@@ -3,6 +3,7 @@
using System.Linq;
using System.Text;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
@@ -12,6 +13,7 @@
using TextureUnit = OpenTK.Graphics.ES20.All;
using TextureTarget = OpenTK.Graphics.ES20.All;
#endif
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
@@ -70,7 +72,7 @@ internal void Dirty()
internal void SetTextures(GraphicsDevice device)
{
-#if !WINRT
+#if !DIRECTX
Threading.EnsureUIThread();
#endif
View
32 MonoGame.Framework/Graphics/TextureCube.cs
@@ -1,24 +1,24 @@
using System;
using System.Runtime.InteropServices;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif PSM
-using Sce.PlayStation.Core.Graphics;
-#elif WINRT
-// TODO
-#else
+#elif GLES
using OpenTK.Graphics.ES20;
-#if IPHONE || ANDROID
using PixelInternalFormat = OpenTK.Graphics.ES20.All;
using PixelFormat = OpenTK.Graphics.ES20.All;
using PixelType = OpenTK.Graphics.ES20.All;
using TextureTarget = OpenTK.Graphics.ES20.All;
using TextureParameterName = OpenTK.Graphics.ES20.All;
using TextureMinFilter = OpenTK.Graphics.ES20.All;
#endif
+#elif DIRECTX
+// TODO
+#elif PSM
+using Sce.PlayStation.Core.Graphics;
#endif
namespace Microsoft.Xna.Framework.Graphics
@@ -35,7 +35,7 @@ public int Size
}
}
-#if WINRT
+#if DIRECTX
#elif PSM
//TODO
@@ -51,7 +51,7 @@ public TextureCube (GraphicsDevice graphicsDevice, int size, bool mipMap, Surfac
this.size = size;
this.levelCount = 1;
-#if WINRT
+#if DIRECTX
#elif PSM
//TODO
@@ -113,8 +113,8 @@ public TextureCube (GraphicsDevice graphicsDevice, int size, bool mipMap, Surfac
this.levelCount++;
}
}
-#endif
- }
+#endif
+ }
/// <summary>
/// Gets a copy of cube texture data specifying a cubemap face.
@@ -171,9 +171,9 @@ public TextureCube (GraphicsDevice graphicsDevice, int size, bool mipMap, Surfac
yOffset = rect.Value.Y;
width = rect.Value.Width;
height = rect.Value.Height;
- }
-
-#if WINRT
+ }
+
+#if DIRECTX
#elif PSM
//TODO
@@ -188,11 +188,11 @@ public TextureCube (GraphicsDevice graphicsDevice, int size, bool mipMap, Surfac
GL.TexSubImage2D(target, level, xOffset, yOffset, width, height, glFormat, glType, dataPtr);
GraphicsExtensions.CheckGLError();
}
-#endif
- dataHandle.Free ();
+#endif
+ dataHandle.Free ();
}
-#if !WINRT && !PSM
+#if OPENGL
private TextureTarget GetGLCubeFace(CubeMapFace face) {
switch (face) {
case CubeMapFace.PositiveX: return TextureTarget.TextureCubeMapPositiveX;
View
8 MonoGame.Framework/Graphics/Vertices/IndexBuffer.cs
@@ -4,18 +4,20 @@
using System.Text;
using System.Runtime.InteropServices;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif PSM
-using Sce.PlayStation.Core.Graphics;
-using PssVertexBuffer = Sce.PlayStation.Core.Graphics.VertexBuffer;
#elif GLES
using OpenTK.Graphics.ES20;
using BufferTarget = OpenTK.Graphics.ES20.All;
using BufferUsageHint = OpenTK.Graphics.ES20.All;
#endif
+#elif PSM
+using Sce.PlayStation.Core.Graphics;
+using PssVertexBuffer = Sce.PlayStation.Core.Graphics.VertexBuffer;
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
7 MonoGame.Framework/Graphics/Vertices/VertexBuffer.cs
@@ -4,18 +4,19 @@
using System.Text;
using System.Runtime.InteropServices;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
-#elif PSM
-using Sce.PlayStation.Core.Graphics;
#elif GLES
using OpenTK.Graphics.ES20;
using BufferTarget = OpenTK.Graphics.ES20.All;
using BufferUsageHint = OpenTK.Graphics.ES20.All;
#endif
-
+#elif PSM
+using Sce.PlayStation.Core.Graphics;
+#endif
namespace Microsoft.Xna.Framework.Graphics
{
View
6 MonoGame.Framework/Graphics/Vertices/VertexDeclaration.cs
@@ -2,16 +2,18 @@
using System.Runtime.InteropServices;
using System.Collections.Generic;
+#if OPENGL
#if MONOMAC
using MonoMac.OpenGL;
#elif WINDOWS || LINUX
using OpenTK.Graphics.OpenGL;
+#else
+using OpenTK.Graphics.ES20;
+#endif
#elif PSM
using Sce.PlayStation.Core.Graphics;
#elif DIRECTX
using System.Reflection;
-#else
-using OpenTK.Graphics.ES20;
#endif
namespace Microsoft.Xna.Framework.Graphics
View
19 MonoGame.Framework/Input/Mouse.cs
@@ -45,25 +45,26 @@ 1. Definitions
using System.Drawing;
#endif
+#if OPENGL
#if WINDOWS || LINUX
using MouseInfo = OpenTK.Input.Mouse;
#elif MONOMAC
using MonoMac.Foundation;
using MonoMac.AppKit;
#endif
-
+#endif
namespace Microsoft.Xna.Framework.Input
{
public static class Mouse
{
internal static MouseState State;
-#if WINDOWS || LINUX
+#if (WINDOWS && OPENGL) || LINUX
private static OpenTK.Input.MouseDevice _mouse = null;
#endif
-#if WINDOWS
+#if (WINDOWS && OPENGL)
static OpenTK.GameWindow Window;
@@ -110,13 +111,13 @@ public static MouseState GetState()
#if MONOMAC
//We need to maintain precision...
State.ScrollWheelValue = (int)ScrollWheelValue;
-#elif WINDOWS || LINUX
+#elif (WINDOWS && OPENGL) || LINUX
// maybe someone is tring to get mouse before initialize
if (_mouse == null)
return State;
-#if WINDOWS
+#if (WINDOWS && OPENGL)
var p = new POINT();
GetCursorPos(out p);
var pc = Window.PointToClient(p.ToPoint());
@@ -139,13 +140,15 @@ public static MouseState GetState()
public static void SetPosition(int x, int y)
{
UpdateStatePosition(x, y);
-
-#if WINDOWS || LINUX
+
+#if (WINDOWS && OPENGL) || LINUX
///correcting the coordinate system
///Only way to set the mouse position !!!
System.Drawing.Point pt = Window.PointToScreen(new System.Drawing.Point(x, y));
+#elif WINDOWS
+ var pt = new System.Drawing.Point(0,0);
#endif
-
+
#if WINDOWS
SetCursorPos(pt.X, pt.Y);
#elif LINUX
View
35 MonoGame.Framework/Media/MediaPlayer.cs
@@ -49,9 +49,11 @@ 1. Definitions
using MonoTouch.MediaPlayer;
#endif
-#if WINRT
+#if DIRECTX
using SharpDX.MediaFoundation;
using SharpDX.Multimedia;
+#endif
+#if WINRT
using Windows.UI.Core;
#endif
@@ -69,9 +71,12 @@ public static class MediaPlayer
private static bool _isMuted = false;
private static MediaQueue _queue = new MediaQueue();
-#if WINRT
+#if DIRECTX
private static MediaEngine _mediaEngineEx;
+
+#if WINRT
private static CoreDispatcher _dispatcher;
+#endif
public static TimeSpan PlayPosition
{
@@ -95,14 +100,18 @@ static MediaPlayer()
_mediaEngineEx = mediaEngine.QueryInterface<MediaEngineEx>();
}
+#if WINRT
_dispatcher = CoreWindow.GetForCurrentThread().Dispatcher;
+#endif
}
private static void MediaEngineExOnPlaybackEvent(MediaEngineEvent mediaEvent, long param1, int param2)
{
if (mediaEvent == MediaEngineEvent.Ended)
{
+#if WINRT
_dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => OnSongFinishedPlaying(null, null)).AsTask();
+#endif
}
}
#endif
@@ -118,7 +127,7 @@ public static bool IsMuted
{
_isMuted = value;
-#if WINRT
+#if DIRECTX
_mediaEngineEx.Muted = value;
#else
if (_queue.Count == 0)
@@ -143,7 +152,7 @@ public static bool IsRepeating
{
_isRepeating = value;
-#if WINRT
+#if DIRECTX
_mediaEngineEx.Loop = value;
#endif
}
@@ -152,7 +161,7 @@ public static bool IsRepeating
public static bool IsShuffled { get; set; }
public static bool IsVisualizationEnabled { get { return false; } }
-#if !WINRT
+#if !DIRECTX
public static TimeSpan PlayPosition
{
get
@@ -164,7 +173,7 @@ public static TimeSpan PlayPosition
}
}
#endif
-
+
public static MediaState State
{
get { return _state; }
@@ -216,8 +225,8 @@ public static float Volume
set
{
_volume = value;
-
-#if WINRT
+
+#if DIRECTX
_mediaEngineEx.Volume = value;
#else
if (_queue.ActiveSong == null)
@@ -232,7 +241,7 @@ public static float Volume
public static void Pause()
{
-#if WINRT
+#if DIRECTX
if (State == MediaState.Stopped)
return;
@@ -275,8 +284,8 @@ public static void Play(SongCollection collection, int index = 0)
}
private static void PlaySong(Song song)
- {
-#if WINRT
+ {
+#if DIRECTX
var folder = Windows.ApplicationModel.Package.Current.InstalledLocation.Path;
var path = folder + "\\" + song.FilePath;
var uri = new Uri(path);
@@ -314,7 +323,7 @@ internal static void OnSongFinishedPlaying (object sender, EventArgs args)
public static void Resume()
{
-#if WINRT
+#if DIRECTX
_mediaEngineEx.Play();
#else
if (_queue.ActiveSong == null)
@@ -327,7 +336,7 @@ public static void Resume()
public static void Stop()
{
-#if WINRT
+#if DIRECTX
_mediaEngineEx.Source = null;
#else
if (_queue.ActiveSong == null)
View
6 MonoGame.Framework/Media/MediaQueue.cs
@@ -63,14 +63,14 @@ internal void Clear()
for(; songs.Count > 0; )
{
song = songs[0];
-#if !WINRT
+#if !DIRECTX
song.Stop();
#endif
songs.Remove(song);
}
}
-#if !WINRT
+#if !DIRECTX
internal void SetVolume(float volume)
{
int count = songs.Count;
@@ -84,7 +84,7 @@ internal void Add(Song song)
songs.Add(song);
}
-#if !WINRT
+#if !DIRECTX
internal void Stop()
{
int count = songs.Count;
View
20 MonoGame.Framework/Media/Song.cs
@@ -56,7 +56,7 @@ public sealed class Song : IEquatable<Song>, IDisposable
private AVAudioPlayer _sound;
#elif PSM
private PSSuiteSong _sound;
-#elif !WINRT
+#elif !DIRECTX
private SoundEffectInstance _sound;
#endif
@@ -74,7 +74,7 @@ internal Song(string fileName)
_sound.FinishedPlaying += OnFinishedPlaying;
#elif PSM
_sound = new PSSuiteSong(_name);
-#elif !WINRT
+#elif !DIRECTX
_sound = new SoundEffect(_name).CreateInstance();
#endif
}
@@ -99,7 +99,7 @@ void Dispose(bool disposing)
{
if (!disposed)
{
-#if !WINRT
+#if !DIRECTX
if (disposing)
{
if (_sound != null)
@@ -116,9 +116,9 @@ void Dispose(bool disposing)
}
}
- public bool Equals(Song song)
+ public bool Equals(Song song)
{
-#if WINRT
+#if DIRECTX
return song != null && song.FilePath == FilePath;
#else
return ((object)song != null) && (Name == song.Name);
@@ -155,7 +155,7 @@ public override bool Equals(Object obj)
return ! (song1 == song2);
}
-#if !WINRT
+#if !DIRECTX
internal delegate void FinishedPlayingHandler(object sender, EventArgs args);
event FinishedPlayingHandler DonePlaying;
@@ -192,11 +192,11 @@ internal void Resume()
{
if (_sound == null)
return;
- #if IPHONE
+#if IPHONE
_sound.Play();
- #else
+#else
_sound.Resume();
- #endif
+#endif
}
internal void Pause()
@@ -232,7 +232,7 @@ internal float Volume
_sound.Volume = value;
}
}
-#endif // !WINRT
+#endif // !DIRECTX
// TODO: Implement
public TimeSpan Duration
View
383 MonoGame.Framework/MonoGame.Framework.Windows.csproj
@@ -0,0 +1,383 @@
+<?xml version="1.0" encoding="utf-8"?>
+<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
+ <PropertyGroup>
+ <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
+ <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
+ <ProductVersion>9.0.30729</ProductVersion>
+ <SchemaVersion>2.0</SchemaVersion>
+ <ProjectGuid>{7DE47032-A904-4C29-BD22-2D235E8D91BA}</ProjectGuid>
+ <OutputType>Library</OutputType>
+ <AppDesignerFolder>Properties</AppDesignerFolder>
+ <RootNamespace>Microsoft.Xna.Framework</RootNamespace>
+ <AssemblyName>MonoGame.Framework.Windows</AssemblyName>
+ <FileAlignment>512</FileAlignment>
+ <FileUpgradeFlags>
+ </FileUpgradeFlags>
+ <OldToolsVersion>3.5</OldToolsVersion>
+ <UpgradeBackupLocation />
+ <NoStdLib>False</NoStdLib>
+ <TreatWarningsAsErrors>false</TreatWarningsAsErrors>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
+ <DebugType>full</DebugType>
+ <Optimize>false</Optimize>
+ <OutputPath>bin\Windows\Debug\</OutputPath>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <DebugSymbols>true</DebugSymbols>
+ <RegisterForComInterop>False</RegisterForComInterop>
+ <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
+ <BaseAddress>4194304</BaseAddress>
+ <DefineConstants>TRACE;WINDOWS;DIRECTX</DefineConstants>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ </PropertyGroup>
+ <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
+ <DebugType>none</DebugType>
+ <Optimize>true</Optimize>
+ <OutputPath>bin\Windows\Release\</OutputPath>
+ <WarningLevel>4</WarningLevel>
+ <AllowUnsafeBlocks>true</AllowUnsafeBlocks>
+ <RegisterForComInterop>False</RegisterForComInterop>
+ <GenerateSerializationAssemblies>Auto</GenerateSerializationAssemblies>
+ <BaseAddress>4194304</BaseAddress>
+ <DefineConstants>TRACE;WINDOWS;DIRECTX</DefineConstants>
+ <PlatformTarget>AnyCPU</PlatformTarget>
+ </PropertyGroup>
+ <ItemGroup>
+ <Reference Include="SharpDX">
+ <HintPath>..\ThirdParty\Libs\SharpDX\Windows\SharpDX.dll</HintPath>
+ </Reference>
+ <Reference Include="SharpDX.Direct2D1">
+ <HintPath>..\ThirdParty\Libs\SharpDX\Windows\SharpDX.Direct2D1.dll</HintPath>
+ </Reference>
+ <Reference Include="SharpDX.Direct3D11">
+ <HintPath>..\ThirdParty\Libs\SharpDX\Windows\SharpDX.Direct3D11.dll</HintPath>
+ </Reference>
+ <Reference Include="SharpDX.DXGI">
+ <HintPath>..\ThirdParty\Libs\SharpDX\Windows\SharpDX.DXGI.dll</HintPath>
+ </Reference>
+ <Reference Include="SharpDX.MediaFoundation">
+ <HintPath>..\ThirdParty\Libs\SharpDX\Windows\SharpDX.MediaFoundation.dll</HintPath>
+ </Reference>
+ <Reference Include="SharpDX.XAudio2">
+ <HintPath>..\ThirdParty\Libs\SharpDX\Windows\SharpDX.XAudio2.dll</HintPath>
+ </Reference>
+ <Reference Include="System" />
+ <Reference Include="System.Core" />
+ <Reference Include="System.Web" />
+ <Reference Include="System.Web.Services" />
+ <Reference Include="System.Windows.Forms" />
+ <Reference Include="System.Xml.Linq" />
+ <Reference Include="System.Xml" />
+ <Reference Include="System.Drawing" />
+ </ItemGroup>
+ <ItemGroup>
+ <Compile Include="Audio\SoundEffect.cs" />
+ <Compile Include="Audio\SoundEffectInstance.cs" />
+ <Compile Include="Content\ContentExtensions.cs" />
+ <Compile Include="Content\ContentReaders\DualTextureEffectReader.cs" />
+ <Compile Include="Content\ContentReaders\EffectReader.cs" />
+ <Compile Include="Content\ContentReaders\EnvironmentMapEffectReader.cs" />
+ <Compile Include="Content\ContentReaders\ExternalReferenceReader.cs" />
+ <Compile Include="Content\ContentReaders\ModelReader.cs" />
+ <Compile Include="Content\ContentReaders\SkinnedEffectReader.cs" />
+ <Compile Include="Content\ContentReaders\SongReader.cs" />
+ <Compile Include="Content\ContentReaders\SpriteFontReader.cs" />
+ <Compile Include="Content\ContentReaders\Texture2DReader.cs" />
+ <Compile Include="Content\ContentReaders\AlphaTestEffectReader.cs" />
+ <Compile Include="Content\ContentReaders\BasicEffectReader.cs" />
+ <Compile Include="Content\ContentReaders\BoundingBoxReader.cs" />
+ <Compile Include="Content\ContentReaders\IndexBufferReader.cs" />
+ <Compile Include="Content\ContentReaders\MatrixReader.cs" />
+ <Compile Include="Content\ContentReaders\TextureCubeReader.cs" />
+ <Compile Include="Content\ContentReaders\TextureReader.cs" />
+ <Compile Include="Content\ContentReaders\VertexBufferReader.cs" />
+ <Compile Include="Content\ContentReaders\VertexDeclarationReader.cs" />
+ <Compile Include="Content\ResourceContentManager.cs" />
+ <Compile Include="Graphics\GraphicsExtensions.cs" />
+ <Compile Include="Graphics\Shader\ConstantBufferCollection.cs" />
+ <Compile Include="Input\Mouse.cs" />
+ <Compile Include="Game.cs" />
+ <Compile Include="GamePlatform.cs" />
+ <Compile Include="Graphics\CubeMapFace.cs" />
+ <Compile Include="Graphics\DisplayMode.cs" />
+ <Compile Include="Graphics\Effect\AlphaTestEffect.cs" />
+ <Compile Include="Graphics\Effect\DualTextureEffect.cs" />
+ <Compile Include="Graphics\Effect\Effect.cs" />
+ <Compile Include="Graphics\Effect\EffectAnnotation.cs" />
+ <Compile Include="Graphics\Effect\EffectAnnotationCollection.cs" />
+ <Compile Include="Graphics\Effect\EffectHelpers.cs" />
+ <Compile Include="Graphics\Effect\EffectPass.cs" />
+ <Compile Include="Graphics\Effect\EnvironmentMapEffect.cs" />
+ <Compile Include="Graphics\Effect\SkinnedEffect.cs" />
+ <Compile Include="Graphics\GraphicsAdapter.cs" />
+ <Compile Include="Graphics\GraphicsDevice.cs" />
+ <Compile Include="Graphics\Model.cs" />
+ <Compile Include="Graphics\ModelBone.cs" />
+ <Compile Include="Graphics\ModelBoneCollection.cs" />
+ <Compile Include="Graphics\ModelEffectCollection.cs" />
+ <Compile Include="Graphics\ModelMesh.cs" />
+ <Compile Include="Graphics\ModelMeshCollection.cs" />
+ <Compile Include="Graphics\ModelMeshPart.cs" />
+ <Compile Include="Graphics\ModelMeshPartCollection.cs" />
+ <Compile Include="Graphics\PackedVector\HalfSingle.cs" />
+ <Compile Include="Graphics\PackedVector\HalfTypeHelper.cs" />
+ <Compile Include="Graphics\PackedVector\HalfVector2.cs" />
+ <Compile Include="Graphics\PackedVector\NormalizedShort2.cs" />
+ <Compile Include="Graphics\PackedVector\NormalizedShort4.cs" />
+ <Compile Include="Graphics\PresentationParameters.cs" />
+ <Compile Include="Graphics\PresentInterval.cs" />
+ <Compile Include="Graphics\RenderTarget2D.cs" />
+ <Compile Include="Graphics\Shader\ConstantBuffer.cs" />
+ <Compile Include="Graphics\Shader\Shader.cs" />
+ <Compile Include="Graphics\Shader\ShaderProgramCache.cs" />
+ <Compile Include="Graphics\Shader\ShaderStage.cs" />
+ <Compile Include="Graphics\SpriteBatch.cs" />
+ <Compile Include="Graphics\SpriteBatcher.cs" />
+ <Compile Include="Graphics\Texture2D.cs" />
+ <Compile Include="Graphics\TextureCube.cs" />
+ <Compile Include="Graphics\Vertices\DynamicIndexBuffer.cs" />
+ <Compile Include="Graphics\Vertices\DynamicVertexBuffer.cs" />
+ <Compile Include="Graphics\Vertices\IndexBuffer.cs" />
+ <Compile Include="Graphics\Vertices\IndexElementSize.cs" />
+ <Compile Include="Graphics\Vertices\VertexBuffer.cs" />
+ <Compile Include="Graphics\Vertices\VertexDeclaration.cs" />
+ <Compile Include="Graphics\Vertices\VertexDeclarationCache.cs" />
+ <Compile Include="Graphics\Vertices\VertexPositionColorTexture.cs" />
+ <Compile Include="Input\GamePadDeadZone.cs" />
+ <Compile Include="Input\Keyboard.cs" />
+ <Compile Include="Input\MouseState.cs" />
+ <Compile Include="LaunchParameters.cs" />
+ <Compile Include="Media\VideoSoundtrackType.cs" />
+ <Compile Include="Properties\AssemblyInfo.cs" />
+ <Compile Include="Audio\AudioChannels.cs" />
+ <Compile Include="Audio\AudioEmitter.cs" />
+ <Compile Include="Audio\AudioListener.cs" />
+ <Compile Include="Audio\AudioStopOptions.cs" />
+ <Compile Include="Audio\InstancePlayLimitException.cs" />
+ <Compile Include="Audio\NoAudioHardwareException.cs" />
+ <Compile Include="Audio\SoundState.cs" />
+ <Compile Include="Content\ContentManager.cs" />
+ <Compile Include="Content\ContentReaders\ArrayReader.cs" />
+ <Compile Include="Content\ContentReaders\BooleanReader.cs" />
+ <Compile Include="Content\ContentReaders\ColorReader.cs" />
+ <Compile Include="Content\ContentReaders\DictionaryReader.cs" />
+ <Compile Include="Content\ContentReaders\DoubleReader.cs" />
+ <Compile Include="Content\ContentReaders\EnumReader.cs" />
+ <Compile Include="Content\ContentReaders\Int16Reader.cs" />
+ <Compile Include="Content\ContentReaders\Int32Reader.cs" />
+ <Compile Include="Content\ContentReaders\Int64Reader.cs" />
+ <Compile Include="Content\ContentReaders\NullableReader.cs" />
+ <Compile Include="Content\ContentReaders\PointReader.cs" />
+ <Compile Include="Content\ContentReaders\ReflectiveReader.cs" />
+ <Compile Include="Content\ContentReaders\SingleReader.cs" />
+ <Compile Include="Content\ContentReaders\SoundEffectReader.cs" />