refactored AddInSystem (testing needed)

implemented feature #469 (Default AddIn override)
This commit is contained in:
Glatzemann 2011-12-06 09:11:26 +00:00
parent c553c15792
commit 0e1d271195
30 changed files with 699 additions and 255 deletions

View File

@ -90,7 +90,7 @@ namespace ANX.Framework.TestCenter.Strukturen.Input
{ {
AddInSystemFactory.Instance.Initialize(); AddInSystemFactory.Instance.Initialize();
AddInSystemFactory.Instance.SetDefaultCreator("XInput"); AddInSystemFactory.Instance.PreferredInputSystem = "XInput";
XNAGamePadState xnastate = XNAGamePad.GetState(xnaplayer); XNAGamePadState xnastate = XNAGamePad.GetState(xnaplayer);
ANXGamePadState anxstate = ANXGamePad.GetState(anxplayer); ANXGamePadState anxstate = ANXGamePad.GetState(anxplayer);

View File

@ -418,7 +418,9 @@
<Compile Include="Net\QualityOfService.cs" /> <Compile Include="Net\QualityOfService.cs" />
<Compile Include="Net\SendDataOptions.cs" /> <Compile Include="Net\SendDataOptions.cs" />
<Compile Include="Net\WriteLeaderboardsEventArgs.cs" /> <Compile Include="Net\WriteLeaderboardsEventArgs.cs" />
<Compile Include="NonXNA\AddIn.cs" />
<Compile Include="NonXNA\AddInLoadingException.cs" /> <Compile Include="NonXNA\AddInLoadingException.cs" />
<Compile Include="NonXNA\AddInType.cs" />
<Compile Include="NonXNA\InputSystem\IKeyboard.cs" /> <Compile Include="NonXNA\InputSystem\IKeyboard.cs" />
<Compile Include="NonXNA\InputSystem\IMotionSensingDevice.cs" /> <Compile Include="NonXNA\InputSystem\IMotionSensingDevice.cs" />
<Compile Include="NonXNA\InputSystem\IMouse.cs" /> <Compile Include="NonXNA\InputSystem\IMouse.cs" />

View File

@ -90,21 +90,9 @@ namespace ANX.Framework
public event EventHandler<EventArgs> Disposed; public event EventHandler<EventArgs> Disposed;
public event EventHandler<EventArgs> Exiting; public event EventHandler<EventArgs> Exiting;
//TODO: The constructor should be overloaded unlike the original XNA. There will be one argument which is used to
// try to load a specified environment (DX9, DX10, DX11, OpenGL). The default constructor will decide which
// is the best (or only) environment to load. The default environment should behave mostly like XNA.
public Game() public Game()
: this("DirectX10", "XInput", "XAudio")
{
}
public Game(String renderSystemName = "DirectX10", String inputSystemName = "XInput", String soundSystemName = "XAudio")
{ {
logger.Info("created a new Game-Class"); logger.Info("created a new Game-Class");
logger.Info("- asked for RenderSystem '{0}'", renderSystemName);
logger.Info("- asked for InputSystem '{0}'", inputSystemName);
logger.Info("- asked for SoundSystem '{0}'", soundSystemName);
this.gameServices = new GameServiceContainer(); this.gameServices = new GameServiceContainer();
this.gameTime = new GameTime(); this.gameTime = new GameTime();
@ -120,46 +108,18 @@ namespace ANX.Framework
throw new AddInLoadingException("Error while initializing AddInSystem.", ex); throw new AddInLoadingException("Error while initializing AddInSystem.", ex);
} }
try
{
AddInSystemFactory.Instance.SetDefaultCreator(inputSystemName);
}
catch (Exception ex)
{
logger.ErrorException(String.Format("Error during loading InputSystem {0}", inputSystemName), ex);
throw new AddInLoadingException(String.Format("Error during loading InputSystem {0}", inputSystemName), ex);
}
IInputSystemCreator inputSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IInputSystemCreator>(); IInputSystemCreator inputSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IInputSystemCreator>();
if (inputSystemCreator != null) if (inputSystemCreator != null)
{ {
this.gameServices.AddService(typeof(IInputSystemCreator), inputSystemCreator); this.gameServices.AddService(typeof(IInputSystemCreator), inputSystemCreator);
} }
try
{
AddInSystemFactory.Instance.SetDefaultCreator(soundSystemName);
}
catch (Exception ex)
{
logger.ErrorException(String.Format("Error during loading SoundSystem {0}", soundSystemName), ex);
throw new AddInLoadingException(String.Format("Error during loading SoundSystem {0}", soundSystemName), ex);
}
ISoundSystemCreator soundSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>(); ISoundSystemCreator soundSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<ISoundSystemCreator>();
if (soundSystemCreator != null) if (soundSystemCreator != null)
{ {
this.gameServices.AddService(typeof(ISoundSystemCreator), soundSystemCreator); this.gameServices.AddService(typeof(ISoundSystemCreator), soundSystemCreator);
} }
try
{
AddInSystemFactory.Instance.SetDefaultCreator(renderSystemName);
}
catch (Exception ex)
{
logger.ErrorException(String.Format("Error during loading RenderSystem {0}", renderSystemName), ex);
throw new AddInLoadingException(String.Format("Error during loading RenderSystem {0}", renderSystemName), ex);
}
IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>(); IRenderSystemCreator renderSystemCreator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>();
if (renderSystemCreator != null) if (renderSystemCreator != null)
{ {
@ -168,10 +128,9 @@ namespace ANX.Framework
logger.Info("creating GameHost"); logger.Info("creating GameHost");
IRenderSystemCreator creator = AddInSystemFactory.Instance.GetDefaultCreator<IRenderSystemCreator>(); if (renderSystemCreator != null)
if (creator != null)
{ {
this.host = creator.CreateGameHost(this); this.host = renderSystemCreator.CreateGameHost(this);
this.host.Activated += new EventHandler<EventArgs>(this.HostActivated); this.host.Activated += new EventHandler<EventArgs>(this.HostActivated);
this.host.Deactivated += new EventHandler<EventArgs>(this.HostDeactivated); this.host.Deactivated += new EventHandler<EventArgs>(this.HostDeactivated);

View File

@ -0,0 +1,307 @@
#region Using Statements
using System;
using System.Runtime.Serialization;
using System.IO;
using System.Reflection;
using System.Collections.Generic;
using System.Resources;
using System.Collections;
using System.Linq;
#endregion
#region License
//
// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
//
// This file is released under the Ms-PL license.
//
//
//
// Microsoft Public License (Ms-PL)
//
// This license governs use of the accompanying software. If you use the software, you accept this license.
// If you do not accept the license, do not use the software.
//
// 1.Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning
// here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
//
// 2.Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
// or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in
// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed
// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution
// in the software or derivative works of the contribution in the software.
//
// 3.Conditions and Limitations
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
// patent license from such contributor to the software ends automatically.
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
// notices that are present in the software.
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
// object code form, you may only do so under a license that complies with this license.
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
#endregion // License
namespace ANX.Framework.NonXNA
{
public class AddIn : IComparable<AddIn>
{
#region Private Members
private string fileName;
private List<string> platforms = new List<string>();
private Assembly assembly;
private Type creatorType;
private ICreator instance;
private AddInType addInType;
#endregion // Private Members
#region Constructor
public AddIn(string fileName)
{
if (string.IsNullOrEmpty(fileName))
{
throw new ArgumentNullException("fileName");
}
if (!File.Exists(fileName))
{
throw new InvalidOperationException(String.Format("The AddIn '{0}' does not exist.", fileName));
}
this.fileName = fileName;
try
{
this.assembly = Assembly.LoadFrom(fileName);
}
catch { }
if (this.assembly != null)
{
foreach (Type t in this.assembly.GetTypes().Where(p => typeof(IInputSystemCreator).IsAssignableFrom(p) ||
typeof(IRenderSystemCreator).IsAssignableFrom(p) ||
typeof(ISoundSystemCreator).IsAssignableFrom(p)
))
{
this.creatorType = t;
if (typeof(IInputSystemCreator).IsAssignableFrom(t))
{
this.addInType = AddInType.InputSystem;
}
else if (typeof(IRenderSystemCreator).IsAssignableFrom(t))
{
this.addInType = AddInType.RenderSystem;
}
else if (typeof(ISoundSystemCreator).IsAssignableFrom(t))
{
this.addInType = AddInType.SoundSystem;
}
else
{
this.addInType = AddInType.Unknown;
}
break;
}
if (this.creatorType != null)
{
try
{
this.platforms.AddRange(FetchSupportedPlattforms(this.assembly));
}
catch { }
}
}
}
#endregion // Constructor
#region Puplic Methods
#endregion // Public Methods
#region Properties
/// <summary>
/// Returns whether this is a valid AddIn of the ANX.Framework.
/// </summary>
public bool IsValid
{
get
{
return this.assembly != null && this.creatorType != null;
}
}
/// <summary>
/// The filename of the current AddIn assembly
/// </summary>
public string FileName
{
get
{
return this.fileName;
}
}
/// <summary>
/// Returns true if this AddIn is supported by the current Platform
/// </summary>
public bool IsSupported
{
get
{
if (this.assembly != null && this.platforms != null && this.platforms.Count > 0)
{
foreach (string platform in this.platforms)
{
if (string.Equals(Environment.OSVersion.Platform.ToString(), platform, StringComparison.InvariantCultureIgnoreCase))
{
return true;
}
}
}
return false;
}
}
/// <summary>
/// Returns the version of the AddIn
/// </summary>
public Version Version
{
get
{
if (this.assembly != null)
{
return this.assembly.GetName().Version;
}
return null;
}
}
public string Name
{
get
{
if (this.assembly != null)
{
return this.Instance.Name;
}
return String.Empty;
}
}
public int Priority
{
get
{
if (this.assembly != null)
{
return this.Instance.Priority;
}
return int.MaxValue;
}
}
public AddInType Type
{
get
{
return this.addInType;
}
}
/// <summary>
/// Returns the concrete instance of the creator of this AddIn. The instance is cached and
/// only created on first access.
/// </summary>
/// <remarks>
/// If this AddIn is not supported on this platform the instance will be null.
/// </remarks>
public ICreator Instance
{
get
{
if (instance == null && IsSupported)
{
this.instance = this.assembly.CreateInstance(this.creatorType.FullName) as ICreator;
if (this.instance != null)
{
this.instance.RegisterCreator(AddInSystemFactory.Instance);
}
}
return this.instance;
}
}
#endregion // Properties
#region Private Helpers
private string[] FetchSupportedPlattforms(Assembly assembly)
{
string[] platforms = null;
string[] res = assembly.GetManifestResourceNames();
if (res != null)
{
foreach (string ressource in res)
{
Stream manifestResourceStream = assembly.GetManifestResourceStream(ressource);
if (manifestResourceStream != null)
{
using (ResourceReader resourceReader = new ResourceReader(manifestResourceStream))
{
IDictionaryEnumerator dict = resourceReader.GetEnumerator();
while (dict.MoveNext())
{
if (string.Equals(dict.Key.ToString(), "SupportedPlatforms", StringComparison.InvariantCultureIgnoreCase) &&
dict.Value.GetType() == typeof(string))
{
platforms = dict.Value.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return platforms;
}
}
resourceReader.Close();
}
}
}
}
return platforms;
}
#endregion // Private Helpers
public int CompareTo(AddIn other)
{
return this.Priority.CompareTo(other.Priority);
}
}
}

View File

@ -62,6 +62,7 @@ namespace ANX.Framework.NonXNA
{ {
public class AddInSystemFactory public class AddInSystemFactory
{ {
#region Private Members
private Dictionary<String, ICreator> creators; private Dictionary<String, ICreator> creators;
private static AddInSystemFactory instance; private static AddInSystemFactory instance;
private bool initialized; private bool initialized;
@ -69,8 +70,21 @@ namespace ANX.Framework.NonXNA
private OperatingSystem operatingSystem; private OperatingSystem operatingSystem;
private Version operatingSystemVersion; private Version operatingSystemVersion;
private string preferredRenderSystem;
private bool preferredRenderSystemLocked;
private string preferredInputSystem;
private bool preferredInputSystemLocked;
private string preferredSoundSystem;
private bool preferredSoundSystemLocked;
private List<AddIn> renderSystems;
private List<AddIn> inputSystems;
private List<AddIn> soundSystems;
private static Logger logger = LogManager.GetCurrentClassLogger(); private static Logger logger = LogManager.GetCurrentClassLogger();
#endregion // Private Members
public static AddInSystemFactory Instance public static AddInSystemFactory Instance
{ {
get get
@ -87,6 +101,10 @@ namespace ANX.Framework.NonXNA
private AddInSystemFactory() private AddInSystemFactory()
{ {
this.renderSystems = new List<AddIn>();
this.inputSystems = new List<AddIn>();
this.soundSystems = new List<AddIn>();
this.creators = new Dictionary<string, ICreator>(); this.creators = new Dictionary<string, ICreator>();
this.operatingSystem = Environment.OSVersion; this.operatingSystem = Environment.OSVersion;
@ -110,56 +128,33 @@ namespace ANX.Framework.NonXNA
{ {
logger.Info("[ANX] trying to load '{0}'...", file); logger.Info("[ANX] trying to load '{0}'...", file);
Assembly part = null; AddIn addin = new AddIn(file);
if (addin.IsValid && addin.IsSupported)
try
{ {
part = Assembly.LoadFile(file); switch (addin.Type)
}
catch (Exception ex)
{
logger.Debug("error calling Assembly.LoadFile({0}) Exception: {1}", file, ex.Message);
}
if (part != null)
{
logger.Info("[ANX] scanning for ANX interfaces...");
foreach (Type t in part.GetTypes().Where(p => typeof(IInputSystemCreator).IsAssignableFrom(p) ||
typeof(IRenderSystemCreator).IsAssignableFrom(p) ||
typeof(ISoundSystemCreator).IsAssignableFrom(p)
))
{ {
logger.Info("[ANX] testing if assembly is supported on current platform"); case AddInType.InputSystem:
string[] platforms = FetchSupportedPlattforms(part); this.inputSystems.Add(addin);
bool supportedPlatform = false; break;
case AddInType.RenderSystem:
foreach (string platform in platforms) this.renderSystems.Add(addin);
{ break;
if (string.Equals(OperatingSystem.Platform.ToString(), platform, StringComparison.InvariantCultureIgnoreCase)) case AddInType.SoundSystem:
{ this.soundSystems.Add(addin);
supportedPlatform = true; break;
break;
}
}
if (supportedPlatform)
{
logger.Info("[ANX] registering instance of '{0}'...", t.FullName);
var instance = part.CreateInstance(t.FullName);
((ICreator)instance).RegisterCreator(this);
}
else
{
logger.Info("[ANX] current platform '{0}' is not supported by '{1}'", OperatingSystem.Platform.ToString(), t.FullName);
}
} }
logger.Info("[ANX] successfully loaded addin...");
}
else
{
logger.Info("[ANX] skipped loading file because it is not supported or not a valid AddIn");
} }
} }
} }
SetDefaultCreators(); this.inputSystems.Sort();
this.renderSystems.Sort();
this.soundSystems.Sort();
} }
} }
@ -220,54 +215,82 @@ namespace ANX.Framework.NonXNA
} }
Type type = typeof(T); Type type = typeof(T);
AddInType addInType = GetAddInType(type);
if (defaultCreators.ContainsKey(type)) switch (addInType)
{ {
return defaultCreators[type] as T; case AddInType.InputSystem:
} if (string.IsNullOrEmpty(preferredInputSystem))
{
if (inputSystems.Count > 0)
{
return inputSystems[0].Instance as T;
}
throw new AddInLoadingException("couldn't get default input system because there are no registered input systems available");
}
else
{
foreach (AddIn addin in this.inputSystems)
{
if (addin.Name.Equals(preferredInputSystem, StringComparison.InvariantCultureIgnoreCase))
{
return addin.Instance as T;
}
}
throw new AddInLoadingException(String.Format("couldn't get default input system '{0}' because it was not found in the list of registered creators", preferredInputSystem));
}
case AddInType.RenderSystem:
if (string.IsNullOrEmpty(preferredRenderSystem))
{
if (renderSystems.Count > 0)
{
return renderSystems[0].Instance as T;
}
throw new AddInLoadingException("couldn't get default render system because there are no registered render systems available");
}
else
{
foreach (AddIn addin in this.renderSystems)
{
if (addin.Name.Equals(preferredRenderSystem, StringComparison.InvariantCultureIgnoreCase))
{
return addin.Instance as T;
}
}
throw new AddInLoadingException(String.Format("couldn't get default render system '{0}' because it was not found in the list of registered creators", preferredRenderSystem));
}
case AddInType.SoundSystem:
if (string.IsNullOrEmpty(preferredSoundSystem))
{
if (soundSystems.Count > 0)
{
return soundSystems[0].Instance as T;
}
throw new AddInLoadingException("couldn't get default sound system because there are no registered sound systems available");
}
else
{
foreach (AddIn addin in this.soundSystems)
{
if (addin.Name.Equals(preferredSoundSystem, StringComparison.InvariantCultureIgnoreCase))
{
return addin.Instance as T;
}
}
throw new AddInLoadingException(String.Format("couldn't get default sound system '{0}' because it was not found in the list of registered creators", preferredSoundSystem));
}
logger.Error(String.Format("couldn't find a DefaultCreator of type '{0}'. Listing all registered creators: ", type.FullName));
foreach (KeyValuePair<Type, ICreator> kvp in defaultCreators)
{
logger.Error(kvp.Key);
} }
throw new AddInLoadingException(String.Format("couldn't find a DefaultCreator of type '{0}'", type.FullName)); throw new AddInLoadingException(String.Format("couldn't find a DefaultCreator of type '{0}'", type.FullName));
} }
public void SetDefaultCreator<T>(T creator) where T : class, ICreator
{
Type t = typeof(T);
logger.Debug("setting DefaultCreator by type: {0}", t.FullName);
defaultCreators[t] = creator;
}
public void SetDefaultCreator(string creatorName)
{
if (!initialized)
{
Initialize();
}
ICreator creator = null;
creators.TryGetValue(creatorName.ToLowerInvariant(), out creator);
if (creator != null)
{
Type t = creator.GetType().GetInterfaces()[0];
if (t == typeof(ICreator))
{
//TODO: exception handling
t = creator.GetType().GetInterfaces()[1];
}
logger.Debug("setting DefaultCreator by name: '{0}'. Resolved type: '{1}'. ", creatorName, t.FullName);
defaultCreators[t] = creator;
}
else
{
throw new AddInLoadingException(String.Format("couldn't set DefaultCreator by name: '{0}'. ", creatorName));
}
}
public OperatingSystem OperatingSystem public OperatingSystem OperatingSystem
{ {
get get
@ -284,94 +307,90 @@ namespace ANX.Framework.NonXNA
} }
} }
private void SetDefaultCreators() public string PreferredRenderSystem
{ {
foreach (ICreator creator in this.creators.Values) get
{ {
string type = creator.GetType().GetInterfaces()[0].ToString(); return this.preferredRenderSystem;
}
switch (type) set
{
if (this.preferredRenderSystemLocked && !this.preferredRenderSystem.Equals(value, StringComparison.InvariantCultureIgnoreCase))
{ {
case "ANX.Framework.NonXNA.IRenderSystemCreator": throw new AddInLoadingException("can't set preferred RenderSystem because a RenderSystem is alread in use.");
IRenderSystemCreator renderSystemCreator = creator as IRenderSystemCreator;
IRenderSystemCreator defaultRenderSystemCreator = null;
if (defaultCreators.ContainsKey(typeof(IRenderSystemCreator)))
{
renderSystemCreator = defaultCreators[typeof(IRenderSystemCreator)] as IRenderSystemCreator;
}
if (renderSystemCreator != null && (defaultRenderSystemCreator == null || defaultRenderSystemCreator.Priority > renderSystemCreator.Priority))
{
SetDefaultCreator<IRenderSystemCreator>(renderSystemCreator);
}
break;
case "ANX.Framework.NonXNA.ISoundSystemCreator":
ISoundSystemCreator soundSystemCreator = creator as ISoundSystemCreator;
ISoundSystemCreator defaultSoundSystemCreator = null;
if (defaultCreators.ContainsKey(typeof(ISoundSystemCreator)))
{
defaultSoundSystemCreator = defaultCreators[typeof(ISoundSystemCreator)] as ISoundSystemCreator;
}
if (soundSystemCreator != null && (defaultSoundSystemCreator == null || defaultSoundSystemCreator.Priority > soundSystemCreator.Priority))
{
SetDefaultCreator<ISoundSystemCreator>(soundSystemCreator);
}
break;
case "ANX.Framework.NonXNA.IInputSystemCreator":
IInputSystemCreator inputSystemCreator = creator as IInputSystemCreator;
IInputSystemCreator defaultInputSystemCreator = null;
if (defaultCreators.ContainsKey(typeof(IInputSystemCreator)))
{
defaultInputSystemCreator = defaultCreators[typeof(IInputSystemCreator)] as IInputSystemCreator;
}
if (inputSystemCreator != null && (defaultInputSystemCreator == null || defaultInputSystemCreator.Priority > inputSystemCreator.Priority))
{
SetDefaultCreator<IInputSystemCreator>(inputSystemCreator);
}
break;
case "ANX.Framework.NonXNA.ICreator":
break;
default:
throw new InvalidOperationException(String.Format("unable to set a default system for creator of type '{0}'", type));
} }
this.preferredRenderSystem = value;
} }
} }
private string[] FetchSupportedPlattforms(Assembly assembly) public string PreferredInputSystem
{ {
string[] platforms = null; get
string[] res = assembly.GetManifestResourceNames();
if (res != null)
{ {
foreach (string ressource in res) return this.preferredInputSystem;
{
Stream manifestResourceStream = assembly.GetManifestResourceStream(ressource);
if (manifestResourceStream != null)
{
using (ResourceReader resourceReader = new ResourceReader(manifestResourceStream))
{
IDictionaryEnumerator dict = resourceReader.GetEnumerator();
while (dict.MoveNext())
{
if (string.Equals(dict.Key.ToString(), "SupportedPlatforms", StringComparison.InvariantCultureIgnoreCase) &&
dict.Value.GetType() == typeof(string))
{
platforms = dict.Value.ToString().Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
return platforms;
}
}
resourceReader.Close();
}
}
}
} }
set
{
if (this.preferredInputSystemLocked && !this.preferredInputSystem.Equals(value, StringComparison.InvariantCultureIgnoreCase))
{
throw new AddInLoadingException("can't set preferred InputSystem because a InputSystem is alread in use.");
}
return platforms; this.preferredInputSystem = value;
}
} }
public string PreferredSoundSystem
{
get
{
return this.preferredSoundSystem;
}
set
{
if (this.preferredSoundSystemLocked && !this.preferredSoundSystem.Equals(value, StringComparison.InvariantCultureIgnoreCase))
{
throw new AddInLoadingException("can't set preferred SoundSystem because a SoundSystem is alread in use.");
}
this.preferredSoundSystem = value;
}
}
public void PreventRenderSystemChange()
{
this.preferredRenderSystemLocked = true;
}
public void PreventInputSystemChange()
{
this.preferredInputSystemLocked = true;
}
public void PreventSoundSystemChange()
{
this.preferredSoundSystemLocked = true;
}
private AddInType GetAddInType(Type t)
{
if (typeof(IRenderSystemCreator).IsAssignableFrom(t))
{
return AddInType.RenderSystem;
}
else if (typeof(IInputSystemCreator).IsAssignableFrom(t))
{
return AddInType.InputSystem;
}
else if (typeof(ISoundSystemCreator).IsAssignableFrom(t))
{
return AddInType.SoundSystem;
}
else
{
return AddInType.Unknown;
}
}
} }
} }

View File

@ -0,0 +1,62 @@
#region Using Statements
using System;
#endregion
#region License
//
// This file is part of the ANX.Framework created by the "ANX.Framework developer group".
//
// This file is released under the Ms-PL license.
//
//
//
// Microsoft Public License (Ms-PL)
//
// This license governs use of the accompanying software. If you use the software, you accept this license.
// If you do not accept the license, do not use the software.
//
// 1.Definitions
// The terms "reproduce," "reproduction," "derivative works," and "distribution" have the same meaning
// here as under U.S. copyright law.
// A "contribution" is the original software, or any additions or changes to the software.
// A "contributor" is any person that distributes its contribution under this license.
// "Licensed patents" are a contributor's patent claims that read directly on its contribution.
//
// 2.Grant of Rights
// (A) Copyright Grant- Subject to the terms of this license, including the license conditions and limitations
// in section 3, each contributor grants you a non-exclusive, worldwide, royalty-free copyright license to
// reproduce its contribution, prepare derivative works of its contribution, and distribute its contribution
// or any derivative works that you create.
// (B) Patent Grant- Subject to the terms of this license, including the license conditions and limitations in
// section 3, each contributor grants you a non-exclusive, worldwide, royalty-free license under its licensed
// patents to make, have made, use, sell, offer for sale, import, and/or otherwise dispose of its contribution
// in the software or derivative works of the contribution in the software.
//
// 3.Conditions and Limitations
// (A) No Trademark License- This license does not grant you rights to use any contributors' name, logo, or trademarks.
// (B) If you bring a patent claim against any contributor over patents that you claim are infringed by the software, your
// patent license from such contributor to the software ends automatically.
// (C) If you distribute any portion of the software, you must retain all copyright, patent, trademark, and attribution
// notices that are present in the software.
// (D) If you distribute any portion of the software in source code form, you may do so only under this license by including
// a complete copy of this license with your distribution. If you distribute any portion of the software in compiled or
// object code form, you may only do so under a license that complies with this license.
// (E) The software is licensed "as-is." You bear the risk of using it. The contributors give no express warranties, guarantees,
// or conditions. You may have additional consumer rights under your local laws which this license cannot change. To the
// extent permitted under your local laws, the contributors exclude the implied warranties of merchantability, fitness for a
// particular purpose and non-infringement.
#endregion // License
namespace ANX.Framework.NonXNA
{
public enum AddInType
{
Unknown,
RenderSystem,
InputSystem,
SoundSystem
}
}

View File

@ -31,8 +31,8 @@ using System.Runtime.InteropServices;
// //
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
[assembly: AssemblyVersion("0.4.32.*")] [assembly: AssemblyVersion("0.4.33.*")]
[assembly: AssemblyFileVersion("0.4.32.0")] [assembly: AssemblyFileVersion("0.4.33.0")]
[assembly:InternalsVisibleTo("ANX.Framework.Windows.DX10")] [assembly:InternalsVisibleTo("ANX.Framework.Windows.DX10")]
[assembly:InternalsVisibleTo("ANX.RenderSystem.Windows.DX11")] [assembly:InternalsVisibleTo("ANX.RenderSystem.Windows.DX11")]

View File

@ -98,6 +98,7 @@ namespace ANX.InputSystem.OpenTK
get get
{ {
logger.Debug("returning a new OpenTK GamePad device"); logger.Debug("returning a new OpenTK GamePad device");
AddInSystemFactory.Instance.PreventInputSystemChange();
return new GamePad(); return new GamePad();
} }
} }
@ -107,6 +108,7 @@ namespace ANX.InputSystem.OpenTK
get get
{ {
logger.Debug("returning a new OpenTK Mouse device"); logger.Debug("returning a new OpenTK Mouse device");
AddInSystemFactory.Instance.PreventInputSystemChange();
return new Mouse(); return new Mouse();
} }
} }
@ -116,6 +118,7 @@ namespace ANX.InputSystem.OpenTK
get get
{ {
logger.Debug("returning a new OpenTK Keyboard device"); logger.Debug("returning a new OpenTK Keyboard device");
AddInSystemFactory.Instance.PreventInputSystemChange();
return new Keyboard(); return new Keyboard();
} }
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.1.0")] [assembly: AssemblyVersion("0.0.2.0")]
[assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyFileVersion("0.0.2.0")]

View File

@ -60,23 +60,39 @@ namespace ANX.InputSystem.Recording
{ {
public IGamePad GamePad public IGamePad GamePad
{ {
get { return new RecordingGamePad(); } get
{
AddInSystemFactory.Instance.PreventInputSystemChange();
return new RecordingGamePad();
}
} }
public IMouse Mouse public IMouse Mouse
{ {
get { return new RecordingMouse(); } get
{
AddInSystemFactory.Instance.PreventInputSystemChange();
return new RecordingMouse();
}
} }
public IKeyboard Keyboard public IKeyboard Keyboard
{ {
get { return new RecordingKeyboard(); } get
{
AddInSystemFactory.Instance.PreventInputSystemChange();
return new RecordingKeyboard();
}
} }
#if XNAEXT #if XNAEXT
public IMotionSensingDevice MotionSensingDevice public IMotionSensingDevice MotionSensingDevice
{ {
get { return new RecordingMotionSensingDevice(); } get
{
AddInSystemFactory.Instance.PreventInputSystemChange();
return new RecordingMotionSensingDevice();
}
} }
#endif #endif

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.1.0")] [assembly: AssemblyVersion("0.0.2.0")]
[assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyFileVersion("0.0.2.0")]

View File

@ -95,7 +95,11 @@ namespace ANX.InputSystem.Windows.Kinect
public IMotionSensingDevice MotionSensingDevice public IMotionSensingDevice MotionSensingDevice
{ {
get { return new Kinect(); } get
{
AddInSystemFactory.Instance.PreventInputSystemChange();
return new Kinect();
}
} }
public IKeyboard Keyboard public IKeyboard Keyboard

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.3.0")] [assembly: AssemblyVersion("0.5.4.0")]
[assembly: AssemblyFileVersion("0.5.3.0")] [assembly: AssemblyFileVersion("0.5.4.0")]

View File

@ -96,6 +96,7 @@ namespace ANX.InputSystem.Windows.XInput
get get
{ {
logger.Debug("returning a new XInput GamePad device"); logger.Debug("returning a new XInput GamePad device");
AddInSystemFactory.Instance.PreventInputSystemChange();
return new GamePad(); return new GamePad();
} }
} }
@ -105,6 +106,7 @@ namespace ANX.InputSystem.Windows.XInput
get get
{ {
logger.Debug("returning a new XInput Mouse device"); logger.Debug("returning a new XInput Mouse device");
AddInSystemFactory.Instance.PreventInputSystemChange();
return new Mouse(); return new Mouse();
} }
} }
@ -114,6 +116,7 @@ namespace ANX.InputSystem.Windows.XInput
get get
{ {
logger.Debug("returning a new XInput Keyboard device"); logger.Debug("returning a new XInput Keyboard device");
AddInSystemFactory.Instance.PreventInputSystemChange();
return new Keyboard(); return new Keyboard();
} }
} }
@ -121,7 +124,7 @@ namespace ANX.InputSystem.Windows.XInput
#if XNAEXT #if XNAEXT
public IMotionSensingDevice MotionSensingDevice public IMotionSensingDevice MotionSensingDevice
{ {
get {return null; } get { return null; }
} }
#endif #endif
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.6.2.0")] [assembly: AssemblyVersion("0.6.3.0")]
[assembly: AssemblyFileVersion("0.6.2.0")] [assembly: AssemblyFileVersion("0.6.3.0")]

View File

@ -84,26 +84,32 @@ namespace ANX.Framework.Windows.DX10
public GameHost CreateGameHost(Game game) public GameHost CreateGameHost(Game game)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new WindowsGameHost(game); return new WindowsGameHost(game);
} }
public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters) public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new GraphicsDeviceWindowsDX10(presentationParameters); return new GraphicsDeviceWindowsDX10(presentationParameters);
} }
public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new IndexBuffer_DX10(graphics, size, indexCount, usage); return new IndexBuffer_DX10(graphics, size, indexCount, usage);
} }
public INativeBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) public INativeBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage); return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage);
} }
public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode); Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode);
return effect; return effect;
@ -111,6 +117,8 @@ namespace ANX.Framework.Windows.DX10
public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, System.IO.Stream byteCode) public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, System.IO.Stream byteCode)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, byteCode); Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, byteCode);
return effect; return effect;
@ -118,6 +126,8 @@ namespace ANX.Framework.Windows.DX10
public Texture2D CreateTexture(GraphicsDevice graphics, string fileName) public Texture2D CreateTexture(GraphicsDevice graphics, string fileName)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
//TODO: implement //TODO: implement
throw new NotImplementedException(); throw new NotImplementedException();
@ -131,26 +141,32 @@ namespace ANX.Framework.Windows.DX10
public INativeBlendState CreateBlendState() public INativeBlendState CreateBlendState()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new BlendState_DX10(); return new BlendState_DX10();
} }
public INativeRasterizerState CreateRasterizerState() public INativeRasterizerState CreateRasterizerState()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new RasterizerState_DX10(); return new RasterizerState_DX10();
} }
public INativeDepthStencilState CreateDepthStencilState() public INativeDepthStencilState CreateDepthStencilState()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new DepthStencilState_DX10(); return new DepthStencilState_DX10();
} }
public INativeSamplerState CreateSamplerState() public INativeSamplerState CreateSamplerState()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new SamplerState_DX10(); return new SamplerState_DX10();
} }
public byte[] GetShaderByteCode(PreDefinedShader type) public byte[] GetShaderByteCode(PreDefinedShader type)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
if (type == PreDefinedShader.SpriteBatch) if (type == PreDefinedShader.SpriteBatch)
{ {
return ShaderByteCode.SpriteBatchByteCode; return ShaderByteCode.SpriteBatchByteCode;
@ -187,6 +203,8 @@ namespace ANX.Framework.Windows.DX10
public System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter> GetAdapterList() public System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
SharpDX.DXGI.Factory factory = new Factory(); SharpDX.DXGI.Factory factory = new Factory();
List<GraphicsAdapter> adapterList = new List<GraphicsAdapter>(); List<GraphicsAdapter> adapterList = new List<GraphicsAdapter>();
@ -239,11 +257,15 @@ namespace ANX.Framework.Windows.DX10
public INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount) public INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new Texture2D_DX10(graphics, width, height, surfaceFormat, mipCount); return new Texture2D_DX10(graphics, width, height, surfaceFormat, mipCount);
} }
public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage) public INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new RenderTarget2D_DX10(graphics, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage); return new RenderTarget2D_DX10(graphics, width, height, mipMap, preferredFormat, preferredDepthFormat, preferredMultiSampleCount, usage);
} }
} }

View File

@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.7.10.0")] [assembly: AssemblyVersion("0.7.11.0")]
[assembly: AssemblyFileVersion("0.7.10.0")] [assembly: AssemblyFileVersion("0.7.11.0")]
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")] [assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]

View File

@ -106,20 +106,25 @@ namespace ANX.Framework.Windows.GL3
public GameHost CreateGameHost(Game game) public GameHost CreateGameHost(Game game)
{ {
logger.Info("creating OpenGL3 GameHost"); logger.Info("creating OpenGL3 GameHost");
return new WindowsGameHost(game); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new WindowsGameHost(game);
} }
#endregion #endregion
#region CreateEffect #region CreateEffect
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode) public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new EffectGL3(managedEffect, byteCode); return new EffectGL3(managedEffect, byteCode);
} }
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect,
Stream vertexShaderByteCode, Stream pixelShaderByteCode) Stream vertexShaderByteCode, Stream pixelShaderByteCode)
{ {
return new EffectGL3(managedEffect, vertexShaderByteCode, pixelShaderByteCode); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new EffectGL3(managedEffect, vertexShaderByteCode, pixelShaderByteCode);
} }
#endregion #endregion
@ -127,7 +132,8 @@ namespace ANX.Framework.Windows.GL3
INativeGraphicsDevice IRenderSystemCreator.CreateGraphicsDevice( INativeGraphicsDevice IRenderSystemCreator.CreateGraphicsDevice(
PresentationParameters presentationParameters) PresentationParameters presentationParameters)
{ {
return new GraphicsDeviceWindowsGL3(presentationParameters); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new GraphicsDeviceWindowsGL3(presentationParameters);
} }
#endregion #endregion
@ -144,7 +150,8 @@ namespace ANX.Framework.Windows.GL3
public INativeTexture2D CreateTexture(GraphicsDevice graphics, public INativeTexture2D CreateTexture(GraphicsDevice graphics,
SurfaceFormat surfaceFormat, int width, int height, int mipCount) SurfaceFormat surfaceFormat, int width, int height, int mipCount)
{ {
return new Texture2DGL3(surfaceFormat, width, height, mipCount); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new Texture2DGL3(surfaceFormat, width, height, mipCount);
} }
#endregion #endregion
@ -161,7 +168,8 @@ namespace ANX.Framework.Windows.GL3
public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics, public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics,
IndexElementSize size, int indexCount, BufferUsage usage) IndexElementSize size, int indexCount, BufferUsage usage)
{ {
return new IndexBufferGL3(size, indexCount, usage); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new IndexBufferGL3(size, indexCount, usage);
} }
#endregion #endregion
@ -179,7 +187,8 @@ namespace ANX.Framework.Windows.GL3
VertexDeclaration vertexDeclaration, int vertexCount, VertexDeclaration vertexDeclaration, int vertexCount,
BufferUsage usage) BufferUsage usage)
{ {
return new VertexBufferGL3(vertexDeclaration, vertexCount, usage); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new VertexBufferGL3(vertexDeclaration, vertexCount, usage);
} }
#endregion #endregion
@ -190,7 +199,8 @@ namespace ANX.Framework.Windows.GL3
/// <returns>Native Blend State.</returns> /// <returns>Native Blend State.</returns>
public INativeBlendState CreateBlendState() public INativeBlendState CreateBlendState()
{ {
return new BlendStateGL3(); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new BlendStateGL3();
} }
#endregion #endregion
@ -201,7 +211,8 @@ namespace ANX.Framework.Windows.GL3
/// <returns>Native Rasterizer State.</returns> /// <returns>Native Rasterizer State.</returns>
public INativeRasterizerState CreateRasterizerState() public INativeRasterizerState CreateRasterizerState()
{ {
return new RasterizerStateGL3(); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new RasterizerStateGL3();
} }
#endregion #endregion
@ -212,7 +223,8 @@ namespace ANX.Framework.Windows.GL3
/// <returns>Native Depth Stencil State.</returns> /// <returns>Native Depth Stencil State.</returns>
public INativeDepthStencilState CreateDepthStencilState() public INativeDepthStencilState CreateDepthStencilState()
{ {
return new DepthStencilStateGL3(); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new DepthStencilStateGL3();
} }
#endregion #endregion
@ -223,7 +235,8 @@ namespace ANX.Framework.Windows.GL3
/// <returns>Native Sampler State.</returns> /// <returns>Native Sampler State.</returns>
public INativeSamplerState CreateSamplerState() public INativeSamplerState CreateSamplerState()
{ {
return new SamplerStateGL3(); AddInSystemFactory.Instance.PreventRenderSystemChange();
return new SamplerStateGL3();
} }
#endregion #endregion
@ -235,7 +248,9 @@ namespace ANX.Framework.Windows.GL3
/// <returns>Byte code of the shader.</returns> /// <returns>Byte code of the shader.</returns>
public byte[] GetShaderByteCode(PreDefinedShader type) public byte[] GetShaderByteCode(PreDefinedShader type)
{ {
if (type == PreDefinedShader.SpriteBatch) AddInSystemFactory.Instance.PreventRenderSystemChange();
if (type == PreDefinedShader.SpriteBatch)
{ {
return ShaderByteCode.SpriteBatchByteCode; return ShaderByteCode.SpriteBatchByteCode;
} }
@ -271,7 +286,9 @@ namespace ANX.Framework.Windows.GL3
/// <returns>List of graphics adapters.</returns> /// <returns>List of graphics adapters.</returns>
public ReadOnlyCollection<GraphicsAdapter> GetAdapterList() public ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
{ {
var result = new List<GraphicsAdapter>(); AddInSystemFactory.Instance.PreventRenderSystemChange();
var result = new List<GraphicsAdapter>();
foreach (DisplayDevice device in DisplayDevice.AvailableDisplays) foreach (DisplayDevice device in DisplayDevice.AvailableDisplays)
{ {
var displayModeCollection = new DisplayModeCollection(); var displayModeCollection = new DisplayModeCollection();
@ -330,7 +347,8 @@ namespace ANX.Framework.Windows.GL3
DepthFormat preferredDepthFormat, int preferredMultiSampleCount, DepthFormat preferredDepthFormat, int preferredMultiSampleCount,
RenderTargetUsage usage) RenderTargetUsage usage)
{ {
return new RenderTarget2DGL3(width, height, mipMap, preferredFormat, AddInSystemFactory.Instance.PreventRenderSystemChange();
return new RenderTarget2DGL3(width, height, mipMap, preferredFormat,
preferredDepthFormat, preferredMultiSampleCount, usage); preferredDepthFormat, preferredMultiSampleCount, usage);
} }
#endregion #endregion

View File

@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.7.0")] [assembly: AssemblyVersion("0.5.8.0")]
[assembly: AssemblyFileVersion("0.5.7.0")] [assembly: AssemblyFileVersion("0.5.8.0")]
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")] [assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]

View File

@ -89,53 +89,62 @@ namespace ANX.RenderSystem.Windows.DX11
public GameHost CreateGameHost(Game game) public GameHost CreateGameHost(Game game)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
//return new WindowsGameHost(game); //return new WindowsGameHost(game);
} }
public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters) public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
//return new GraphicsDeviceWindowsDX11_1(presentationParameters); //return new GraphicsDeviceWindowsDX11_1(presentationParameters);
} }
public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage) public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
//return new IndexBuffer_DX 11(graphics, size, indexCount, usage); //return new IndexBuffer_DX 11(graphics, size, indexCount, usage);
} }
public INativeBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage) public INativeBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
return new VertexBuffer_DX11(graphics, vertexDeclaration, vertexCount, usage); return new VertexBuffer_DX11(graphics, vertexDeclaration, vertexCount, usage);
} }
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect effect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) public INativeEffect CreateEffect(GraphicsDevice graphics, Effect effect, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
//return new Effect_DX11(graphics, vertexShaderByteCode, pixelShaderByteCode); //return new Effect_DX11(graphics, vertexShaderByteCode, pixelShaderByteCode);
} }
public INativeEffect CreateEffect(GraphicsDevice graphics, Effect effect, System.IO.Stream byteCode) public INativeEffect CreateEffect(GraphicsDevice graphics, Effect effect, System.IO.Stream byteCode)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
//return new Effect_DX11(graphics, byteCode); //return new Effect_DX11(graphics, byteCode);
} }
public Texture2D CreateTexture(GraphicsDevice graphics, string fileName) public Texture2D CreateTexture(GraphicsDevice graphics, string fileName)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
//GraphicsDeviceWindowsDX10 graphicsDX10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
//SharpDX.Direct3D10.Texture2D nativeTexture = SharpDX.Direct3D10.Texture2D.FromFile<SharpDX.Direct3D10.Texture2D>(graphicsDX10.NativeDevice, fileName);
//Texture2D_DX10 texture = new Texture2D_DX10(graphics, nativeTexture.Description.Width, nativeTexture.Description.Height);
//texture.NativeTexture = nativeTexture;
//return texture;
} }
public Texture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount, byte[] colorData) public Texture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount, byte[] colorData)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
/* /*
@ -205,36 +214,48 @@ namespace ANX.RenderSystem.Windows.DX11
public INativeBlendState CreateBlendState() public INativeBlendState CreateBlendState()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
} }
public INativeRasterizerState CreateRasterizerState() public INativeRasterizerState CreateRasterizerState()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
} }
public INativeDepthStencilState CreateDepthStencilState() public INativeDepthStencilState CreateDepthStencilState()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
} }
public INativeSamplerState CreateSamplerState() public INativeSamplerState CreateSamplerState()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
} }
public byte[] GetShaderByteCode(PreDefinedShader type) public byte[] GetShaderByteCode(PreDefinedShader type)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
} }
public System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter> GetAdapterList() public System.Collections.ObjectModel.ReadOnlyCollection<GraphicsAdapter> GetAdapterList()
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
} }
@ -247,6 +268,8 @@ namespace ANX.RenderSystem.Windows.DX11
public Framework.NonXNA.RenderSystem.INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage) public Framework.NonXNA.RenderSystem.INativeRenderTarget2D CreateRenderTarget(GraphicsDevice graphics, int width, int height, bool mipMap, SurfaceFormat preferredFormat, DepthFormat preferredDepthFormat, int preferredMultiSampleCount, RenderTargetUsage usage)
{ {
AddInSystemFactory.Instance.PreventRenderSystemChange();
throw new NotImplementedException(); throw new NotImplementedException();
} }
} }

View File

@ -29,5 +29,5 @@ using System.Runtime.InteropServices;
// Buildnummer // Buildnummer
// Revision // Revision
// //
[assembly: AssemblyVersion("0.1.2.0")] [assembly: AssemblyVersion("0.1.3.0")]
[assembly: AssemblyFileVersion("0.1.2.0")] [assembly: AssemblyFileVersion("0.1.3.0")]

View File

@ -17,7 +17,6 @@ namespace Kinect
MotionSensingDeviceState kinectState; MotionSensingDeviceState kinectState;
public Game1() public Game1()
: base("DirectX10", "Kinect")
{ {
graphics = new GraphicsDeviceManager(this); graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "SampleContent"; Content.RootDirectory = "SampleContent";

View File

@ -1,4 +1,5 @@
using System; using System;
using ANX.Framework.NonXNA;
namespace Kinect namespace Kinect
{ {
@ -10,6 +11,8 @@ namespace Kinect
/// </summary> /// </summary>
static void Main(string[] args) static void Main(string[] args)
{ {
AddInSystemFactory.Instance.PreferredInputSystem = "Kinect";
using (Game1 game = new Game1()) using (Game1 game = new Game1())
{ {
game.Run(); game.Run();

View File

@ -77,7 +77,6 @@ namespace WindowsGame1
private int lastFps = 60; private int lastFps = 60;
public Game1() public Game1()
: base("DirectX10")
{ {
graphics = new GraphicsDeviceManager(this); graphics = new GraphicsDeviceManager(this);
graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings); graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);

View File

@ -65,7 +65,6 @@ namespace TextRendering
SpriteFont debugFont; SpriteFont debugFont;
public Game1() public Game1()
: base("OpenGL3")
{ {
graphics = new GraphicsDeviceManager(this); graphics = new GraphicsDeviceManager(this);
graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings); graphics.PreparingDeviceSettings += new EventHandler<PreparingDeviceSettingsEventArgs>(graphics_PreparingDeviceSettings);

View File

@ -1,4 +1,5 @@
using System; using System;
using ANX.Framework.NonXNA;
namespace TextRendering namespace TextRendering
{ {
@ -10,6 +11,8 @@ namespace TextRendering
/// </summary> /// </summary>
static void Main(string[] args) static void Main(string[] args)
{ {
AddInSystemFactory.Instance.PreferredRenderSystem = "OpenGL3";
using (Game1 game = new Game1()) using (Game1 game = new Game1())
{ {
game.Run(); game.Run();

View File

@ -64,8 +64,7 @@ namespace WindowsGame1
GraphicsDeviceManager graphics; GraphicsDeviceManager graphics;
SpriteBatch spriteBatch; SpriteBatch spriteBatch;
public Game1(string renderSystem, string inputSystem, string audioSystem) public Game1()
: base(renderSystem, inputSystem, audioSystem)
{ {
graphics = new GraphicsDeviceManager(this); graphics = new GraphicsDeviceManager(this);
Content.RootDirectory = "SampleContent"; Content.RootDirectory = "SampleContent";

View File

@ -19,7 +19,11 @@ namespace WindowsGame1
AddInSelector selector = new AddInSelector(); AddInSelector selector = new AddInSelector();
if (selector.ShowDialog() == System.Windows.Forms.DialogResult.OK) if (selector.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{ {
using (Game1 game = new Game1(selector.cbRenderSystem.Text, selector.cbInputSystems.CheckedItems[0].ToString(), selector.cbAudioSystem.Text)) AddInSystemFactory.Instance.PreferredRenderSystem = selector.cbRenderSystem.Text;
AddInSystemFactory.Instance.PreferredSoundSystem = selector.cbAudioSystem.Text;
AddInSystemFactory.Instance.PreferredInputSystem = selector.cbInputSystems.CheckedItems[0].ToString();
using (Game1 game = new Game1())
{ {
game.Run(); game.Run();
} }

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.1.0")] [assembly: AssemblyVersion("0.0.2.0")]
[assembly: AssemblyFileVersion("0.0.1.0")] [assembly: AssemblyFileVersion("0.0.2.0")]

View File

@ -32,5 +32,5 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben: // übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")] // [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.0.2.0")] [assembly: AssemblyVersion("0.0.3.0")]
[assembly: AssemblyFileVersion("0.0.2.0")] [assembly: AssemblyFileVersion("0.0.3.0")]