diff --git a/src/Audio/AudioDevice.cs b/src/Audio/AudioDevice.cs index c290a6e..0ced362 100644 --- a/src/Audio/AudioDevice.cs +++ b/src/Audio/AudioDevice.cs @@ -71,21 +71,7 @@ namespace Microsoft.Xna.Framework.Audio } else { - try - { - ALDevice = new OpenALDevice(); - } - catch(DllNotFoundException e) - { - System.Console.WriteLine("OpenAL not found! Need FNA.dll.config?"); - throw e; - } - catch(Exception) - { - /* We ignore and device creation exceptions, - * as they are handled down the line with Instance != null - */ - } + ALDevice = FNAPlatform.CreateALDevice(); } // Populate device list diff --git a/src/FNAPlatform.cs b/src/FNAPlatform.cs index 1f25c49..c83fed1 100644 --- a/src/FNAPlatform.cs +++ b/src/FNAPlatform.cs @@ -12,6 +12,7 @@ using System; using System.IO; using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Input; #endregion @@ -39,6 +40,8 @@ namespace Microsoft.Xna.Framework Dispose = SDL2_FNAPlatform.Dispose; BeforeInitialize = SDL2_FNAPlatform.BeforeInitialize; RunLoop = SDL2_FNAPlatform.RunLoop; + CreateGLDevice = SDL2_FNAPlatform.CreateGLDevice; + CreateALDevice = SDL2_FNAPlatform.CreateALDevice; SetPresentationInterval = SDL2_FNAPlatform.SetPresentationInterval; GetGraphicsAdapters = SDL2_FNAPlatform.GetGraphicsAdapters; GetKeyFromScancode = SDL2_FNAPlatform.GetKeyFromScancode; @@ -69,6 +72,14 @@ namespace Microsoft.Xna.Framework public delegate void RunLoopFunc(Game game); public static RunLoopFunc RunLoop; + public delegate IGLDevice CreateGLDeviceFunc( + PresentationParameters presentationParameters + ); + public static CreateGLDeviceFunc CreateGLDevice; + + public delegate IALDevice CreateALDeviceFunc(); + public static CreateALDeviceFunc CreateALDevice; + public delegate void SetPresentationIntervalFunc(PresentInterval interval); public static SetPresentationIntervalFunc SetPresentationInterval; diff --git a/src/Graphics/GraphicsDevice.cs b/src/Graphics/GraphicsDevice.cs index 84eb327..14ae08f 100644 --- a/src/Graphics/GraphicsDevice.cs +++ b/src/Graphics/GraphicsDevice.cs @@ -383,8 +383,8 @@ namespace Microsoft.Xna.Framework.Graphics PresentationParameters.MultiSampleCount ); - // Set up the OpenGL Device. Loads entry points. - GLDevice = new OpenGLDevice(PresentationParameters); + // Set up the IDLDevice + GLDevice = FNAPlatform.CreateGLDevice(PresentationParameters); // The mouse needs to know this for faux-backbuffer mouse scaling. Input.Mouse.INTERNAL_BackBufferWidth = PresentationParameters.BackBufferWidth; diff --git a/src/SDL2/SDL2_FNAPlatform.cs b/src/SDL2/SDL2_FNAPlatform.cs index 1b2a8e0..b2f194d 100644 --- a/src/SDL2/SDL2_FNAPlatform.cs +++ b/src/SDL2/SDL2_FNAPlatform.cs @@ -33,6 +33,7 @@ using System.Runtime.InteropServices; using SDL2; using Microsoft.Xna.Framework.Graphics; +using Microsoft.Xna.Framework.Audio; using Microsoft.Xna.Framework.Input; #endregion @@ -434,6 +435,33 @@ namespace Microsoft.Xna.Framework } } + public static IGLDevice CreateGLDevice( + PresentationParameters presentationParameters + ) { + // This loads the OpenGL entry points. + return new OpenGLDevice(presentationParameters); + } + + public static IALDevice CreateALDevice() + { + try + { + return new OpenALDevice(); + } + catch(DllNotFoundException e) + { + System.Console.WriteLine("OpenAL not found! Need FNA.dll.config?"); + throw e; + } + catch(Exception) + { + /* We ignore device creation exceptions, + * as they are handled down the line with Instance != null + */ + return null; + } + } + public static void SetPresentationInterval(PresentInterval interval) { if (interval == PresentInterval.Default || interval == PresentInterval.One)