diff --git a/InputSystems/ANX.InputSystem.Windows.Kinect/ANX.InputSystem.Windows.Kinect.csproj b/InputSystems/ANX.InputSystem.Windows.Kinect/ANX.InputSystem.Windows.Kinect.csproj
new file mode 100644
index 00000000..031bea8c
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.Kinect/ANX.InputSystem.Windows.Kinect.csproj
@@ -0,0 +1,92 @@
+
+
+
+ Debug
+ x86
+ 8.0.30703
+ 2.0
+ {E5D69E75-D77C-493F-BBDA-6F9E73B82549}
+ Library
+ Properties
+ ANX.InputSystem.Windows.Kinect
+ ANX.InputSystem.Windows.Kinect
+ v4.0
+ Client
+ 512
+
+
+ x86
+ true
+ full
+ false
+ ..\..\bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ x86
+ pdbonly
+ true
+ ..\..\bin\Debug\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+ False
+ ..\lib\KinectSDK\Microsoft.Research.Kinect.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ResXFileCodeGenerator
+ Resources.Designer.cs
+ Designer
+
+
+ True
+ Resources.resx
+
+
+ SettingsSingleFileGenerator
+ Settings.Designer.cs
+
+
+ True
+ Settings.settings
+ True
+
+
+
+
+ {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}
+ ANX.Framework
+
+
+
+
+
\ No newline at end of file
diff --git a/InputSystems/ANX.InputSystem.Windows.Kinect/Creator.cs b/InputSystems/ANX.InputSystem.Windows.Kinect/Creator.cs
new file mode 100644
index 00000000..12dbff43
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.Kinect/Creator.cs
@@ -0,0 +1,95 @@
+#region Using Statements
+using System;
+using ANX.Framework.Input;
+using ANX.Framework.NonXNA;
+
+#endregion // Using Statements
+
+#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.InputSystem.Windows.Kinect
+{
+ public class Creator : IInputSystemCreator
+ {
+ public string Name
+ {
+ get { return "Kinect"; }
+ }
+
+ public void RegisterCreator(AddInSystemFactory factory)
+ {
+ factory.AddCreator(this);
+ }
+
+ #region IInputSystemCreator Member
+
+ public IGamePad GamePad
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public IMouse Mouse
+ {
+ get { return null; }
+ }
+
+ public IMotionSensingDevice MotionSensingDevice
+ {
+ get { return new Kinect(); }
+ }
+
+ public IKeyboard Keyboard
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ #endregion
+
+ }
+}
diff --git a/InputSystems/ANX.InputSystem.Windows.Kinect/Kinect.cs b/InputSystems/ANX.InputSystem.Windows.Kinect/Kinect.cs
new file mode 100644
index 00000000..ee2a563e
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.Kinect/Kinect.cs
@@ -0,0 +1,212 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
+using Microsoft.Research.Kinect.Nui;
+using ANX.Framework.Input.MotionSensing;
+
+#endregion // Using Statements
+
+#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.
+//
+// 2.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.InputSystem.Windows.Kinect
+{
+
+ public class Kinect : IMotionSensingDevice
+ {
+ #region Private Members
+ private Runtime pNui;
+ private Vector3[] cache;
+ private GraphicsDevice graphicsDevice;
+ private Texture2D rgb;
+ private Texture2D depth;
+
+ #endregion // Private Members
+
+ public Kinect()
+ {
+ pNui = new Runtime();
+ pNui.Initialize(RuntimeOptions.UseDepthAndPlayerIndex | RuntimeOptions.UseSkeletalTracking | RuntimeOptions.UseColor);
+ pNui.SkeletonEngine.TransformSmooth = true;
+
+
+
+ this.cache = new Vector3[21];
+ //init for the first time
+ for (int i = 0; i < 21; ++i)
+ {
+ this.cache[i]=Vector3.Zero;
+ }
+ //Added parameters which where used in our Kinect project
+ var parameters = new TransformSmoothParameters
+ {
+ Smoothing = 0.5f,
+ Correction = 0.2f,
+ Prediction = 0.04f,
+ JitterRadius = 0.9f,
+ MaxDeviationRadius = 0.9f
+ };
+
+ pNui.SkeletonEngine.SmoothParameters = parameters;
+
+ try
+ {
+ pNui.VideoStream.Open(ImageStreamType.Video, 2, ImageResolution.Resolution640x480, ImageType.Color);
+ pNui.DepthStream.Open(ImageStreamType.Depth, 2, ImageResolution.Resolution320x240, ImageType.DepthAndPlayerIndex);
+ }
+ catch (InvalidOperationException)
+ {
+ // Display error message; omitted for space return;
+ }
+ //lastTime = DateTime.Now;
+
+ pNui.SkeletonFrameReady += new EventHandler(pNui_SkeletonFrameReady);
+ pNui.DepthFrameReady += new EventHandler(pNui_DepthFrameReady);
+ pNui.VideoFrameReady += new EventHandler(pNui_VideoFrameReady);
+
+ // move down all the way
+ pNui.NuiCamera.ElevationAngle = -15;
+
+ System.Threading.Thread.Sleep(1500);
+
+ // move up all the way
+ pNui.NuiCamera.ElevationAngle = 20;
+ }
+
+ void pNui_VideoFrameReady(object sender, ImageFrameReadyEventArgs e)
+ {
+ if (this.graphicsDevice != null)
+ {
+ if (this.rgb == null)
+ {
+ this.rgb = new Texture2D(this.graphicsDevice, e.ImageFrame.Image.Width, e.ImageFrame.Image.Height);
+ }
+
+ //TODO: this works only if the image is in RGBA32 Format. Other formats does need a conversion first.
+ this.rgb.SetData(e.ImageFrame.Image.Bits);
+ }
+ }
+
+ void pNui_DepthFrameReady(object sender, ImageFrameReadyEventArgs e)
+ {
+ if (this.graphicsDevice != null)
+ {
+ if (this.depth == null)
+ {
+ this.depth = new Texture2D(this.graphicsDevice, e.ImageFrame.Image.Width, e.ImageFrame.Image.Height);
+ }
+
+ //TODO: this works only if the image is in RGBA32 Format. Other formats does need a conversion first.
+ //TODO: special surface format: this.depth.SetData(e.ImageFrame.Image.Bits);
+ }
+ }
+
+ private void pNui_SkeletonFrameReady(object sender, SkeletonFrameReadyEventArgs e)
+ {
+ foreach (SkeletonData data in e.SkeletonFrame.Skeletons)
+ {
+ //Tracked that defines whether a skeleton is 'tracked' or not.
+ //The untracked skeletons only give their position.
+ if (SkeletonTrackingState.Tracked != data.TrackingState) continue;
+
+ //Each joint has a Position property that is defined by a Vector4: (x, y, z, w).
+ //The first three attributes define the position in camera space.
+ //The last attribute (w)
+ //gives the quality level (between 0 and 2) of the
+ foreach (Joint joint in data.Joints)
+ {
+ if (joint.Position.W < 0.6f) return;// Quality check
+ cache[(int)joint.ID] = toVector3(joint.Position);
+ }
+ }
+ }
+
+ private Vector3 toVector3(Vector vector)
+ {
+ //evtl -z
+ return new Vector3(vector.X, vector.Y, vector.Z);
+ }
+
+ public MotionSensingDeviceState GetState()
+ {
+ return new MotionSensingDeviceState(rgb, depth, cache[0], cache[1], cache[2], cache[3], cache[4], cache[5], cache[6], cache[7], cache[8], cache[9], cache[10],cache[11], cache[12], cache[13], cache[14], cache[15], cache[16], cache[17], cache[18], cache[19], cache[20]);
+ }
+
+
+
+ public GraphicsDevice GraphicsDevice
+ {
+ get
+ {
+ return graphicsDevice;
+ }
+ set
+ {
+ graphicsDevice = value;
+ }
+ }
+
+ public MotionSensingDeviceType DeviceType
+ {
+ get { return MotionSensingDeviceType.Kinect; }
+ }
+
+ public void Dispose()
+ {
+ if (pNui != null)
+ {
+ pNui.Uninitialize();
+ pNui = null;
+ }
+ }
+ }
+}
diff --git a/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/AssemblyInfo.cs b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..19406fec
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("ANX.InputSystem.Windows.Kinect")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("ANX.Framework Team")]
+[assembly: AssemblyProduct("ANX.InputSystem.Windows.Kinect")]
+[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("bcca5303-c3a4-4dba-a408-0d2da515e7c2")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("0.5.2.0")]
+[assembly: AssemblyFileVersion("0.5.2.0")]
diff --git a/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Resources.Designer.cs b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Resources.Designer.cs
new file mode 100644
index 00000000..6099e6bd
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Resources.Designer.cs
@@ -0,0 +1,71 @@
+//------------------------------------------------------------------------------
+//
+// Dieser Code wurde von einem Tool generiert.
+// Laufzeitversion:4.0.30319.239
+//
+// Änderungen an dieser Datei können fehlerhaftes Verhalten verursachen und gehen verloren, wenn
+// der Code neu generiert wird.
+//
+//------------------------------------------------------------------------------
+
+namespace ANX.InputSystem.Windows.Kinect.Properties
+{
+
+
+ ///
+ /// Eine stark typisierte Ressourcenklasse zum Suchen von lokalisierten Zeichenfolgen usw.
+ ///
+ // Diese Klasse wurde von der StronglyTypedResourceBuilder-Klasse
+ // über ein Tool wie ResGen oder Visual Studio automatisch generiert.
+ // Um einen Member hinzuzufügen oder zu entfernen, bearbeiten Sie die .ResX-Datei und führen dann ResGen
+ // mit der Option /str erneut aus, oder erstellen Sie Ihr VS-Projekt neu.
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
+ [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ internal class Resources
+ {
+
+ private static global::System.Resources.ResourceManager resourceMan;
+
+ private static global::System.Globalization.CultureInfo resourceCulture;
+
+ [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
+ internal Resources()
+ {
+ }
+
+ ///
+ /// Gibt die zwischengespeicherte ResourceManager-Instanz zurück, die von dieser Klasse verwendet wird.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Resources.ResourceManager ResourceManager
+ {
+ get
+ {
+ if ((resourceMan == null))
+ {
+ global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("ANX.InputSystem.Windows.Kinect.Properties.Resources", typeof(Resources).Assembly);
+ resourceMan = temp;
+ }
+ return resourceMan;
+ }
+ }
+
+ ///
+ /// Überschreibt die CurrentUICulture-Eigenschaft des aktuellen Threads für alle
+ /// Ressourcenlookups, die diese stark typisierte Ressourcenklasse verwenden.
+ ///
+ [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
+ internal static global::System.Globalization.CultureInfo Culture
+ {
+ get
+ {
+ return resourceCulture;
+ }
+ set
+ {
+ resourceCulture = value;
+ }
+ }
+ }
+}
diff --git a/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Resources.resx b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Resources.resx
new file mode 100644
index 00000000..ffecec85
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Resources.resx
@@ -0,0 +1,117 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ text/microsoft-resx
+
+
+ 2.0
+
+
+ System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
+ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
+
+
\ No newline at end of file
diff --git a/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Settings.Designer.cs b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Settings.Designer.cs
new file mode 100644
index 00000000..a82b1e66
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Settings.Designer.cs
@@ -0,0 +1,30 @@
+//------------------------------------------------------------------------------
+//
+// This code was generated by a tool.
+// Runtime Version:4.0.30319.239
+//
+// Changes to this file may cause incorrect behavior and will be lost if
+// the code is regenerated.
+//
+//------------------------------------------------------------------------------
+
+namespace ANX.InputSystem.Windows.Kinect.Properties
+{
+
+
+ [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
+ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "10.0.0.0")]
+ internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
+ {
+
+ private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
+
+ public static Settings Default
+ {
+ get
+ {
+ return defaultInstance;
+ }
+ }
+ }
+}
diff --git a/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Settings.settings b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Settings.settings
new file mode 100644
index 00000000..abf36c5d
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.Kinect/Properties/Settings.settings
@@ -0,0 +1,7 @@
+
+
+
+
+
+
+
diff --git a/InputSystems/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj b/InputSystems/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj
new file mode 100644
index 00000000..603490ce
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.XInput/ANX.InputSystem.Windows.XInput.csproj
@@ -0,0 +1,74 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {60D08399-244F-46A3-91F1-4CFD26D961A3}
+ Library
+ Properties
+ ANX.InputSystem.Windows.XInput
+ ANX.InputSystem.Windows.XInput
+ v4.0
+ 512
+
+
+ true
+ full
+ false
+ ..\..\bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ ..\..\bin\Debug\
+ TRACE
+ prompt
+ 4
+
+
+
+ ..\lib\SharpDX\Bin\SharpDX.dll
+
+
+ ..\lib\SharpDX\Bin\SharpDX.DirectInput.dll
+
+
+ ..\lib\SharpDX\Bin\SharpDX.XInput.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}
+ ANX.Framework
+
+
+
+
+
\ No newline at end of file
diff --git a/InputSystems/ANX.InputSystem.Windows.XInput/Creator.cs b/InputSystems/ANX.InputSystem.Windows.XInput/Creator.cs
new file mode 100644
index 00000000..785a0362
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.XInput/Creator.cs
@@ -0,0 +1,99 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+using System.Runtime.InteropServices;
+using ANX.Framework.NonXNA;
+
+#endregion // Using Statements
+
+#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.InputSystem.Windows.XInput
+{
+ public class Creator : IInputSystemCreator
+ {
+
+
+ public string Name
+ {
+ get { return "XInput"; }
+ }
+
+ public IGamePad GamePad
+ {
+ get { return new GamePad(); }
+ }
+
+ public void RegisterCreator(AddInSystemFactory factory)
+ {
+ factory.AddCreator(this);
+ }
+
+
+
+ public IMouse Mouse
+ {
+ get { return new Mouse(); }
+ }
+
+
+ public IMotionSensingDevice MotionSensingDevice
+ {
+ get {return null; }
+ }
+
+ public IKeyboard Keyboard
+ {
+ get { return new Keyboard(); }
+ }
+
+ }
+}
diff --git a/InputSystems/ANX.InputSystem.Windows.XInput/FormatConverter.cs b/InputSystems/ANX.InputSystem.Windows.XInput/FormatConverter.cs
new file mode 100644
index 00000000..c505e950
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.XInput/FormatConverter.cs
@@ -0,0 +1,112 @@
+#region Using Statements
+using System;
+using ANX.Framework.Input;
+using SharpDX.XInput;
+
+#endregion // Using Statements
+
+#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.InputSystem.Windows.XInput
+{
+ internal class FormatConverter
+ {
+ public static ANX.Framework.Input.Keys Translate(SharpDX.DirectInput.Key key)
+ {
+ //TODO: implement all keys
+ //TODO: test if a array with the mapping which is constructed once is faster
+
+ switch (key)
+ {
+ case SharpDX.DirectInput.Key.A:
+ return Keys.A;
+ case SharpDX.DirectInput.Key.Escape:
+ return Keys.Escape;
+ }
+
+ throw new NotImplementedException();
+ }
+
+ public static KeyboardState Translate(SharpDX.DirectInput.KeyboardState keyboardState)
+ {
+ int keyCount = keyboardState.PressedKeys.Count;
+ Keys[] keys = new Keys[keyCount];
+
+ for (int i = 0; i < keyCount; i++)
+ {
+ keys[i] = Translate(keyboardState.PressedKeys[i]);
+ }
+
+ KeyboardState ks = new KeyboardState(keys);
+
+ return ks;
+ }
+
+ public static Buttons Translate(SharpDX.XInput.GamepadButtonFlags buttons)
+ {
+ Buttons tb = 0;
+
+ tb |= (buttons & GamepadButtonFlags.A) == GamepadButtonFlags.A ? Buttons.A : 0;
+ tb |= (buttons & GamepadButtonFlags.B) == GamepadButtonFlags.B ? Buttons.B : 0;
+ tb |= (buttons & GamepadButtonFlags.Back) == GamepadButtonFlags.Back ? Buttons.Back : 0;
+ tb |= (buttons & GamepadButtonFlags.DPadDown) == GamepadButtonFlags.DPadDown ? Buttons.DPadDown : 0;
+ tb |= (buttons & GamepadButtonFlags.DPadLeft) == GamepadButtonFlags.DPadLeft ? Buttons.DPadLeft : 0;
+ tb |= (buttons & GamepadButtonFlags.DPadRight) == GamepadButtonFlags.DPadRight ? Buttons.DPadRight : 0;
+ tb |= (buttons & GamepadButtonFlags.DPadUp) == GamepadButtonFlags.DPadUp ? Buttons.DPadUp : 0;
+ tb |= (buttons & GamepadButtonFlags.LeftShoulder) == GamepadButtonFlags.LeftShoulder ? Buttons.LeftShoulder : 0;
+ tb |= (buttons & GamepadButtonFlags.LeftThumb) == GamepadButtonFlags.LeftThumb ? Buttons.LeftTrigger : 0;
+ tb |= (buttons & GamepadButtonFlags.RightShoulder) == GamepadButtonFlags.RightShoulder ? Buttons.RightShoulder : 0;
+ tb |= (buttons & GamepadButtonFlags.RightThumb) == GamepadButtonFlags.RightThumb ? Buttons.RightTrigger : 0;
+ tb |= (buttons & GamepadButtonFlags.Start) == GamepadButtonFlags.Start ? Buttons.Start : 0;
+ tb |= (buttons & GamepadButtonFlags.X) == GamepadButtonFlags.X ? Buttons.X : 0;
+ tb |= (buttons & GamepadButtonFlags.Y) == GamepadButtonFlags.Y ? Buttons.Y : 0;
+
+ return tb;
+ }
+ }
+}
diff --git a/InputSystems/ANX.InputSystem.Windows.XInput/GamePad.cs b/InputSystems/ANX.InputSystem.Windows.XInput/GamePad.cs
new file mode 100644
index 00000000..80faf91b
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.XInput/GamePad.cs
@@ -0,0 +1,152 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.IO;
+using System.Runtime.InteropServices;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Input;
+using ANX.Framework;
+using SharpDX.XInput;
+
+#endregion // Using Statements
+
+#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.InputSystem.Windows.XInput
+{
+ public class GamePad : IGamePad
+ {
+ private Controller[] controller;
+
+ public GamePad()
+ {
+ controller = new Controller[4];
+ controller[0] = new Controller(UserIndex.One);
+ controller[1] = new Controller(UserIndex.Two);
+ controller[2] = new Controller(UserIndex.Three);
+ controller[3] = new Controller(UserIndex.Four);
+ }
+ public GamePadCapabilities GetCapabilities(PlayerIndex playerIndex)
+ {
+ Capabilities result;
+ GamePadCapabilities returnres;
+ //SharpDX.XInput.Capabilities = new SharpDX.XInput.Capabilities();
+ try
+ {
+ result = controller[(int)playerIndex].GetCapabilities(DeviceQueryType.Gamepad);
+ returnres = new GamePadCapabilities();
+
+ }
+ catch (Exception)
+ {
+
+ returnres = new GamePadCapabilities();
+ } return returnres;
+ }
+
+ public GamePadState GetState(PlayerIndex playerIndex)
+ {
+ State result;
+ GamePadState returnres;
+ if(controller[(int)playerIndex].IsConnected)
+ {
+ result = controller[(int)playerIndex].GetState();
+ //returnres = new GamePadCapabilities(result.Type,result.Gamepad.Buttons.)
+ returnres = new GamePadState(new Vector2(result.Gamepad.LeftThumbX, result.Gamepad.LeftThumbY), new Vector2(result.Gamepad.RightThumbX, result.Gamepad.RightThumbY), (float)result.Gamepad.LeftTrigger, (float)result.Gamepad.RightTrigger, FormatConverter.Translate(result.Gamepad.Buttons));
+ }
+ else
+ {
+
+ returnres = new GamePadState();
+ }
+
+
+ return returnres;
+ }
+
+ public GamePadState GetState(PlayerIndex playerIndex, GamePadDeadZone deadZoneMode)
+ {
+ throw new NotImplementedException();
+ }
+
+ public bool SetVibration(PlayerIndex playerIndex, float leftMotor, float rightMotor)
+ {
+ short left;
+ short right;
+ if (Math.Abs(leftMotor)>1)
+ {
+ left = 1;
+ }
+ else
+ {
+ left = Convert.ToInt16(Math.Abs(leftMotor) * short.MaxValue);
+ }
+ if (Math.Abs(rightMotor) > 1)
+ {
+ right = 1;
+ }
+ else
+ {
+ right = Convert.ToInt16(Math.Abs(rightMotor) * short.MaxValue);
+ }
+
+ if (controller[(int)playerIndex].IsConnected)
+ {
+ Vibration vib = new Vibration();
+ vib.LeftMotorSpeed = left;
+ vib.RightMotorSpeed = right;
+ controller[(int)playerIndex].SetVibration(vib);
+ return true;
+ }
+ return false;
+
+ }
+ }
+}
diff --git a/InputSystems/ANX.InputSystem.Windows.XInput/Keyboard.cs b/InputSystems/ANX.InputSystem.Windows.XInput/Keyboard.cs
new file mode 100644
index 00000000..0417e917
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.XInput/Keyboard.cs
@@ -0,0 +1,127 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.InputSystem;
+using ANX.Framework.NonXNA;
+using SharpDX.DirectInput;
+using DXKeyboard=SharpDX.DirectInput.Keyboard;
+#endregion // Using Statements
+
+#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.InputSystem.Windows.XInput
+{
+ public class Keyboard : IKeyboard
+ {
+ #region Private Members
+ private DirectInput directInput;
+ private DXKeyboard nativeKeyboard;
+ private KeyboardState nativeState;
+
+ #endregion // Private Members
+
+ public IntPtr WindowHandle
+ {
+ get;
+ set;
+ }
+
+ public Keyboard()
+ {
+ this.nativeState = new KeyboardState();
+ }
+
+ public Framework.Input.KeyboardState GetState(Framework.PlayerIndex playerIndex)
+ {
+ //TODO: prevent new
+
+ // only available on XBox, behaviour regarding MSDN: empty keystate
+ return new Framework.Input.KeyboardState();
+ }
+
+ public Framework.Input.KeyboardState GetState()
+ {
+ if (this.nativeKeyboard == null && this.WindowHandle != null && this.WindowHandle != IntPtr.Zero)
+ {
+ this.directInput = new DirectInput();
+ this.nativeKeyboard = new DXKeyboard(this.directInput);
+ this.nativeKeyboard.SetCooperativeLevel(this.WindowHandle, CooperativeLevel.NonExclusive | CooperativeLevel.Background);
+ this.nativeKeyboard.Acquire();
+ }
+
+ if (this.nativeKeyboard != null)
+ {
+ nativeKeyboard.GetCurrentState(ref this.nativeState);
+ if (this.nativeState.PressedKeys.Count > 0)
+ {
+ return FormatConverter.Translate(this.nativeState);
+ }
+ }
+
+ return new Framework.Input.KeyboardState();
+ }
+
+ public void Dispose()
+ {
+ if (this.nativeKeyboard != null)
+ {
+ this.nativeKeyboard.Unacquire();
+ this.nativeKeyboard.Dispose();
+ this.nativeKeyboard = null;
+ }
+
+ if (this.directInput != null)
+ {
+ this.directInput.Dispose();
+ this.directInput = null;
+ }
+ }
+ }
+}
diff --git a/InputSystems/ANX.InputSystem.Windows.XInput/Mouse.cs b/InputSystems/ANX.InputSystem.Windows.XInput/Mouse.cs
new file mode 100644
index 00000000..298e4d63
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.XInput/Mouse.cs
@@ -0,0 +1,130 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Input;
+using SharpDX.DirectInput;
+using System.Runtime.InteropServices;
+using ANX.Framework;
+
+#endregion // Using Statements
+
+#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
+
+using MouseX = SharpDX.DirectInput.Mouse;
+
+namespace ANX.InputSystem.Windows.XInput
+{
+ class Mouse : IMouse
+ {
+ [DllImport("user32.dll")]
+ static extern bool GetCursorPos(ref Point lpPoint);
+
+ [DllImport("user32.dll")]
+ static extern void SetCursorPos(int x, int y);
+
+ [DllImport("user32.dll")]
+ static extern bool ScreenToClient(IntPtr hWnd, ref Point lpPoint);
+
+ private DirectInput directInput;
+ private MouseX mouse;
+
+ public IntPtr WindowHandle
+ {
+ get;
+ set;
+ }
+
+ public Mouse()
+ {
+ this.directInput = new DirectInput();
+ this.mouse = new MouseX(this.directInput);
+ this.mouse.Properties.AxisMode = DeviceAxisMode.Absolute;
+ this.mouse.Acquire();
+ }
+
+ public ANX.Framework.Input.MouseState GetState()
+ {
+ var state = this.mouse.GetCurrentState();
+
+ Point cursorPos = new Point();
+ GetCursorPos(ref cursorPos);
+ if (WindowHandle != IntPtr.Zero)
+ {
+ ScreenToClient(WindowHandle, ref cursorPos);
+ }
+ state.X = cursorPos.X;
+ state.Y = cursorPos.Y;
+
+ ButtonState left = new ButtonState();
+ ButtonState middle = new ButtonState();
+ ButtonState right = new ButtonState();
+ ButtonState x1 = new ButtonState();
+ ButtonState x2 = new ButtonState();
+ if(state.Buttons[0]){left=ButtonState.Pressed;}
+ if(state.Buttons[1]){middle=ButtonState.Pressed;}
+ if(state.Buttons[2]){right=ButtonState.Pressed;}
+ if(state.Buttons[3]){x1=ButtonState.Pressed;}
+ if(state.Buttons[4]){x2=ButtonState.Pressed;}
+ return new ANX.Framework.Input.MouseState(state.X,state.Y,state.Z,left,middle,right,x1,x2);
+ }
+
+ public void SetPosition(int x, int y)
+ {
+ Point currentPosition = new Point(x, y);
+ GetCursorPos(ref currentPosition);
+ if (WindowHandle != IntPtr.Zero)
+ {
+ ScreenToClient(WindowHandle, ref currentPosition);
+ }
+ SetCursorPos(currentPosition.X, currentPosition.Y);
+ }
+ }
+}
diff --git a/InputSystems/ANX.InputSystem.Windows.XInput/Properties/AssemblyInfo.cs b/InputSystems/ANX.InputSystem.Windows.XInput/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..d47385bb
--- /dev/null
+++ b/InputSystems/ANX.InputSystem.Windows.XInput/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("ANX.InputSystem.Windows.XInput")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("ANX.Framework Team")]
+[assembly: AssemblyProduct("ANX.InputSystem.Windows.XInput")]
+[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("a9254330-76c5-466a-8239-cbbe11845e76")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("0.6.0.0")]
+[assembly: AssemblyFileVersion("0.6.0.0")]
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/ANX.Framework.Windows.DX10.csproj b/RenderSystems/ANX.Framework.Windows.DX10/ANX.Framework.Windows.DX10.csproj
new file mode 100644
index 00000000..d8a61fcf
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/ANX.Framework.Windows.DX10.csproj
@@ -0,0 +1,101 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {5BE49183-2F6F-4527-AC90-D816911FCF90}
+ Library
+ Properties
+ ANX.Framework.Windows.DX10
+ ANX.Framework.Windows.DX10
+ v4.0
+ 512
+
+
+ true
+ full
+ false
+ ..\..\bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x86
+ true
+
+
+ pdbonly
+ true
+ ..\..\bin\Release\
+ TRACE
+ prompt
+ 4
+ x86
+ true
+
+
+
+ False
+ ..\lib\SharpDX\Bin\SharpDX.dll
+
+
+ False
+ ..\lib\SharpDX\Bin\SharpDX.D3DCompiler.dll
+
+
+ False
+ ..\lib\SharpDX\Bin\SharpDX.Direct3D10.dll
+
+
+ False
+ ..\lib\SharpDX\Bin\SharpDX.DXGI.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}
+ ANX.Framework
+
+
+
+
+ "$(ProjectDir)../../Tools/bin/sscg.exe" ../../../shader/DX10/build.xml
+
+
+
\ No newline at end of file
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/BlendState_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/BlendState_DX10.cs
new file mode 100644
index 00000000..b36dcbc5
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/BlendState_DX10.cs
@@ -0,0 +1,295 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SharpDX.Direct3D10;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class BlendState_DX10 : INativeBlendState
+ {
+ #region Private Members
+ private BlendStateDescription description;
+ private SharpDX.Direct3D10.BlendState nativeBlendState;
+ private bool nativeBlendStateDirty;
+ private SharpDX.Color4 blendFactor;
+ private int multiSampleMask;
+ private bool bound;
+
+ #endregion // Private Members
+
+ public BlendState_DX10()
+ {
+ this.description = new BlendStateDescription();
+
+ for (int i = 0; i < description.IsBlendEnabled.Length; i++)
+ {
+ description.IsBlendEnabled[i] = (i < 4);
+ }
+
+ nativeBlendStateDirty = true;
+ }
+
+ public void Apply(GraphicsDevice graphics)
+ {
+ GraphicsDeviceWindowsDX10 gdx10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
+ SharpDX.Direct3D10.Device device = gdx10.NativeDevice;
+
+ UpdateNativeBlendState(device);
+ this.bound = true;
+
+ device.OutputMerger.SetBlendState(nativeBlendState, this.blendFactor, this.multiSampleMask);
+ }
+
+ public void Release()
+ {
+ this.bound = false;
+ }
+
+ public void Dispose()
+ {
+ if (this.nativeBlendState != null)
+ {
+ this.nativeBlendState.Dispose();
+ this.nativeBlendState = null;
+ }
+ }
+
+ public bool IsBound
+ {
+ get
+ {
+ return this.bound;
+ }
+ }
+
+ public Color BlendFactor
+ {
+ set
+ {
+ const float colorConvert = 1f / 255f;
+
+ blendFactor.Red = value.R * colorConvert;
+ blendFactor.Green = value.G * colorConvert;
+ blendFactor.Blue = value.B * colorConvert;
+ blendFactor.Alpha = value.A * colorConvert;
+ }
+ }
+
+ public int MultiSampleMask
+ {
+ set
+ {
+ this.multiSampleMask = value;
+ }
+ }
+
+ public BlendFunction AlphaBlendFunction
+ {
+ set
+ {
+ BlendOperation alphaBlendOperation = FormatConverter.Translate(value);
+
+ if (description.AlphaBlendOperation != alphaBlendOperation)
+ {
+ nativeBlendStateDirty = true;
+ description.AlphaBlendOperation = alphaBlendOperation;
+ }
+ }
+ }
+
+ public BlendFunction ColorBlendFunction
+ {
+ set
+ {
+ BlendOperation blendOperation = FormatConverter.Translate(value);
+
+ if (description.BlendOperation != blendOperation)
+ {
+ nativeBlendStateDirty = true;
+ description.BlendOperation = blendOperation;
+ }
+ }
+ }
+
+ public Blend AlphaDestinationBlend
+ {
+ set
+ {
+ BlendOption destinationAlphaBlend = FormatConverter.Translate(value);
+
+ if (description.DestinationAlphaBlend != destinationAlphaBlend)
+ {
+ nativeBlendStateDirty = true;
+ description.DestinationAlphaBlend = destinationAlphaBlend;
+ }
+ }
+ }
+
+ public Blend ColorDestinationBlend
+ {
+ set
+ {
+ BlendOption destinationBlend = FormatConverter.Translate(value);
+
+ if (description.DestinationBlend != destinationBlend)
+ {
+ nativeBlendStateDirty = true;
+ description.DestinationBlend = destinationBlend;
+ }
+ }
+ }
+
+ public ColorWriteChannels ColorWriteChannels
+ {
+ set
+ {
+ ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
+
+ if (description.RenderTargetWriteMask[0] != renderTargetWriteMask)
+ {
+ nativeBlendStateDirty = true;
+ description.RenderTargetWriteMask[0] = renderTargetWriteMask;
+ }
+ }
+ }
+
+ public ColorWriteChannels ColorWriteChannels1
+ {
+ set
+ {
+ ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
+
+ if (description.RenderTargetWriteMask[1] != renderTargetWriteMask)
+ {
+ nativeBlendStateDirty = true;
+ description.RenderTargetWriteMask[1] = renderTargetWriteMask;
+ }
+ }
+ }
+
+ public ColorWriteChannels ColorWriteChannels2
+ {
+ set
+ {
+ ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
+
+ if (description.RenderTargetWriteMask[2] != renderTargetWriteMask)
+ {
+ nativeBlendStateDirty = true;
+ description.RenderTargetWriteMask[2] = renderTargetWriteMask;
+ }
+ }
+ }
+
+ public ColorWriteChannels ColorWriteChannels3
+ {
+ set
+ {
+ ColorWriteMaskFlags renderTargetWriteMask = FormatConverter.Translate(value);
+
+ if (description.RenderTargetWriteMask[3] != renderTargetWriteMask)
+ {
+ nativeBlendStateDirty = true;
+ description.RenderTargetWriteMask[3] = renderTargetWriteMask;
+ }
+ }
+ }
+
+ public Blend AlphaSourceBlend
+ {
+ set
+ {
+ BlendOption sourceAlphaBlend = FormatConverter.Translate(value);
+
+ if (description.SourceAlphaBlend != sourceAlphaBlend)
+ {
+ nativeBlendStateDirty = true;
+ description.SourceAlphaBlend = sourceAlphaBlend;
+ }
+ }
+ }
+
+ public Blend ColorSourceBlend
+ {
+ set
+ {
+ BlendOption sourceBlend = FormatConverter.Translate(value);
+
+ if (description.SourceBlend != sourceBlend)
+ {
+ nativeBlendStateDirty = true;
+ description.SourceBlend = sourceBlend;
+ }
+ }
+ }
+
+ private void UpdateNativeBlendState(SharpDX.Direct3D10.Device device)
+ {
+ if (this.nativeBlendStateDirty == true || this.nativeBlendState == null)
+ {
+ if (this.nativeBlendState != null)
+ {
+ this.nativeBlendState.Dispose();
+ this.nativeBlendState = null;
+ }
+
+ this.nativeBlendState = new SharpDX.Direct3D10.BlendState(device, ref this.description);
+
+ this.nativeBlendStateDirty = false;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/Creator.cs b/RenderSystems/ANX.Framework.Windows.DX10/Creator.cs
new file mode 100644
index 00000000..3709052d
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/Creator.cs
@@ -0,0 +1,211 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.Graphics;
+using System.IO;
+using ANX.Framework.NonXNA;
+using System.Runtime.InteropServices;
+using SharpDX.DXGI;
+using ANX.Framework.NonXNA.RenderSystem;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class Creator : IRenderSystemCreator
+ {
+ public string Name
+ {
+ get { return "DirectX10"; }
+ }
+
+ public GameHost CreateGameHost(Game game)
+ {
+ return new WindowsGameHost(game);
+ }
+
+ public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters)
+ {
+ return new GraphicsDeviceWindowsDX10(presentationParameters);
+ }
+
+ public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
+ {
+ return new IndexBuffer_DX10(graphics, size, indexCount, usage);
+ }
+
+ public INativeBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
+ {
+ return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage);
+ }
+
+ public INativeEffect CreateEffect(GraphicsDevice graphics, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
+ {
+ Effect_DX10 effect = new Effect_DX10(graphics, vertexShaderByteCode, pixelShaderByteCode);
+
+ return effect;
+ }
+
+ public INativeEffect CreateEffect(GraphicsDevice graphics, System.IO.Stream byteCode)
+ {
+ Effect_DX10 effect = new Effect_DX10(graphics, byteCode);
+
+ return effect;
+ }
+
+ public Texture2D CreateTexture(GraphicsDevice graphics, string fileName)
+ {
+ //TODO: implement
+ throw new NotImplementedException();
+
+ //GraphicsDeviceWindowsDX10 graphicsDX10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
+ //SharpDX.Direct3D10.Texture2D nativeTexture = SharpDX.Direct3D10.Texture2D.FromFile(graphicsDX10.NativeDevice, fileName);
+ //Texture2D_DX10 texture = new Texture2D_DX10(graphics, nativeTexture.Description.Width, nativeTexture.Description.Height);
+ //texture.NativeTexture = nativeTexture;
+
+ //return texture;
+ }
+
+ public INativeBlendState CreateBlendState()
+ {
+ return new BlendState_DX10();
+ }
+
+ public INativeRasterizerState CreateRasterizerState()
+ {
+ return new RasterizerState_DX10();
+ }
+
+ public INativeDepthStencilState CreateDepthStencilState()
+ {
+ return new DepthStencilState_DX10();
+ }
+
+ public INativeSamplerState CreateSamplerState()
+ {
+ return new SamplerState_DX10();
+ }
+
+ public byte[] GetShaderByteCode(PreDefinedShader type)
+ {
+ if (type == PreDefinedShader.SpriteBatch)
+ {
+ return ShaderByteCode.SpriteBatchByteCode;
+ }
+
+ throw new NotImplementedException("ByteCode for '" + type.ToString() + "' is not yet available");
+ }
+
+ public void RegisterCreator(AddInSystemFactory factory)
+ {
+ factory.AddCreator(this);
+ }
+
+
+ public System.Collections.ObjectModel.ReadOnlyCollection GetAdapterList()
+ {
+ SharpDX.DXGI.Factory factory = new Factory();
+
+ List adapterList = new List();
+ DisplayModeCollection displayModeCollection = new DisplayModeCollection();
+
+ for (int i = 0; i < factory.GetAdapterCount(); i++)
+ {
+ using (Adapter adapter = factory.GetAdapter(i))
+ {
+ GraphicsAdapter ga = new GraphicsAdapter();
+ //ga.CurrentDisplayMode = ;
+ //ga.Description = ;
+ ga.DeviceId = adapter.Description.DeviceId;
+ ga.DeviceName = adapter.Description.Description;
+ ga.IsDefaultAdapter = i == 0; //TODO: how to set default adapter?
+ //ga.IsWideScreen = ;
+ //ga.MonitorHandle = ;
+ ga.Revision = adapter.Description.Revision;
+ ga.SubSystemId = adapter.Description.SubsystemId;
+ //ga.SupportedDisplayModes = ;
+ ga.VendorId = adapter.Description.VendorId;
+
+ using (Output adapterOutput = adapter.GetOutput(0))
+ {
+ foreach (ModeDescription modeDescription in adapterOutput.GetDisplayModeList(Format.R8G8B8A8_UNorm, DisplayModeEnumerationFlags.Interlaced))
+ {
+ DisplayMode displayMode = new DisplayMode()
+ {
+ Format = FormatConverter.Translate(modeDescription.Format),
+ Width = modeDescription.Width,
+ Height = modeDescription.Height,
+ AspectRatio = (float)modeDescription.Width / (float)modeDescription.Height,
+ TitleSafeArea = new Rectangle(0, 0, modeDescription.Width, modeDescription.Height), //TODO: calculate this for real
+ };
+
+ displayModeCollection[displayMode.Format] = new DisplayMode[] { displayMode };
+ }
+ }
+
+ ga.SupportedDisplayModes = displayModeCollection;
+
+ adapterList.Add(ga);
+ }
+ }
+
+ factory.Dispose();
+
+ return new System.Collections.ObjectModel.ReadOnlyCollection(adapterList);
+ }
+
+ public INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount)
+ {
+ return new Texture2D_DX10(graphics, width, height, surfaceFormat, mipCount);
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/DepthStencilState_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/DepthStencilState_DX10.cs
new file mode 100644
index 00000000..376d4e9c
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/DepthStencilState_DX10.cs
@@ -0,0 +1,290 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.NonXNA;
+using SharpDX.Direct3D10;
+
+namespace ANX.Framework.Windows.DX10
+{
+ public class DepthStencilState_DX10 : INativeDepthStencilState
+ {
+ #region Private Members
+ private DepthStencilStateDescription description;
+ private SharpDX.Direct3D10.DepthStencilState nativeDepthStencilState;
+ private bool nativeDepthStencilStateDirty;
+ private bool bound;
+
+ private int referenceStencil;
+
+ #endregion // Private Members
+
+ public DepthStencilState_DX10()
+ {
+ this.description = new DepthStencilStateDescription();
+
+ this.nativeDepthStencilStateDirty = true;
+ }
+
+ public void Apply(Graphics.GraphicsDevice graphicsDevice)
+ {
+ GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10;
+ Device device = gdx10.NativeDevice;
+
+ UpdateNativeDepthStencilState(device);
+ this.bound = true;
+
+ device.OutputMerger.SetDepthStencilState(nativeDepthStencilState, this.referenceStencil);
+ }
+
+ public void Release()
+ {
+ this.bound = false;
+ }
+
+ public void Dispose()
+ {
+ if (this.nativeDepthStencilState != null)
+ {
+ this.nativeDepthStencilState.Dispose();
+ this.nativeDepthStencilState = null;
+ }
+ }
+
+ public bool IsBound
+ {
+ get
+ {
+ return this.bound;
+ }
+ }
+
+ public Graphics.StencilOperation CounterClockwiseStencilDepthBufferFail
+ {
+ set
+ {
+ SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value);
+
+ if (description.BackFace.DepthFailOperation != operation)
+ {
+ description.BackFace.DepthFailOperation = operation;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public Graphics.StencilOperation CounterClockwiseStencilFail
+ {
+ set
+ {
+ SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value);
+
+ if (description.BackFace.FailOperation != operation)
+ {
+ description.BackFace.FailOperation = operation;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public Graphics.CompareFunction CounterClockwiseStencilFunction
+ {
+ set
+ {
+ SharpDX.Direct3D10.Comparison comparison = FormatConverter.Translate(value);
+
+ if (description.BackFace.Comparison != comparison)
+ {
+ description.BackFace.Comparison = comparison;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public Graphics.StencilOperation CounterClockwiseStencilPass
+ {
+ set
+ {
+ SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value);
+
+ if (description.BackFace.PassOperation != operation)
+ {
+ description.BackFace.PassOperation = operation;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public bool DepthBufferEnable
+ {
+ set
+ {
+ if (description.IsDepthEnabled != value)
+ {
+ description.IsDepthEnabled = value;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public Graphics.CompareFunction DepthBufferFunction
+ {
+ set
+ {
+ SharpDX.Direct3D10.Comparison comparison = FormatConverter.Translate(value);
+
+ if (description.DepthComparison != comparison)
+ {
+ description.DepthComparison = comparison;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public bool DepthBufferWriteEnable
+ {
+ set
+ {
+ DepthWriteMask writeMask = value ? DepthWriteMask.All : DepthWriteMask.Zero;
+
+ if (description.DepthWriteMask != writeMask)
+ {
+ description.DepthWriteMask = writeMask;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public int ReferenceStencil
+ {
+ set
+ {
+ if (this.referenceStencil != value)
+ {
+ this.referenceStencil = value;
+ this.nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public Graphics.StencilOperation StencilDepthBufferFail
+ {
+ set
+ {
+ SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value);
+
+ if (description.FrontFace.DepthFailOperation != operation)
+ {
+ description.FrontFace.DepthFailOperation = operation;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public bool StencilEnable
+ {
+ set
+ {
+ if (description.IsStencilEnabled != value)
+ {
+ description.IsStencilEnabled = value;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public Graphics.StencilOperation StencilFail
+ {
+ set
+ {
+ SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value);
+
+ if (description.FrontFace.FailOperation != operation)
+ {
+ description.FrontFace.FailOperation = operation;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public Graphics.CompareFunction StencilFunction
+ {
+ set
+ {
+ SharpDX.Direct3D10.Comparison comparison = FormatConverter.Translate(value);
+
+ if (description.FrontFace.Comparison != comparison)
+ {
+ description.FrontFace.Comparison = comparison;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public int StencilMask
+ {
+ set
+ {
+ byte stencilMask = (byte)value; //TODO: check range
+
+ if (description.StencilReadMask != stencilMask)
+ {
+ description.StencilReadMask = stencilMask;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public Graphics.StencilOperation StencilPass
+ {
+ set
+ {
+ SharpDX.Direct3D10.StencilOperation operation = FormatConverter.Translate(value);
+
+ if (description.FrontFace.PassOperation != operation)
+ {
+ description.FrontFace.PassOperation = operation;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public int StencilWriteMask
+ {
+ set
+ {
+ byte stencilWriteMask = (byte)value; //TODO: check range
+
+ if (description.StencilWriteMask != stencilWriteMask)
+ {
+ description.StencilWriteMask = stencilWriteMask;
+ nativeDepthStencilStateDirty = true;
+ }
+ }
+ }
+
+ public bool TwoSidedStencilMode
+ {
+ set
+ {
+ //TODO: check if we really need this. in xna this enables only counter clockwise stencil operations
+ }
+ }
+
+ private void UpdateNativeDepthStencilState(Device device)
+ {
+ if (this.nativeDepthStencilStateDirty == true || this.nativeDepthStencilState == null)
+ {
+ if (this.nativeDepthStencilState != null)
+ {
+ this.nativeDepthStencilState.Dispose();
+ this.nativeDepthStencilState = null;
+ }
+
+ this.nativeDepthStencilState = new SharpDX.Direct3D10.DepthStencilState(device, ref this.description);
+
+ this.nativeDepthStencilStateDirty = false;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/EffectParameter_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/EffectParameter_DX10.cs
new file mode 100644
index 00000000..1fa6b98b
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/EffectParameter_DX10.cs
@@ -0,0 +1,104 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.NonXNA;
+using SharpDX.Direct3D10;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA.RenderSystem;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class EffectParameter_DX10 : INativeEffectParameter
+ {
+ private EffectVariable nativeEffectVariable;
+
+ public EffectVariable NativeParameter
+ {
+ get
+ {
+ return this.nativeEffectVariable;
+ }
+ internal set
+ {
+ this.nativeEffectVariable = value;
+ }
+ }
+
+
+ public void SetValue(Matrix value)
+ {
+ SharpDX.Matrix m = new SharpDX.Matrix(value.M11, value.M12, value.M13, value.M14, value.M21, value.M22, value.M23, value.M24, value.M31, value.M32, value.M33, value.M34, value.M41, value.M42, value.M43, value.M44);
+ nativeEffectVariable.AsMatrix().SetMatrix(m);
+ }
+
+ public void SetValue(Texture value)
+ {
+ Texture2D_DX10 tex = value.NativeTexture as Texture2D_DX10;
+ GraphicsDeviceWindowsDX10 graphicsDX10 = tex.GraphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10;
+ SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice;
+
+ //ShaderResourceView srv = new ShaderResourceView(device, tex.NativeTexture);
+ //nativeEffectVariable.AsShaderResource().SetResource(srv);
+ nativeEffectVariable.AsShaderResource().SetResource(tex.NativeShaderResourceView);
+ }
+
+ public string Name
+ {
+ get
+ {
+ return nativeEffectVariable.Description.Name;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/EffectTechnique_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/EffectTechnique_DX10.cs
new file mode 100644
index 00000000..2acf74de
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/EffectTechnique_DX10.cs
@@ -0,0 +1,84 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.NonXNA;
+using SharpDX.Direct3D10;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class EffectTechnique_DX10 : INativeEffectTechnique
+ {
+ private EffectTechnique nativeTechnique;
+
+ public EffectTechnique NativeTechnique
+ {
+ get
+ {
+ return this.nativeTechnique;
+ }
+ internal set
+ {
+ this.nativeTechnique = value;
+ }
+ }
+
+ public string Name
+ {
+ get
+ {
+ return nativeTechnique.Description.Name;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs
new file mode 100644
index 00000000..e1b2f77f
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs
@@ -0,0 +1,244 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SharpDX.Direct3D10;
+using SharpDX.D3DCompiler;
+using System.IO;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class Effect_DX10 : INativeEffect
+ {
+ private ShaderBytecode pixelShaderByteCode;
+ private ShaderBytecode vertexShaderByteCode;
+ private VertexShader vertexShader;
+ private PixelShader pixelShader;
+
+ private ShaderBytecode effectByteCode;
+ private SharpDX.Direct3D10.Effect nativeEffect;
+
+ public Effect_DX10(GraphicsDevice device, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
+ {
+ if (vertexShaderByteCode.CanSeek)
+ {
+ vertexShaderByteCode.Seek(0, SeekOrigin.Begin);
+ }
+ this.vertexShaderByteCode = ShaderBytecode.FromStream(vertexShaderByteCode);
+ this.vertexShader = new VertexShader((SharpDX.Direct3D10.Device)device.NativeDevice, this.vertexShaderByteCode);
+
+ if (pixelShaderByteCode.CanSeek)
+ {
+ pixelShaderByteCode.Seek(0, SeekOrigin.Begin);
+ }
+ this.pixelShaderByteCode = ShaderBytecode.FromStream(pixelShaderByteCode);
+ this.pixelShader = new PixelShader((SharpDX.Direct3D10.Device)device.NativeDevice, this.pixelShaderByteCode);
+ }
+
+ public Effect_DX10(GraphicsDevice device, Stream effectByteCode)
+ {
+ if (effectByteCode.CanSeek)
+ {
+ effectByteCode.Seek(0, SeekOrigin.Begin);
+ }
+ this.effectByteCode = ShaderBytecode.FromStream(effectByteCode);
+ this.nativeEffect = new SharpDX.Direct3D10.Effect(((GraphicsDeviceWindowsDX10)device.NativeDevice).NativeDevice, this.effectByteCode);
+ }
+
+ public void Apply(GraphicsDevice graphicsDevice)
+ {
+ //TODO: dummy
+ ((GraphicsDeviceWindowsDX10)graphicsDevice.NativeDevice).currentEffect = this;
+ }
+
+ internal SharpDX.Direct3D10.Effect NativeEffect
+ {
+ get
+ {
+ return this.nativeEffect;
+ }
+ }
+
+ internal ShaderBytecode PixelShaderByteCode
+ {
+ get
+ {
+ return this.pixelShaderByteCode;
+ }
+ }
+
+ internal ShaderBytecode VertexShaderByteCode
+ {
+ get
+ {
+ return this.vertexShaderByteCode;
+ }
+ }
+
+ internal VertexShader VertexShader
+ {
+ get
+ {
+ return this.vertexShader;
+ }
+ }
+
+ internal PixelShader PixelShader
+ {
+ get
+ {
+ return this.pixelShader;
+ }
+ }
+
+ public static byte[] CompileVertexShader(string effectCode)
+ {
+ ShaderBytecode vertexShaderByteCode = ShaderBytecode.Compile(effectCode, "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None);
+ byte[] bytecode = new byte[vertexShaderByteCode.BufferSize];
+ vertexShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
+ return bytecode;
+ }
+
+ public static byte[] CompilePixelShader(string effectCode)
+ {
+ ShaderBytecode pixelShaderByteCode = ShaderBytecode.Compile(effectCode, "PS", "ps_4_0", ShaderFlags.None, EffectFlags.None);
+ byte[] bytecode = new byte[pixelShaderByteCode.BufferSize];
+ pixelShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
+ return bytecode;
+ }
+
+ public static byte[] CompileFXShader(string effectCode)
+ {
+ ShaderBytecode effectByteCode = ShaderBytecode.Compile(effectCode, "fx_4_0", ShaderFlags.None, EffectFlags.None);
+ byte[] bytecode = new byte[effectByteCode.BufferSize];
+ effectByteCode.Data.Read(bytecode, 0, bytecode.Length);
+ return bytecode;
+ }
+
+ public void Dispose()
+ {
+ if (this.pixelShaderByteCode != null)
+ {
+ this.pixelShaderByteCode.Dispose();
+ this.pixelShaderByteCode = null;
+ }
+
+ if (this.pixelShader != null)
+ {
+ this.pixelShader.Dispose();
+ this.pixelShader = null;
+ }
+
+ if (this.vertexShaderByteCode != null)
+ {
+ this.vertexShaderByteCode.Dispose();
+ this.vertexShaderByteCode = null;
+ }
+
+ if (this.vertexShader != null)
+ {
+ this.vertexShader.Dispose();
+ this.vertexShader = null;
+ }
+
+ if (this.effectByteCode != null)
+ {
+ this.effectByteCode.Dispose();
+ this.effectByteCode = null;
+ }
+
+ if (this.nativeEffect != null)
+ {
+ this.nativeEffect.Dispose();
+ this.nativeEffect = null;
+ }
+ }
+
+
+ public IEnumerable Techniques
+ {
+ get
+ {
+ for (int i = 0; i < nativeEffect.Description.TechniqueCount; i++)
+ {
+ EffectTechnique_DX10 teqDx10 = new EffectTechnique_DX10();
+ teqDx10.NativeTechnique = nativeEffect.GetTechniqueByIndex(i);
+
+ Graphics.EffectTechnique teq = new Graphics.EffectTechnique();
+ teq.NativeTechnique = teqDx10;
+
+ yield return teq;
+ }
+ }
+ }
+
+ public IEnumerable Parameters
+ {
+ get
+ {
+ for (int i = 0; i < nativeEffect.Description.GlobalVariableCount; i++)
+ {
+ EffectParameter_DX10 parDx10 = new EffectParameter_DX10();
+ parDx10.NativeParameter = nativeEffect.GetVariableByIndex(i);
+
+ Graphics.EffectParameter par = new Graphics.EffectParameter();
+ par.NativeParameter = parDx10;
+
+ yield return par;
+ }
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/FormatConverter.cs b/RenderSystems/ANX.Framework.Windows.DX10/FormatConverter.cs
new file mode 100644
index 00000000..00747845
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/FormatConverter.cs
@@ -0,0 +1,357 @@
+#region Using Statements
+using System;
+using ANX.Framework.Graphics;
+using SharpDX.Direct3D10;
+using SharpDX.Direct3D;
+using SharpDX.DXGI;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ internal class FormatConverter
+ {
+
+ public static int FormatSize(SurfaceFormat format)
+ {
+ switch (format)
+ {
+ case SurfaceFormat.Vector4:
+ return 16;
+ //case SurfaceFormat.Vector3:
+ // return 12;
+ case SurfaceFormat.Vector2:
+ return 8;
+ case SurfaceFormat.Single:
+ case SurfaceFormat.Color:
+ //case SurfaceFormat.RGBA1010102:
+ //case SurfaceFormat.RG32:
+ return 4;
+ //case SurfaceFormat.BGR565:
+ //case SurfaceFormat.BGRA5551:
+ // return 2;
+ case SurfaceFormat.Dxt1:
+ case SurfaceFormat.Dxt3:
+ case SurfaceFormat.Dxt5:
+ case SurfaceFormat.Alpha8:
+ return 1;
+ default:
+ throw new ArgumentException("Invalid format");
+ }
+ }
+
+ public static SharpDX.DXGI.Format Translate(SurfaceFormat surfaceFormat)
+ {
+ switch (surfaceFormat)
+ {
+ case SurfaceFormat.Color:
+ return SharpDX.DXGI.Format.R8G8B8A8_UNorm;
+ case SurfaceFormat.Dxt3:
+ return SharpDX.DXGI.Format.BC2_UNorm;
+ case SurfaceFormat.Dxt5:
+ return SharpDX.DXGI.Format.BC3_UNorm;
+ }
+
+ throw new Exception("can't translate SurfaceFormat: " + surfaceFormat.ToString());
+ }
+
+ public static SurfaceFormat Translate(SharpDX.DXGI.Format format)
+ {
+ switch (format)
+ {
+ case SharpDX.DXGI.Format.R8G8B8A8_UNorm:
+ return SurfaceFormat.Color;
+ case SharpDX.DXGI.Format.BC2_UNorm:
+ return SurfaceFormat.Dxt3;
+ case SharpDX.DXGI.Format.BC3_UNorm:
+ return SurfaceFormat.Dxt5;
+ }
+
+ throw new Exception("can't translate Format: " + format.ToString());
+ }
+
+ public static Filter Translate(TextureFilter filter)
+ {
+ switch (filter)
+ {
+ case TextureFilter.Anisotropic:
+ return Filter.Anisotropic;
+ case TextureFilter.Linear:
+ return Filter.MinMagMipLinear;
+ case TextureFilter.LinearMipPoint:
+ return Filter.MinMagMipPoint;
+ case TextureFilter.MinLinearMagPointMipLinear:
+ return Filter.MinLinearMagPointMipLinear;
+ case TextureFilter.MinLinearMagPointMipPoint:
+ return Filter.MinLinearMagMipPoint;
+ case TextureFilter.MinPointMagLinearMipLinear:
+ return Filter.MinPointMagMipLinear;
+ case TextureFilter.MinPointMagLinearMipPoint:
+ return Filter.MinPointMagLinearMipPoint;
+ case TextureFilter.Point:
+ return Filter.MinMagMipPoint;
+ case TextureFilter.PointMipLinear:
+ return Filter.MinMagPointMipLinear;
+ }
+
+ throw new NotImplementedException();
+ }
+
+ public static SharpDX.Direct3D10.TextureAddressMode Translate(ANX.Framework.Graphics.TextureAddressMode addressMode)
+ {
+ switch (addressMode)
+ {
+ case Graphics.TextureAddressMode.Clamp:
+ return SharpDX.Direct3D10.TextureAddressMode.Clamp;
+ case Graphics.TextureAddressMode.Mirror:
+ return SharpDX.Direct3D10.TextureAddressMode.Mirror;
+ case Graphics.TextureAddressMode.Wrap:
+ return SharpDX.Direct3D10.TextureAddressMode.Wrap;
+ }
+
+ return SharpDX.Direct3D10.TextureAddressMode.Clamp;
+ }
+
+ public static PrimitiveTopology Translate(PrimitiveType primitiveType)
+ {
+ switch (primitiveType)
+ {
+ case PrimitiveType.LineList:
+ return PrimitiveTopology.LineList;
+ case PrimitiveType.LineStrip:
+ return PrimitiveTopology.LineStrip;
+ case PrimitiveType.TriangleList:
+ return PrimitiveTopology.TriangleList;
+ case PrimitiveType.TriangleStrip:
+ return PrimitiveTopology.TriangleStrip;
+ default:
+ throw new InvalidOperationException("unknown PrimitiveType: " + primitiveType.ToString());
+ }
+ }
+
+ public static SharpDX.DXGI.Format Translate(IndexElementSize indexElementSize)
+ {
+ switch (indexElementSize)
+ {
+ case IndexElementSize.SixteenBits:
+ return Format.R16_UInt;
+ case IndexElementSize.ThirtyTwoBits:
+ return Format.R32_UInt;
+ default:
+ throw new InvalidOperationException("unknown IndexElementSize: " + indexElementSize.ToString());
+ }
+ }
+
+ public static string Translate(VertexElementUsage usage)
+ {
+ //TODO: map the other Usages
+ if (usage == VertexElementUsage.TextureCoordinate)
+ {
+ return "TEXCOORD";
+ }
+ else
+ {
+ return usage.ToString().ToUpperInvariant();
+ }
+ }
+
+ public static BlendOperation Translate(BlendFunction blendFunction)
+ {
+ switch (blendFunction)
+ {
+ case BlendFunction.Add:
+ return BlendOperation.Add;
+ case BlendFunction.Max:
+ return BlendOperation.Maximum;
+ case BlendFunction.Min:
+ return BlendOperation.Minimum;
+ case BlendFunction.ReverseSubtract:
+ return BlendOperation.ReverseSubtract;
+ case BlendFunction.Subtract:
+ return BlendOperation.Subtract;
+ }
+
+ throw new NotImplementedException();
+ }
+
+ public static BlendOption Translate(Blend blend)
+ {
+ switch (blend)
+ {
+ case Blend.BlendFactor:
+ return BlendOption.BlendFactor;
+ case Blend.DestinationAlpha:
+ return BlendOption.DestinationAlpha;
+ case Blend.DestinationColor:
+ return BlendOption.DestinationColor;
+ case Blend.InverseBlendFactor:
+ return BlendOption.InverseBlendFactor;
+ case Blend.InverseDestinationAlpha:
+ return BlendOption.InverseDestinationAlpha;
+ case Blend.InverseDestinationColor:
+ return BlendOption.InverseDestinationColor;
+ case Blend.InverseSourceAlpha:
+ return BlendOption.InverseSourceAlpha;
+ case Blend.InverseSourceColor:
+ return BlendOption.InverseSourceColor;
+ case Blend.One:
+ return BlendOption.One;
+ case Blend.SourceAlpha:
+ return BlendOption.SourceAlpha;
+ case Blend.SourceAlphaSaturation:
+ return BlendOption.SourceAlphaSaturate;
+ case Blend.SourceColor:
+ return BlendOption.SourceColor;
+ case Blend.Zero:
+ return BlendOption.Zero;
+ }
+
+ throw new NotImplementedException();
+ }
+
+ public static ColorWriteMaskFlags Translate(ColorWriteChannels colorWriteChannels)
+ {
+ switch (colorWriteChannels)
+ {
+ case ColorWriteChannels.All:
+ return ColorWriteMaskFlags.All;
+ case ColorWriteChannels.Alpha:
+ return ColorWriteMaskFlags.Alpha;
+ case ColorWriteChannels.Blue:
+ return ColorWriteMaskFlags.Blue;
+ case ColorWriteChannels.Green:
+ return ColorWriteMaskFlags.Green;
+ case ColorWriteChannels.Red:
+ return ColorWriteMaskFlags.Red;
+ }
+
+ throw new NotImplementedException();
+ }
+
+ public static SharpDX.Direct3D10.StencilOperation Translate(ANX.Framework.Graphics.StencilOperation stencilOperation)
+ {
+ switch (stencilOperation)
+ {
+ case Graphics.StencilOperation.Decrement:
+ return SharpDX.Direct3D10.StencilOperation.Decrement;
+ case Graphics.StencilOperation.DecrementSaturation:
+ return SharpDX.Direct3D10.StencilOperation.DecrementAndClamp;
+ case Graphics.StencilOperation.Increment:
+ return SharpDX.Direct3D10.StencilOperation.Increment;
+ case Graphics.StencilOperation.IncrementSaturation:
+ return SharpDX.Direct3D10.StencilOperation.IncrementAndClamp;
+ case Graphics.StencilOperation.Invert:
+ return SharpDX.Direct3D10.StencilOperation.Invert;
+ case Graphics.StencilOperation.Keep:
+ return SharpDX.Direct3D10.StencilOperation.Keep;
+ case Graphics.StencilOperation.Replace:
+ return SharpDX.Direct3D10.StencilOperation.Replace;
+ case Graphics.StencilOperation.Zero:
+ return SharpDX.Direct3D10.StencilOperation.Zero;
+ }
+
+ throw new NotImplementedException("unknown StencilOperation");
+ }
+
+ public static Comparison Translate(ANX.Framework.Graphics.CompareFunction compareFunction)
+ {
+ switch (compareFunction)
+ {
+ case ANX.Framework.Graphics.CompareFunction.Always:
+ return Comparison.Always;
+ case ANX.Framework.Graphics.CompareFunction.Equal:
+ return Comparison.Equal;
+ case ANX.Framework.Graphics.CompareFunction.Greater:
+ return Comparison.Greater;
+ case ANX.Framework.Graphics.CompareFunction.GreaterEqual:
+ return Comparison.GreaterEqual;
+ case ANX.Framework.Graphics.CompareFunction.Less:
+ return Comparison.Less;
+ case ANX.Framework.Graphics.CompareFunction.LessEqual:
+ return Comparison.LessEqual;
+ case ANX.Framework.Graphics.CompareFunction.Never:
+ return Comparison.Never;
+ case ANX.Framework.Graphics.CompareFunction.NotEqual:
+ return Comparison.NotEqual;
+ }
+
+ throw new NotImplementedException("unknown CompareFunction");
+ }
+
+ public static SharpDX.Direct3D10.CullMode Translate(ANX.Framework.Graphics.CullMode cullMode)
+ {
+ if (cullMode == Graphics.CullMode.CullClockwiseFace)
+ {
+ return SharpDX.Direct3D10.CullMode.Front;
+ }
+ else if (cullMode == Graphics.CullMode.CullCounterClockwiseFace)
+ {
+ return SharpDX.Direct3D10.CullMode.Back;
+ }
+ else
+ {
+ return SharpDX.Direct3D10.CullMode.None;
+ }
+ }
+
+ public static SharpDX.Direct3D10.FillMode Translate(ANX.Framework.Graphics.FillMode fillMode)
+ {
+ if (fillMode == Graphics.FillMode.WireFrame)
+ {
+ return SharpDX.Direct3D10.FillMode.Wireframe;
+ }
+ else
+ {
+ return SharpDX.Direct3D10.FillMode.Solid;
+ }
+ }
+
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs
new file mode 100644
index 00000000..289d434e
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs
@@ -0,0 +1,481 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SharpDX;
+using SharpDX.DXGI;
+using SharpDX.Direct3D;
+using SharpDX.D3DCompiler;
+using ANX.Framework.NonXNA;
+using SharpDX.Direct3D10;
+using ANX.Framework.Graphics;
+
+#endregion // Using Statements
+
+#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
+
+using Device = SharpDX.Direct3D10.Device;
+using Buffer = SharpDX.Direct3D10.Buffer;
+using System.Runtime.InteropServices;
+
+namespace ANX.Framework.Windows.DX10
+{
+ public class GraphicsDeviceWindowsDX10 : INativeGraphicsDevice
+ {
+ #region Constants
+ private const float ColorMultiplier = 1f / 255f;
+ #endregion
+
+ #region Interop
+ [DllImport("user32.dll")]
+ private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int x, int y, int width, int height, uint uFlags);
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ static extern bool GetWindowRect(IntPtr hWnd, out RECT lpRect);
+
+ [DllImport("user32.dll")]
+ [return: MarshalAs(UnmanagedType.Bool)]
+ static extern bool GetClientRect(IntPtr hWnd, out RECT lpRect);
+
+ [StructLayout(LayoutKind.Sequential)]
+ public struct RECT
+ {
+ public int Left; // x position of upper-left corner
+ public int Top; // y position of upper-left corner
+ public int Right; // x position of lower-right corner
+ public int Bottom; // y position of lower-right corner
+ }
+
+ #endregion
+
+ #region Private Members
+ private Device device;
+ private SwapChain swapChain;
+ private RenderTargetView renderView;
+ private DepthStencilView depthStencilView;
+ private SharpDX.Direct3D10.Texture2D backBuffer;
+ internal Effect_DX10 currentEffect;
+ private VertexBuffer currentVertexBuffer;
+ private IndexBuffer currentIndexBuffer;
+ private SharpDX.Direct3D10.Viewport currentViewport;
+ private uint lastClearColor;
+ private SharpDX.Color4 clearColor;
+ private bool vSyncEnabled;
+
+ #endregion // Private Members
+
+ public GraphicsDeviceWindowsDX10(PresentationParameters presentationParameters)
+ {
+ this.vSyncEnabled = true;
+
+ // SwapChain description
+ var desc = new SwapChainDescription()
+ {
+ BufferCount = 1,
+ ModeDescription = new ModeDescription(presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight, new Rational(60, 1), Format.R8G8B8A8_UNorm),
+ IsWindowed = true,
+ OutputHandle = presentationParameters.DeviceWindowHandle,
+ SampleDescription = new SampleDescription(1, 0),
+ SwapEffect = SwapEffect.Discard,
+ Usage = Usage.RenderTargetOutput
+ };
+
+ // Create Device and SwapChain
+#if DIRECTX_DEBUG_LAYER
+ // http://msdn.microsoft.com/en-us/library/windows/desktop/bb205068(v=vs.85).aspx
+ Device.CreateWithSwapChain(SharpDX.Direct3D10.DriverType.Hardware, DeviceCreationFlags.Debug, desc, out device, out swapChain);
+#else
+ Device.CreateWithSwapChain(SharpDX.Direct3D10.DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain);
+#endif
+
+ // Ignore all windows events
+ Factory factory = swapChain.GetParent();
+ factory.MakeWindowAssociation(presentationParameters.DeviceWindowHandle, WindowAssociationFlags.IgnoreAll);
+
+ // New RenderTargetView from the backbuffer
+ backBuffer = SharpDX.Direct3D10.Texture2D.FromSwapChain(swapChain, 0);
+ renderView = new RenderTargetView(device, backBuffer);
+
+ currentViewport = new SharpDX.Direct3D10.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
+ }
+
+ #region Clear
+ public void Clear(ref Color color)
+ {
+ uint newClearColor = color.PackedValue;
+ if (lastClearColor != newClearColor)
+ {
+ lastClearColor = newClearColor;
+ clearColor.Red = color.R * ColorMultiplier;
+ clearColor.Green = color.G * ColorMultiplier;
+ clearColor.Blue = color.B * ColorMultiplier;
+ clearColor.Alpha = color.A * ColorMultiplier;
+ }
+
+ this.device.ClearRenderTargetView(this.renderView, this.clearColor);
+ }
+
+ public void Clear(ClearOptions options, Vector4 color, float depth, int stencil)
+ {
+ if ((options & ClearOptions.Target) == ClearOptions.Target)
+ {
+ // Clear a RenderTarget (or BackBuffer)
+
+ this.clearColor.Red = color.X;
+ this.clearColor.Green = color.Y;
+ this.clearColor.Blue = color.Z;
+ this.clearColor.Alpha = color.W;
+
+ this.device.ClearRenderTargetView(this.renderView, this.clearColor);
+ }
+
+ if (this.depthStencilView != null)
+ {
+ if ((options | ClearOptions.Stencil | ClearOptions.DepthBuffer) == options)
+ {
+ // Clear the stencil buffer
+ device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth | DepthStencilClearFlags.Stencil, depth, (byte)stencil);
+ }
+ else if ((options | ClearOptions.Stencil) == options)
+ {
+ device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Stencil, depth, (byte)stencil);
+ }
+ else
+ {
+ device.ClearDepthStencilView(this.depthStencilView, DepthStencilClearFlags.Depth, depth, (byte)stencil);
+ }
+ }
+
+ if ((options & ClearOptions.Target) == ClearOptions.Target)
+ {
+ // Clear a RenderTarget
+
+ throw new NotImplementedException();
+ }
+ }
+
+ #endregion
+
+ public void Present()
+ {
+ swapChain.Present(this.vSyncEnabled ? 1 : 0, PresentFlags.None);
+ }
+
+ internal Device NativeDevice
+ {
+ get
+ {
+ return this.device;
+ }
+ }
+
+ private void SetupEffectForDraw(out SharpDX.Direct3D10.EffectPass pass, out SharpDX.Direct3D10.EffectTechnique technique, out ShaderBytecode passSignature)
+ {
+ // get the current effect
+ //TODO: check for null and throw exception
+ Effect_DX10 effect = this.currentEffect;
+
+ // get the input semantic of the current effect / technique that is used
+ //TODO: check for null's and throw exceptions
+ technique = effect.NativeEffect.GetTechniqueByIndex(0);
+ pass = technique.GetPassByIndex(0);
+ passSignature = pass.Description.Signature;
+ }
+
+ private void SetupInputLayout(ShaderBytecode passSignature)
+ {
+ // get the VertexDeclaration from current VertexBuffer to create input layout for the input assembler
+ //TODO: check for null and throw exception
+ VertexDeclaration vertexDeclaration = currentVertexBuffer.VertexDeclaration;
+ var layout = CreateInputLayout(device, passSignature, vertexDeclaration);
+
+ device.InputAssembler.InputLayout = layout;
+ }
+
+ private int CalculateVertexCount(PrimitiveType type, int primitiveCount)
+ {
+ if (type == PrimitiveType.TriangleList)
+ {
+ return primitiveCount * 3;
+ }
+ else if (type == PrimitiveType.LineList)
+ {
+ return primitiveCount * 2;
+ }
+ else if (type == PrimitiveType.LineStrip)
+ {
+ return primitiveCount + 1;
+ }
+ else if (type == PrimitiveType.TriangleStrip)
+ {
+ return primitiveCount + 2;
+ }
+ else
+ {
+ throw new NotImplementedException("couldn't calculate vertex count for PrimitiveType '" + type.ToString() + "'");
+ }
+ }
+
+ public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount)
+ {
+ SharpDX.Direct3D10.EffectPass pass; SharpDX.Direct3D10.EffectTechnique technique; ShaderBytecode passSignature;
+ SetupEffectForDraw(out pass, out technique, out passSignature);
+
+ SetupInputLayout(passSignature);
+
+ // Prepare All the stages
+ device.InputAssembler.PrimitiveTopology = FormatConverter.Translate(primitiveType);
+ device.Rasterizer.SetViewports(currentViewport);
+
+ device.OutputMerger.SetTargets(this.renderView);
+
+ for (int i = 0; i < technique.Description.PassCount; ++i)
+ {
+ pass.Apply();
+ device.DrawIndexed(CalculateVertexCount(primitiveType, primitiveCount), startIndex, baseVertex);
+ }
+ }
+
+ public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount)
+ {
+ SharpDX.Direct3D10.EffectPass pass; SharpDX.Direct3D10.EffectTechnique technique; ShaderBytecode passSignature;
+ SetupEffectForDraw(out pass, out technique, out passSignature);
+
+ SetupInputLayout(passSignature);
+
+ // Prepare All the stages
+ device.InputAssembler.PrimitiveTopology = FormatConverter.Translate(primitiveType);
+ device.Rasterizer.SetViewports(currentViewport);
+ device.OutputMerger.SetTargets(this.renderView);
+
+ for (int i = 0; i < technique.Description.PassCount; ++i)
+ {
+ pass.Apply();
+ device.Draw(primitiveCount, vertexOffset);
+ }
+ }
+
+ public void SetIndexBuffer(IndexBuffer indexBuffer)
+ {
+ if (indexBuffer == null)
+ {
+ throw new ArgumentNullException("indexBuffer");
+ }
+
+ this.currentIndexBuffer = indexBuffer;
+
+ IndexBuffer_DX10 nativeIndexBuffer = indexBuffer.NativeIndexBuffer as IndexBuffer_DX10;
+
+ if (nativeIndexBuffer != null)
+ {
+ device.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer, FormatConverter.Translate(indexBuffer.IndexElementSize), 0);
+ }
+ else
+ {
+ throw new Exception("couldn't fetch native DirectX10 IndexBuffer");
+ }
+ }
+
+ public void SetVertexBuffers(Graphics.VertexBufferBinding[] vertexBuffers)
+ {
+ if (vertexBuffers == null)
+ {
+ throw new ArgumentNullException("vertexBuffers");
+ }
+
+ this.currentVertexBuffer = vertexBuffers[0].VertexBuffer; //TODO: hmmmmm, not nice :-)
+
+ SharpDX.Direct3D10.VertexBufferBinding[] nativeVertexBufferBindings = new SharpDX.Direct3D10.VertexBufferBinding[vertexBuffers.Length];
+ for (int i = 0; i < vertexBuffers.Length; i++)
+ {
+ ANX.Framework.Graphics.VertexBufferBinding anxVertexBufferBinding = vertexBuffers[i];
+ VertexBuffer_DX10 nativeVertexBuffer = anxVertexBufferBinding.VertexBuffer.NativeVertexBuffer as VertexBuffer_DX10;
+
+ if (nativeVertexBuffer != null)
+ {
+ nativeVertexBufferBindings[i] = new SharpDX.Direct3D10.VertexBufferBinding(nativeVertexBuffer.NativeBuffer, anxVertexBufferBinding.VertexBuffer.VertexDeclaration.VertexStride, anxVertexBufferBinding.VertexOffset);
+ }
+ else
+ {
+ throw new Exception("couldn't fetch native DirectX10 VertexBuffer");
+ }
+ }
+
+ device.InputAssembler.SetVertexBuffers(0, nativeVertexBufferBindings);
+ }
+
+ public void SetViewport(Graphics.Viewport viewport)
+ {
+ this.currentViewport = new SharpDX.Direct3D10.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinDepth, viewport.MaxDepth);
+ }
+
+ ///
+ /// This method creates a InputLayout which is needed by DirectX 10 for rendering primitives. The VertexDeclaration of ANX/XNA needs to be mapped
+ /// to the DirectX 10 types. This is what this method is for.
+ ///
+ private InputLayout CreateInputLayout(Device device, ShaderBytecode passSignature, VertexDeclaration vertexDeclaration)
+ {
+ VertexElement[] vertexElements = vertexDeclaration.GetVertexElements();
+ int elementCount = vertexElements.Length;
+ InputElement[] inputElements = new InputElement[elementCount];
+
+ for (int i = 0; i < elementCount; i++)
+ {
+ inputElements[i] = CreateInputElementFromVertexElement(vertexElements[i]);
+ }
+
+ // Layout from VertexShader input signature
+ return new InputLayout(device, passSignature, inputElements);
+ }
+
+ private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement)
+ {
+ string elementName = FormatConverter.Translate(vertexElement.VertexElementUsage);
+
+ Format elementFormat;
+ switch (vertexElement.VertexElementFormat)
+ {
+ case VertexElementFormat.Vector2:
+ elementFormat = Format.R32G32_Float;
+ break;
+ case VertexElementFormat.Vector3:
+ elementFormat = Format.R32G32B32_Float;
+ break;
+ case VertexElementFormat.Vector4:
+ elementFormat = Format.R32G32B32A32_Float;
+ break;
+ case VertexElementFormat.Color:
+ elementFormat = Format.R8G8B8A8_UNorm;
+ break;
+ default:
+ throw new Exception("can't map '" + vertexElement.VertexElementFormat.ToString() + "' to DXGI.Format in DirectX10 RenderSystem CreateInputElementFromVertexElement");
+ }
+
+ return new InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0);
+ }
+
+ public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public void GetBackBufferData(Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ throw new NotImplementedException();
+ }
+
+ public void GetBackBufferData(T[] data) where T : struct
+ {
+ throw new NotImplementedException();
+ }
+
+ public void GetBackBufferData(T[] data, int startIndex, int elementCount) where T : struct
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawUserIndexedPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, Array indexData, int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration, IndexElementSize indexFormat) where T : struct, IVertexType
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public void ResizeBuffers(PresentationParameters presentationParameters)
+ {
+ if (swapChain != null)
+ {
+ renderView.Dispose();
+ backBuffer.Dispose();
+
+ //TODO: handle format
+
+ swapChain.ResizeBuffers(swapChain.Description.BufferCount, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight, Format.R8G8B8A8_UNorm, (int)swapChain.Description.Flags);
+
+ backBuffer = SharpDX.Direct3D10.Texture2D.FromSwapChain(swapChain, 0);
+ renderView = new RenderTargetView(device, backBuffer);
+ }
+
+ // resize the render window
+ RECT windowRect;
+ RECT clientRect;
+ if (GetWindowRect(presentationParameters.DeviceWindowHandle, out windowRect) &&
+ GetClientRect(presentationParameters.DeviceWindowHandle, out clientRect))
+ {
+ int width = presentationParameters.BackBufferWidth + ((windowRect.Right - windowRect.Left) - clientRect.Right);
+ int height = presentationParameters.BackBufferHeight + ((windowRect.Bottom - windowRect.Top) - clientRect.Bottom);
+
+ SetWindowPos(presentationParameters.DeviceWindowHandle, IntPtr.Zero, windowRect.Left, windowRect.Top, width, height, 0);
+ }
+ }
+
+ public bool VSync
+ {
+ get
+ {
+ return this.vSyncEnabled;
+ }
+ set
+ {
+ this.vSyncEnabled = value;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/IndexBuffer_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/IndexBuffer_DX10.cs
new file mode 100644
index 00000000..b0982919
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/IndexBuffer_DX10.cs
@@ -0,0 +1,153 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.NonXNA;
+using SharpDX.Direct3D10;
+using ANX.Framework.Graphics;
+using System.Runtime.InteropServices;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class IndexBuffer_DX10 : INativeBuffer, IDisposable
+ {
+ private SharpDX.Direct3D10.Buffer buffer;
+ private IndexElementSize size;
+
+ public IndexBuffer_DX10(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
+ {
+ this.size = size;
+
+ //TODO: translate and use usage
+
+ GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
+ SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null;
+
+ if (device != null)
+ {
+ BufferDescription description = new BufferDescription()
+ {
+ Usage = ResourceUsage.Dynamic,
+ SizeInBytes = (size == IndexElementSize.SixteenBits ? 2 : 4) * indexCount,
+ BindFlags = BindFlags.IndexBuffer,
+ CpuAccessFlags = CpuAccessFlags.Write,
+ OptionFlags = ResourceOptionFlags.None
+ };
+
+ this.buffer = new SharpDX.Direct3D10.Buffer(device, description);
+ this.buffer.Unmap();
+ }
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data) where T : struct
+ {
+ SetData(graphicsDevice, data, 0, data.Length);
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ if (startIndex > 0 || elementCount < data.Length)
+ {
+ throw new NotImplementedException("currently starIndex and elementCount of SetData are not implemented");
+ }
+
+ //TODO: check offsetInBytes parameter for bounds etc.
+
+ GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned);
+ IntPtr dataPointer = pinnedArray.AddrOfPinnedObject();
+
+ int dataLength = Marshal.SizeOf(typeof(T)) * data.Length;
+
+ unsafe
+ {
+ using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, false))
+ {
+ if (offsetInBytes > 0)
+ {
+ vData.Seek(offsetInBytes / (size == IndexElementSize.SixteenBits ? 2 : 4), System.IO.SeekOrigin.Begin);
+ }
+
+ using (var d = buffer.Map(MapMode.WriteDiscard))
+ {
+ vData.CopyTo(d);
+ buffer.Unmap();
+ }
+ }
+ }
+
+ pinnedArray.Free();
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ SetData(graphicsDevice, 0, data, startIndex, elementCount);
+ }
+
+ public SharpDX.Direct3D10.Buffer NativeBuffer
+ {
+ get
+ {
+ return this.buffer;
+ }
+ }
+
+ public void Dispose()
+ {
+ if (this.buffer != null)
+ {
+ buffer.Dispose();
+ buffer = null;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/NativeMethods.cs b/RenderSystems/ANX.Framework.Windows.DX10/NativeMethods.cs
new file mode 100644
index 00000000..3ccb27a8
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/NativeMethods.cs
@@ -0,0 +1,120 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Runtime.InteropServices;
+using System.Security;
+using System.Drawing;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ internal sealed class NativeMethods
+ {
+ [SuppressUnmanagedCodeSecurity, DllImport("user32.dll", CharSet = CharSet.Auto)]
+ internal static extern bool PeekMessage(out Message msg, IntPtr hWnd, uint messageFilterMin, uint messageFilterMax, uint flags);
+
+ // Nested Types
+ [StructLayout(LayoutKind.Sequential)]
+ public struct Message
+ {
+ public IntPtr hWnd;
+ public NativeMethods.WindowMessage msg;
+ public IntPtr wParam;
+ public IntPtr lParam;
+ public uint time;
+ public Point p;
+ }
+
+ internal enum WindowMessage : uint
+ {
+ ActivateApplication = 0x1c,
+ Character = 0x102,
+ Close = 0x10,
+ Destroy = 2,
+ EnterMenuLoop = 0x211,
+ EnterSizeMove = 0x231,
+ ExitMenuLoop = 530,
+ ExitSizeMove = 0x232,
+ GetMinMax = 0x24,
+ KeyDown = 0x100,
+ KeyUp = 0x101,
+ LeftButtonDoubleClick = 0x203,
+ LeftButtonDown = 0x201,
+ LeftButtonUp = 0x202,
+ MiddleButtonDoubleClick = 0x209,
+ MiddleButtonDown = 0x207,
+ MiddleButtonUp = 520,
+ MouseFirst = 0x201,
+ MouseLast = 0x20d,
+ MouseMove = 0x200,
+ MouseWheel = 0x20a,
+ NonClientHitTest = 0x84,
+ Paint = 15,
+ PowerBroadcast = 0x218,
+ Quit = 0x12,
+ RightButtonDoubleClick = 0x206,
+ RightButtonDown = 0x204,
+ RightButtonUp = 0x205,
+ SetCursor = 0x20,
+ Size = 5,
+ SystemCharacter = 0x106,
+ SystemCommand = 0x112,
+ SystemKeyDown = 260,
+ SystemKeyUp = 0x105,
+ XButtonDoubleClick = 0x20d,
+ XButtonDown = 0x20b,
+ XButtonUp = 0x20c
+ }
+
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs b/RenderSystems/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..74e3d100
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs
@@ -0,0 +1,38 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("ANX.Framework.Windows.DX10")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("ANX Developer Team")]
+[assembly: AssemblyProduct("ANX.Framework.Windows.DX10")]
+[assembly: AssemblyCopyright("Copyright © ANX Developer Team 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("ea63e2c5-c774-43e8-b613-616921a8a5cf")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("0.7.3.0")]
+[assembly: AssemblyFileVersion("0.7.3.0")]
+
+[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/RasterizerState_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/RasterizerState_DX10.cs
new file mode 100644
index 00000000..9fc88785
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/RasterizerState_DX10.cs
@@ -0,0 +1,212 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SharpDX.Direct3D10;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class RasterizerState_DX10 : INativeRasterizerState
+ {
+ #region Private Members
+ private RasterizerStateDescription description;
+ private SharpDX.Direct3D10.RasterizerState nativeRasterizerState;
+ private bool nativeRasterizerStateDirty;
+ private bool bound;
+
+ private const int intMaxOver16 = int.MaxValue / 16;
+
+ #endregion // Private Members
+
+ public RasterizerState_DX10()
+ {
+ this.description = new RasterizerStateDescription();
+
+ this.description.IsAntialiasedLineEnabled = false;
+
+ this.nativeRasterizerStateDirty = true;
+ }
+
+ public void Apply(Graphics.GraphicsDevice graphicsDevice)
+ {
+ GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10;
+ Device device = gdx10.NativeDevice;
+
+ UpdateNativeRasterizerState(device);
+ this.bound = true;
+
+ device.Rasterizer.State = this.nativeRasterizerState;
+ }
+
+ public void Release()
+ {
+ this.bound = false;
+ }
+
+ public void Dispose()
+ {
+ if (this.nativeRasterizerState != null)
+ {
+ this.nativeRasterizerState.Dispose();
+ this.nativeRasterizerState = null;
+ }
+ }
+
+ public bool IsBound
+ {
+ get
+ {
+ return this.bound;
+ }
+ }
+
+ public Graphics.CullMode CullMode
+ {
+ set
+ {
+ SharpDX.Direct3D10.CullMode cullMode = FormatConverter.Translate(value);
+
+ if (description.CullMode != cullMode)
+ {
+ nativeRasterizerStateDirty = true;
+ description.CullMode = cullMode;
+ }
+ }
+ }
+
+ public float DepthBias
+ {
+ set
+ {
+ // XNA uses a float value in the range of 0f..16f as value
+ // DirectX 10 uses a INT value
+
+ int depthBiasValue = (int)(value * intMaxOver16);
+
+ if (description.DepthBias != depthBiasValue)
+ {
+ nativeRasterizerStateDirty = true;
+ description.DepthBias = depthBiasValue;
+ }
+ }
+ }
+
+ public Graphics.FillMode FillMode
+ {
+ set
+ {
+ SharpDX.Direct3D10.FillMode fillMode = FormatConverter.Translate(value);
+
+ if (description.FillMode != fillMode)
+ {
+ nativeRasterizerStateDirty = true;
+ description.FillMode = fillMode;
+ }
+ }
+ }
+
+ public bool MultiSampleAntiAlias
+ {
+ set
+ {
+ if (description.IsMultisampleEnabled != value)
+ {
+ nativeRasterizerStateDirty = true;
+ description.IsMultisampleEnabled = value;
+ }
+ }
+ }
+
+ public bool ScissorTestEnable
+ {
+ set
+ {
+ if (description.IsScissorEnabled != value)
+ {
+ nativeRasterizerStateDirty = true;
+ description.IsScissorEnabled = value;
+ }
+ }
+ }
+
+ public float SlopeScaleDepthBias
+ {
+ set
+ {
+ if (description.SlopeScaledDepthBias != value)
+ {
+ nativeRasterizerStateDirty = true;
+ description.SlopeScaledDepthBias = value;
+ }
+ }
+ }
+
+ private void UpdateNativeRasterizerState(Device device)
+ {
+ if (this.nativeRasterizerStateDirty == true || this.nativeRasterizerState == null)
+ {
+ if (this.nativeRasterizerState != null)
+ {
+ this.nativeRasterizerState.Dispose();
+ this.nativeRasterizerState = null;
+ }
+
+ this.nativeRasterizerState = new SharpDX.Direct3D10.RasterizerState(device, ref this.description);
+
+ this.nativeRasterizerStateDirty = false;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/SamplerState_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/SamplerState_DX10.cs
new file mode 100644
index 00000000..eefd5fa0
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/SamplerState_DX10.cs
@@ -0,0 +1,216 @@
+#region Using Statements
+using System;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
+using SharpDX.Direct3D10;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class SamplerState_DX10 : INativeSamplerState
+ {
+ #region Private Members
+ private SamplerStateDescription description;
+ private SharpDX.Direct3D10.SamplerState nativeSamplerState;
+ private bool nativeSamplerStateDirty;
+ private bool bound;
+
+ #endregion // Private Members
+
+ public SamplerState_DX10()
+ {
+ this.description = new SamplerStateDescription();
+
+ this.nativeSamplerStateDirty = true;
+ }
+
+ public void Apply(GraphicsDevice graphicsDevice, int index)
+ {
+ GraphicsDeviceWindowsDX10 gdx10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10;
+ Device device = gdx10.NativeDevice;
+
+ UpdateNativeSamplerState(device);
+ this.bound = true;
+
+ device.PixelShader.SetSampler(index, this.nativeSamplerState);
+ }
+
+ public void Release()
+ {
+ this.bound = false;
+ }
+
+ public bool IsBound
+ {
+ get
+ {
+ return this.bound;
+ }
+ }
+
+ public ANX.Framework.Graphics.TextureAddressMode AddressU
+ {
+ set
+ {
+ SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value);
+
+ if (description.AddressU != mode)
+ {
+ description.AddressU = mode;
+ nativeSamplerStateDirty = true;
+ }
+ }
+ }
+
+ public ANX.Framework.Graphics.TextureAddressMode AddressV
+ {
+ set
+ {
+ SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value);
+
+ if (description.AddressV != mode)
+ {
+ description.AddressV = mode;
+ nativeSamplerStateDirty = true;
+ }
+ }
+ }
+
+ public ANX.Framework.Graphics.TextureAddressMode AddressW
+ {
+ set
+ {
+ SharpDX.Direct3D10.TextureAddressMode mode = FormatConverter.Translate(value);
+
+ if (description.AddressW != mode)
+ {
+ description.AddressW = mode;
+ nativeSamplerStateDirty = true;
+ }
+ }
+ }
+
+ public TextureFilter Filter
+ {
+ set
+ {
+ SharpDX.Direct3D10.Filter filter = FormatConverter.Translate(value);
+
+ if (description.Filter != filter)
+ {
+ description.Filter = filter;
+ nativeSamplerStateDirty = true;
+ }
+ }
+ }
+
+ public int MaxAnisotropy
+ {
+ set
+ {
+ if (description.MaximumAnisotropy != value)
+ {
+ description.MaximumAnisotropy = value;
+ nativeSamplerStateDirty = true;
+ }
+ }
+ }
+
+ public int MaxMipLevel
+ {
+ set
+ {
+ if (description.MaximumLod != value)
+ {
+ description.MaximumLod = value;
+ nativeSamplerStateDirty = true;
+ }
+ }
+ }
+
+ public float MipMapLevelOfDetailBias
+ {
+ set
+ {
+ if (description.MipLodBias != value)
+ {
+ description.MipLodBias = value;
+ nativeSamplerStateDirty = true;
+ }
+ }
+ }
+
+ public void Dispose()
+ {
+ if (this.nativeSamplerState != null)
+ {
+ this.nativeSamplerState.Dispose();
+ this.nativeSamplerState = null;
+ }
+ }
+
+ private void UpdateNativeSamplerState(Device device)
+ {
+ if (this.nativeSamplerStateDirty == true || this.nativeSamplerState == null)
+ {
+ if (this.nativeSamplerState != null)
+ {
+ this.nativeSamplerState.Dispose();
+ this.nativeSamplerState = null;
+ }
+
+ this.nativeSamplerState = new SharpDX.Direct3D10.SamplerState(device, ref this.description);
+
+ this.nativeSamplerStateDirty = false;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/ShaderByteCode.cs b/RenderSystems/ANX.Framework.Windows.DX10/ShaderByteCode.cs
new file mode 100644
index 00000000..47d28787
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/ShaderByteCode.cs
@@ -0,0 +1,167 @@
+#region Using Statements
+using System;
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ internal static class ShaderByteCode
+ {
+ #region SpriteBatchShader
+ internal static byte[] SpriteBatchByteCode = new byte[]
+ {
+ 068,
+ 088, 066, 067, 076, 188, 007, 250, 222, 184, 008, 085, 030, 093, 218, 008, 162, 103, 199, 180, 001,
+ 000, 000, 000, 044, 008, 000, 000, 001, 000, 000, 000, 036, 000, 000, 000, 070, 088, 049, 048, 000,
+ 008, 000, 000, 001, 016, 255, 254, 001, 000, 000, 000, 001, 000, 000, 000, 002, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 012, 007, 000, 000, 000,
+ 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 002, 000, 000, 000, 000,
+ 000, 000, 000, 036, 071, 108, 111, 098, 097, 108, 115, 000, 102, 108, 111, 097, 116, 052, 120, 052,
+ 000, 013, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 064, 000, 000, 000, 064, 000, 000,
+ 000, 064, 000, 000, 000, 011, 100, 000, 000, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115,
+ 102, 111, 114, 109, 000, 084, 101, 120, 116, 117, 114, 101, 050, 068, 000, 066, 000, 000, 000, 002,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 012,
+ 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 000, 083, 097, 109, 112, 108, 101, 114, 083, 116,
+ 097, 116, 101, 000, 112, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 021, 000, 000, 000, 084, 101, 120, 116, 117, 114, 101, 083,
+ 097, 109, 112, 108, 101, 114, 000, 083, 112, 114, 105, 116, 101, 084, 101, 099, 104, 110, 105, 113,
+ 117, 101, 000, 083, 112, 114, 105, 116, 101, 067, 111, 108, 111, 114, 080, 097, 115, 115, 000, 001,
+ 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 128, 003, 000, 000, 068, 088, 066, 067, 093,
+ 023, 212, 206, 149, 008, 160, 173, 236, 209, 184, 180, 025, 147, 008, 113, 001, 000, 000, 000, 128,
+ 003, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 008, 001, 000, 000, 120, 001, 000, 000, 236,
+ 001, 000, 000, 004, 003, 000, 000, 082, 068, 069, 070, 204, 000, 000, 000, 001, 000, 000, 000, 072,
+ 000, 000, 000, 001, 000, 000, 000, 028, 000, 000, 000, 000, 004, 254, 255, 000, 001, 000, 000, 152,
+ 000, 000, 000, 060, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 036, 071, 108, 111, 098,
+ 097, 108, 115, 000, 171, 171, 171, 060, 000, 000, 000, 001, 000, 000, 000, 096, 000, 000, 000, 064,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 120, 000, 000, 000, 000, 000, 000, 000, 064,
+ 000, 000, 000, 002, 000, 000, 000, 136, 000, 000, 000, 000, 000, 000, 000, 077, 097, 116, 114, 105,
+ 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 000, 003, 000, 003, 000, 004, 000, 004, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 077, 105, 099, 114, 111, 115, 111, 102, 116, 032, 040, 082, 041,
+ 032, 072, 076, 083, 076, 032, 083, 104, 097, 100, 101, 114, 032, 067, 111, 109, 112, 105, 108, 101,
+ 114, 032, 057, 046, 050, 057, 046, 057, 053, 050, 046, 051, 049, 049, 049, 000, 171, 171, 171, 073,
+ 083, 071, 078, 104, 000, 000, 000, 003, 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 015, 000, 000, 089,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015,
+ 015, 000, 000, 095, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002,
+ 000, 000, 000, 003, 003, 000, 000, 080, 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079,
+ 082, 000, 084, 069, 088, 067, 079, 079, 082, 068, 000, 079, 083, 071, 078, 108, 000, 000, 000, 003,
+ 000, 000, 000, 008, 000, 000, 000, 080, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 003,
+ 000, 000, 000, 000, 000, 000, 000, 015, 000, 000, 000, 092, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, 000, 000, 000, 098, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 002, 000, 000, 000, 003, 012, 000, 000, 083,
+ 086, 095, 080, 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088,
+ 067, 079, 079, 082, 068, 000, 171, 083, 072, 068, 082, 016, 001, 000, 000, 064, 000, 001, 000, 068,
+ 000, 000, 000, 089, 000, 000, 004, 070, 142, 032, 000, 000, 000, 000, 000, 004, 000, 000, 000, 095,
+ 000, 000, 003, 242, 016, 016, 000, 000, 000, 000, 000, 095, 000, 000, 003, 242, 016, 016, 000, 001,
+ 000, 000, 000, 095, 000, 000, 003, 050, 016, 016, 000, 002, 000, 000, 000, 103, 000, 000, 004, 242,
+ 032, 016, 000, 000, 000, 000, 000, 001, 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 001,
+ 000, 000, 000, 101, 000, 000, 003, 050, 032, 016, 000, 002, 000, 000, 000, 017, 000, 000, 008, 018,
+ 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 017, 000, 000, 008, 034, 032, 016, 000, 000, 000, 000, 000, 070,
+ 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 001, 000, 000, 000, 017,
+ 000, 000, 008, 066, 032, 016, 000, 000, 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070,
+ 142, 032, 000, 000, 000, 000, 000, 002, 000, 000, 000, 017, 000, 000, 008, 130, 032, 016, 000, 000,
+ 000, 000, 000, 070, 030, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 003,
+ 000, 000, 000, 054, 000, 000, 005, 242, 032, 016, 000, 001, 000, 000, 000, 070, 030, 016, 000, 001,
+ 000, 000, 000, 054, 000, 000, 005, 050, 032, 016, 000, 002, 000, 000, 000, 070, 016, 016, 000, 002,
+ 000, 000, 000, 062, 000, 000, 001, 083, 084, 065, 084, 116, 000, 000, 000, 007, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 006, 000, 000, 000, 004, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 212, 000, 000, 000, 000, 000, 000, 000, 160,
+ 002, 000, 000, 068, 088, 066, 067, 029, 076, 118, 093, 197, 015, 041, 178, 119, 144, 245, 077, 096,
+ 029, 105, 032, 001, 000, 000, 000, 160, 002, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 224,
+ 000, 000, 000, 084, 001, 000, 000, 136, 001, 000, 000, 036, 002, 000, 000, 082, 068, 069, 070, 164,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 002, 000, 000, 000, 028, 000, 000, 000, 000,
+ 004, 255, 255, 000, 001, 000, 000, 115, 000, 000, 000, 092, 000, 000, 000, 003, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 001,
+ 000, 000, 000, 107, 000, 000, 000, 002, 000, 000, 000, 005, 000, 000, 000, 004, 000, 000, 000, 255,
+ 255, 255, 255, 000, 000, 000, 000, 001, 000, 000, 000, 013, 000, 000, 000, 084, 101, 120, 116, 117,
+ 114, 101, 083, 097, 109, 112, 108, 101, 114, 000, 084, 101, 120, 116, 117, 114, 101, 000, 077, 105,
+ 099, 114, 111, 115, 111, 102, 116, 032, 040, 082, 041, 032, 072, 076, 083, 076, 032, 083, 104, 097,
+ 100, 101, 114, 032, 067, 111, 109, 112, 105, 108, 101, 114, 032, 057, 046, 050, 057, 046, 057, 053,
+ 050, 046, 051, 049, 049, 049, 000, 073, 083, 071, 078, 108, 000, 000, 000, 003, 000, 000, 000, 008,
+ 000, 000, 000, 080, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 003, 000, 000, 000, 000,
+ 000, 000, 000, 015, 000, 000, 000, 092, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003,
+ 000, 000, 000, 001, 000, 000, 000, 015, 015, 000, 000, 098, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 003, 000, 000, 000, 002, 000, 000, 000, 003, 003, 000, 000, 083, 086, 095, 080, 079,
+ 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 084, 069, 088, 067, 079, 079, 082,
+ 068, 000, 171, 079, 083, 071, 078, 044, 000, 000, 000, 001, 000, 000, 000, 008, 000, 000, 000, 032,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015,
+ 000, 000, 000, 083, 086, 095, 084, 097, 114, 103, 101, 116, 000, 171, 171, 083, 072, 068, 082, 148,
+ 000, 000, 000, 064, 000, 000, 000, 037, 000, 000, 000, 090, 000, 000, 003, 000, 096, 016, 000, 000,
+ 000, 000, 000, 088, 024, 000, 004, 000, 112, 016, 000, 000, 000, 000, 000, 085, 085, 000, 000, 098,
+ 016, 000, 003, 242, 016, 016, 000, 001, 000, 000, 000, 098, 016, 000, 003, 050, 016, 016, 000, 002,
+ 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 000, 000, 000, 000, 104, 000, 000, 002, 001,
+ 000, 000, 000, 069, 000, 000, 009, 242, 000, 016, 000, 000, 000, 000, 000, 070, 016, 016, 000, 002,
+ 000, 000, 000, 070, 126, 016, 000, 000, 000, 000, 000, 000, 096, 016, 000, 000, 000, 000, 000, 056,
+ 000, 000, 007, 242, 032, 016, 000, 000, 000, 000, 000, 070, 014, 016, 000, 000, 000, 000, 000, 070,
+ 030, 016, 000, 001, 000, 000, 000, 062, 000, 000, 001, 083, 084, 065, 084, 116, 000, 000, 000, 003,
+ 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 096, 004, 000, 000, 000,
+ 000, 000, 000, 004, 000, 000, 000, 064, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 255,
+ 255, 255, 255, 000, 000, 000, 000, 050, 000, 000, 000, 022, 000, 000, 000, 000, 000, 000, 000, 000,
+ 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 104, 000, 000, 000, 076,
+ 000, 000, 000, 000, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 153, 000, 000, 000, 125,
+ 000, 000, 000, 000, 000, 000, 000, 255, 255, 255, 255, 000, 000, 000, 000, 000, 000, 000, 000, 168,
+ 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 184, 000, 000, 000, 003, 000, 000, 000, 000,
+ 000, 000, 000, 008, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 200, 000, 000, 000, 006,
+ 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 088, 004, 000, 000, 007, 000, 000, 000, 000,
+ 000, 000, 000, 007, 000, 000, 000, 004, 007, 000, 000
+ };
+ #endregion //SpriteBatchShader
+
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/Texture2D_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/Texture2D_DX10.cs
new file mode 100644
index 00000000..2d2efa33
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/Texture2D_DX10.cs
@@ -0,0 +1,311 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.Graphics;
+using SharpDX.Direct3D10;
+using ANX.Framework.NonXNA.RenderSystem;
+using System.IO;
+using System.Runtime.InteropServices;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class Texture2D_DX10 : INativeTexture2D
+ {
+ #region Private Members
+ private SharpDX.Direct3D10.Texture2D nativeTexture;
+ private SharpDX.Direct3D10.ShaderResourceView nativeShaderResourceView;
+ private int formatSize;
+ private SurfaceFormat surfaceFormat;
+ private GraphicsDevice graphicsDevice;
+
+ #endregion // Private Members
+
+ public Texture2D_DX10(GraphicsDevice graphicsDevice, int width, int height, SurfaceFormat surfaceFormat, int mipCount)
+ {
+ if (mipCount > 1)
+ {
+ throw new Exception("creating textures with mip map not yet implemented");
+ }
+
+ this.graphicsDevice = graphicsDevice;
+ this.surfaceFormat = surfaceFormat;
+
+ GraphicsDeviceWindowsDX10 graphicsDX10 = graphicsDevice.NativeDevice as GraphicsDeviceWindowsDX10;
+ SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice;
+
+ SharpDX.Direct3D10.Texture2DDescription description = new SharpDX.Direct3D10.Texture2DDescription()
+ {
+ Width = width,
+ Height = height,
+ MipLevels = mipCount,
+ ArraySize = mipCount,
+ Format = FormatConverter.Translate(surfaceFormat),
+ SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
+ Usage = SharpDX.Direct3D10.ResourceUsage.Dynamic,
+ BindFlags = SharpDX.Direct3D10.BindFlags.ShaderResource,
+ CpuAccessFlags = SharpDX.Direct3D10.CpuAccessFlags.Write,
+ OptionFlags = SharpDX.Direct3D10.ResourceOptionFlags.None,
+ };
+ this.nativeTexture = new SharpDX.Direct3D10.Texture2D(graphicsDX10.NativeDevice, description);
+ this.nativeShaderResourceView = new SharpDX.Direct3D10.ShaderResourceView(graphicsDX10.NativeDevice, this.nativeTexture);
+
+ // description of texture formats of DX10: http://msdn.microsoft.com/en-us/library/bb694531(v=VS.85).aspx
+ // more helpfull information on DX10 textures: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205131(v=vs.85).aspx
+
+ this.formatSize = FormatConverter.FormatSize(surfaceFormat);
+ }
+
+ public override int GetHashCode()
+ {
+ return NativeTexture.NativePointer.ToInt32();
+ }
+
+ internal SharpDX.Direct3D10.Texture2D NativeTexture
+ {
+ get
+ {
+ return this.nativeTexture;
+ }
+ set
+ {
+ if (this.nativeTexture != value)
+ {
+ if (this.nativeTexture != null)
+ {
+ this.nativeTexture.Dispose();
+ }
+
+ this.nativeTexture = value;
+ }
+ }
+ }
+
+ internal SharpDX.Direct3D10.ShaderResourceView NativeShaderResourceView
+ {
+ get
+ {
+ return this.nativeShaderResourceView;
+ }
+ set
+ {
+ if (this.nativeShaderResourceView != value)
+ {
+ if (this.nativeShaderResourceView != null)
+ {
+ this.nativeShaderResourceView.Dispose();
+ }
+
+ this.nativeShaderResourceView = value;
+ }
+ }
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data) where T : struct
+ {
+ SetData(graphicsDevice, 0, data, 0, data.Length);
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ SetData(graphicsDevice, 0, data, startIndex, elementCount);
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ //TODO: handle offsetInBytes parameter
+ //TODO: handle startIndex parameter
+ //TODO: handle elementCount parameter
+
+ if (this.surfaceFormat == SurfaceFormat.Color)
+ {
+ int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubresourceIndex(0, 0, 1);
+ SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None);
+ int rowPitch = rectangle.Pitch;
+
+ unsafe
+ {
+ GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
+ byte* colorData = (byte*)handle.AddrOfPinnedObject();
+
+ byte* pTexels = (byte*)rectangle.DataPointer;
+ int srcIndex = 0;
+
+ for (int row = 0; row < Height; row++)
+ {
+ int rowStart = row * rowPitch;
+
+ for (int col = 0; col < Width; col++)
+ {
+ int colStart = col * formatSize;
+ pTexels[rowStart + colStart + 0] = colorData[srcIndex++];
+ pTexels[rowStart + colStart + 1] = colorData[srcIndex++];
+ pTexels[rowStart + colStart + 2] = colorData[srcIndex++];
+ pTexels[rowStart + colStart + 3] = colorData[srcIndex++];
+ }
+ }
+
+ handle.Free();
+ }
+
+ this.nativeTexture.Unmap(subresource);
+ }
+ else if (surfaceFormat == SurfaceFormat.Dxt5 || surfaceFormat == SurfaceFormat.Dxt3 || surfaceFormat == SurfaceFormat.Dxt1)
+ {
+ unsafe
+ {
+ GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
+ byte* colorData = (byte*)handle.AddrOfPinnedObject();
+
+ int w = (Width + 3) >> 2;
+ int h = (Height + 3) >> 2;
+ formatSize = (surfaceFormat == SurfaceFormat.Dxt1) ? 8 : 16;
+
+ int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubresourceIndex(0, 0, 1);
+ SharpDX.DataRectangle rectangle = this.nativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None);
+ SharpDX.DataStream ds = new SharpDX.DataStream(rectangle.DataPointer, Width * Height * 4 * 2, true, true);
+ int pitch = rectangle.Pitch;
+ int col = 0;
+ int index = 0; // startIndex
+ int count = data.Length; // elementCount
+ int actWidth = w * formatSize;
+
+ for (int i = 0; i < h; i++)
+ {
+ ds.Position = (i * pitch) + (col * formatSize);
+ if (count <= 0)
+ {
+ break;
+ }
+ else if (count < actWidth)
+ {
+ for (int idx = index; idx < index + count; idx++)
+ {
+ ds.WriteByte(colorData[idx]);
+ }
+ //ds.WriteRange(colorDataArray, index, count);
+
+ break;
+ }
+
+ for (int idx = index; idx < index + actWidth; idx++)
+ {
+ ds.WriteByte(colorData[idx]);
+ }
+ //ds.WriteRange(colorDataArray, index, actWidth);
+
+ index += actWidth;
+ count -= actWidth;
+ }
+
+ handle.Free();
+
+ this.nativeTexture.Unmap(subresource);
+ }
+ }
+ else
+ {
+ throw new Exception(string.Format("creating textures of format {0} not yet implemented...", surfaceFormat.ToString()));
+ }
+ }
+
+ public int Width
+ {
+ get
+ {
+ if (this.nativeTexture != null)
+ {
+ return this.nativeTexture.Description.Width;
+ }
+
+ return 0;
+ }
+ }
+
+ public int Height
+ {
+ get
+ {
+ if (this.nativeTexture != null)
+ {
+ return this.nativeTexture.Description.Height;
+ }
+
+ return 0;
+ }
+ }
+
+ public GraphicsDevice GraphicsDevice
+ {
+ get
+ {
+ return this.graphicsDevice;
+ }
+ }
+
+ public void Dispose()
+ {
+ if (this.nativeShaderResourceView != null)
+ {
+ this.nativeShaderResourceView.Dispose();
+ this.nativeShaderResourceView = null;
+ }
+
+ if (this.nativeTexture != null)
+ {
+ this.nativeTexture.Dispose();
+ this.nativeTexture = null;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/VertexBuffer_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/VertexBuffer_DX10.cs
new file mode 100644
index 00000000..257e446a
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/VertexBuffer_DX10.cs
@@ -0,0 +1,158 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.NonXNA;
+using SharpDX.Direct3D10;
+using ANX.Framework.Graphics;
+using System.Runtime.InteropServices;
+
+#endregion // Using Statements
+
+#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.Windows.DX10
+{
+ public class VertexBuffer_DX10 : INativeBuffer, IDisposable
+ {
+ SharpDX.Direct3D10.Buffer buffer;
+ int vertexStride;
+
+ public VertexBuffer_DX10(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
+ {
+ this.vertexStride = vertexDeclaration.VertexStride;
+
+ //TODO: translate and use usage
+
+ GraphicsDeviceWindowsDX10 gd10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
+ SharpDX.Direct3D10.Device device = gd10 != null ? gd10.NativeDevice as SharpDX.Direct3D10.Device : null;
+
+ if (device != null)
+ {
+ BufferDescription description = new BufferDescription()
+ {
+ Usage = ResourceUsage.Dynamic,
+ SizeInBytes = vertexDeclaration.VertexStride * vertexCount,
+ BindFlags = BindFlags.VertexBuffer,
+ CpuAccessFlags = CpuAccessFlags.Write,
+ OptionFlags = ResourceOptionFlags.None
+ };
+
+ this.buffer = new SharpDX.Direct3D10.Buffer(device, description);
+ this.buffer.Unmap();
+ }
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ //TODO: check offsetInBytes parameter for bounds etc.
+
+ GCHandle pinnedArray = GCHandle.Alloc(data, GCHandleType.Pinned);
+ IntPtr dataPointer = pinnedArray.AddrOfPinnedObject();
+
+ int dataLength = Marshal.SizeOf(typeof(T)) * data.Length;
+
+ unsafe
+ {
+ using (var vData = new SharpDX.DataStream(dataPointer, dataLength, true, false))
+ {
+ if (offsetInBytes > 0)
+ {
+ vData.Seek(offsetInBytes / vertexStride, System.IO.SeekOrigin.Begin);
+ }
+
+ using (var d = buffer.Map(MapMode.WriteDiscard))
+ {
+ if (startIndex > 0 || elementCount < data.Length)
+ {
+ for (int i = startIndex; i < startIndex + elementCount; i++)
+ {
+ d.Write(data[i]);
+ }
+ }
+ else
+ {
+ vData.CopyTo(d);
+ }
+ buffer.Unmap();
+ }
+ }
+ }
+
+ pinnedArray.Free();
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data) where T : struct
+ {
+ SetData(graphicsDevice, data, 0, data.Length);
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ SetData(graphicsDevice, 0, data, startIndex, elementCount);
+ }
+
+ public SharpDX.Direct3D10.Buffer NativeBuffer
+ {
+ get
+ {
+ return this.buffer;
+ }
+ }
+
+ public void Dispose()
+ {
+ if (this.buffer != null)
+ {
+ buffer.Dispose();
+ buffer = null;
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/WindowsGameHost.cs b/RenderSystems/ANX.Framework.Windows.DX10/WindowsGameHost.cs
new file mode 100644
index 00000000..f0712769
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/WindowsGameHost.cs
@@ -0,0 +1,136 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using ANX.Framework.Windows.DX10;
+using ANX.Framework.Input;
+
+#endregion // Using Statements
+
+#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
+{
+ public class WindowsGameHost : GameHost
+ {
+ private Game game;
+ private WindowsGameWindow gameWindow;
+ private bool exitRequested;
+
+ public WindowsGameHost(Game game)
+ : base(game)
+ {
+ this.game = game;
+ //this.LockThreadToProcessor();
+ this.gameWindow = new WindowsGameWindow();
+ Mouse.WindowHandle = this.gameWindow.Handle; //TODO: find a way to initialize all InputSystems with one Handle
+ Keyboard.WindowHandle = this.gameWindow.Handle;
+ //TouchPanel.WindowHandle = this.gameWindow.Handle;
+ //this.gameWindow.IsMouseVisible = game.IsMouseVisible;
+ this.gameWindow.Activated += new EventHandler(this.GameWindowActivated);
+ this.gameWindow.Deactivated += new EventHandler(this.GameWindowDeactivated);
+ //this.gameWindow.Suspend += new EventHandler(this.GameWindowSuspend);
+ //this.gameWindow.Resume += new EventHandler(this.GameWindowResume);
+
+ }
+
+ public override void Run()
+ {
+ Application.Idle += new EventHandler(this.ApplicationIdle);
+ Application.Run(this.gameWindow.Form);
+ Application.Idle -= this.ApplicationIdle;
+ }
+
+ public void RunOneFrame()
+ {
+ //this.gameWindow.Tick();
+ base.OnIdle();
+ }
+
+ public override GameWindow Window
+ {
+ get
+ {
+ return this.gameWindow;
+ }
+ }
+
+ public override void Exit()
+ {
+ this.exitRequested = true;
+ }
+
+ private void GameWindowActivated(object sender, EventArgs e)
+ {
+ base.OnActivated();
+ }
+
+ private void GameWindowDeactivated(object sender, EventArgs e)
+ {
+ base.OnDeactivated();
+ }
+
+ private void ApplicationIdle(object sender, EventArgs e)
+ {
+ NativeMethods.Message message;
+ while (!NativeMethods.PeekMessage(out message, IntPtr.Zero, 0, 0, 0))
+ {
+ if (this.exitRequested)
+ {
+ this.gameWindow.Close();
+ }
+ else
+ {
+ this.RunOneFrame();
+ }
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.DX10/WindowsGameWindow.cs b/RenderSystems/ANX.Framework.Windows.DX10/WindowsGameWindow.cs
new file mode 100644
index 00000000..c1f84047
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.DX10/WindowsGameWindow.cs
@@ -0,0 +1,159 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Windows.Forms;
+using SharpDX.Windows;
+
+#endregion // Using Statements
+
+#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
+{
+ internal class WindowsGameWindow : GameWindow
+ {
+ #region Private Members
+ private RenderForm gameWindow;
+
+ #endregion // Private Members
+
+ internal WindowsGameWindow()
+ {
+ this.gameWindow = new RenderForm("ANX Framework");
+
+ this.gameWindow.MaximizeBox = false;
+ this.gameWindow.FormBorderStyle = FormBorderStyle.Fixed3D;
+ }
+
+ public void Close()
+ {
+ if (gameWindow != null)
+ {
+ gameWindow.Close();
+ }
+ }
+
+ public Form Form
+ {
+ get
+ {
+ return gameWindow;
+ }
+ }
+
+ public override IntPtr Handle
+ {
+ get
+ {
+ return gameWindow.Handle;
+ }
+ }
+
+ public override bool IsMinimized
+ {
+ get
+ {
+ return gameWindow.WindowState == FormWindowState.Minimized;
+ }
+ }
+
+ public override void BeginScreenDeviceChange(bool willBeFullScreen)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void EndScreenDeviceChange(string screenDeviceName, int clientWidth, int clientHeight)
+ {
+ throw new NotImplementedException();
+ }
+
+ protected override void SetTitle(string title)
+ {
+ this.gameWindow.Text = title;
+ }
+
+ public override bool AllowUserResizing
+ {
+ get
+ {
+ return gameWindow.FormBorderStyle == FormBorderStyle.Sizable;
+ }
+ set
+ {
+ if (value)
+ {
+ gameWindow.FormBorderStyle = FormBorderStyle.Sizable;
+ }
+ else
+ {
+ gameWindow.FormBorderStyle = FormBorderStyle.Fixed3D;
+ }
+ }
+ }
+
+ public override Rectangle ClientBounds
+ {
+ get
+ {
+ return new Rectangle(this.gameWindow.ClientRectangle.Left, this.gameWindow.ClientRectangle.Top, this.gameWindow.ClientRectangle.Width, this.gameWindow.ClientRectangle.Height);
+ }
+ }
+
+ public override string ScreenDeviceName
+ {
+ get { throw new NotImplementedException(); }
+ }
+
+ public override DisplayOrientation CurrentOrientation
+ {
+ get { throw new NotImplementedException(); }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj b/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj
new file mode 100644
index 00000000..b57cd551
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj
@@ -0,0 +1,79 @@
+
+
+
+ Debug
+ AnyCPU
+ 8.0.30703
+ 2.0
+ {EB8258E0-6741-4DB9-B756-1EBDF67B1ED6}
+ Library
+ Properties
+ ANX.Framework.Windows.GL3
+ ANX.Framework.Windows.GL3
+ v4.0
+ 512
+
+
+ true
+ full
+ false
+ ..\..\bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ x86
+
+
+ pdbonly
+ true
+ ..\bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+ False
+ ..\lib\OpenTK\OpenTK.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}
+ ANX.Framework
+
+
+
+
+ "$(ProjectDir)../../Tools/bin/sscg.exe" ../../../shader/GL3/build.xml
+
+
+
\ No newline at end of file
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/BlendStateGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/BlendStateGL3.cs
new file mode 100644
index 00000000..900bd31e
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/BlendStateGL3.cs
@@ -0,0 +1,378 @@
+using System;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
+using OpenTK.Graphics.OpenGL;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native Blend State object for OpenGL.
+ ///
+ /// Basically this is a wrapper class for setting the different values all
+ /// at once, because OpenGL has no State objects like DirectX.
+ ///
+ /// For Information on OpenGL blending: http://www.opengl.org/wiki/Blending
+ ///
+ public class BlendStateGL3 : INativeBlendState
+ {
+ #region Public
+ #region IsBound
+ ///
+ /// Flag if the blend state is bound to the device or not.
+ ///
+ public bool IsBound
+ {
+ get;
+ private set;
+ }
+ #endregion
+
+ #region AlphaBlendFunction
+ public BlendFunction AlphaBlendFunction
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region ColorBlendFunction
+ public BlendFunction ColorBlendFunction
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region AlphaSourceBlend
+ public Blend AlphaSourceBlend
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region AlphaDestinationBlend
+ public Blend AlphaDestinationBlend
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region ColorSourceBlend
+ public Blend ColorSourceBlend
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region ColorDestinationBlend
+ public Blend ColorDestinationBlend
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region ColorWriteChannels
+ public ColorWriteChannels ColorWriteChannels
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region ColorWriteChannels1
+ public ColorWriteChannels ColorWriteChannels1
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region ColorWriteChannels2
+ public ColorWriteChannels ColorWriteChannels2
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region ColorWriteChannels3
+ public ColorWriteChannels ColorWriteChannels3
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region BlendFactor
+ public Color BlendFactor
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region MultiSampleMask
+ public int MultiSampleMask
+ {
+ set;
+ private get;
+ }
+ #endregion
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new OpenGL Blend State wrapper object.
+ ///
+ internal BlendStateGL3()
+ {
+ IsBound = false;
+ }
+ #endregion
+
+ #region Apply
+ ///
+ /// Apply the blend state on the graphics device.
+ ///
+ /// The current graphics device.
+ public void Apply(GraphicsDevice graphicsDevice)
+ {
+ IsBound = true;
+
+ GL.BlendEquationSeparate(
+ TranslateBlendFunction(ColorBlendFunction),
+ TranslateBlendFunction(AlphaBlendFunction));
+
+ GL.BlendFuncSeparate(
+ TranslateBlendSrc(ColorSourceBlend),
+ TranslateBlendDest(ColorDestinationBlend),
+ TranslateBlendSrc(AlphaSourceBlend),
+ TranslateBlendDest(AlphaDestinationBlend));
+
+ SetColorWriteChannel(0, ColorWriteChannels);
+ SetColorWriteChannel(1, ColorWriteChannels1);
+ SetColorWriteChannel(2, ColorWriteChannels2);
+ SetColorWriteChannel(3, ColorWriteChannels3);
+
+ GL.BlendColor(BlendFactor.R * DatatypesMapping.ColorMultiplier,
+ BlendFactor.G * DatatypesMapping.ColorMultiplier,
+ BlendFactor.B * DatatypesMapping.ColorMultiplier,
+ BlendFactor.A * DatatypesMapping.ColorMultiplier);
+
+// TODO: multi sample mask
+ }
+ #endregion
+
+ #region Release
+ ///
+ /// Release the blend state.
+ ///
+ public void Release()
+ {
+ IsBound = false;
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose this blend state object.
+ ///
+ public void Dispose()
+ {
+ }
+
+ #endregion
+
+ #region SetColorWriteChannel
+ ///
+ /// Set the color mask for the specified index.
+ ///
+ /// Index of the color mask.
+ /// Mask channels to enable.
+ private void SetColorWriteChannel(int index, ColorWriteChannels channels)
+ {
+ bool r = (channels == Graphics.ColorWriteChannels.All ||
+ channels == Graphics.ColorWriteChannels.Red);
+ bool g = (channels == Graphics.ColorWriteChannels.All ||
+ channels == Graphics.ColorWriteChannels.Green);
+ bool b = (channels == Graphics.ColorWriteChannels.All ||
+ channels == Graphics.ColorWriteChannels.Blue);
+ bool a = (channels == Graphics.ColorWriteChannels.All ||
+ channels == Graphics.ColorWriteChannels.Alpha);
+
+ GL.ColorMask(index, r, g, b, a);
+ }
+ #endregion
+
+ #region TranslateBlendSrc
+ ///
+ /// Translate the ANX Blend mode to the OpenGL Blend Factor Source.
+ ///
+ /// ANX Blend Function.
+ /// OpenGL Blend Factor Source.
+ private BlendingFactorSrc TranslateBlendSrc(Blend blending)
+ {
+ switch (blending)
+ {
+ default:
+ throw new NotSupportedException("The blend mode '" + blending +
+ "' is not supported for OpenGL BlendingFactorSrc!");
+
+ case Blend.SourceAlpha:
+ return BlendingFactorSrc.SrcAlpha;
+
+ case Blend.DestinationAlpha:
+ return BlendingFactorSrc.DstAlpha;
+
+ case Blend.DestinationColor:
+ return BlendingFactorSrc.DstColor;
+
+ case Blend.InverseDestinationAlpha:
+ return BlendingFactorSrc.OneMinusDstAlpha;
+
+ case Blend.InverseDestinationColor:
+ return BlendingFactorSrc.OneMinusDstColor;
+
+ case Blend.InverseSourceAlpha:
+ return BlendingFactorSrc.OneMinusSrcAlpha;
+
+ case Blend.One:
+ return BlendingFactorSrc.One;
+
+ case Blend.SourceAlphaSaturation:
+ return BlendingFactorSrc.SrcAlphaSaturate;
+
+ case Blend.Zero:
+ return BlendingFactorSrc.Zero;
+ }
+ }
+ #endregion
+
+ #region TranslateBlendDest
+ ///
+ /// Translate the ANX Blend mode to the OpenGL Blend Factor Destination.
+ ///
+ /// ANX Blend Function.
+ /// OpenGL Blend Factor Destination.
+ private BlendingFactorDest TranslateBlendDest(Blend blending)
+ {
+ switch (blending)
+ {
+ case Blend.SourceAlpha:
+ return BlendingFactorDest.SrcAlpha;
+
+ default:
+ throw new NotSupportedException("The blend mode '" + blending +
+ "' is not supported for OpenGL BlendingFactorDest!");
+
+ case Blend.DestinationAlpha:
+ return BlendingFactorDest.DstAlpha;
+
+ case Blend.DestinationColor:
+ return BlendingFactorDest.DstColor;
+
+ case Blend.InverseDestinationAlpha:
+ return BlendingFactorDest.OneMinusDstAlpha;
+
+ case Blend.InverseDestinationColor:
+ return BlendingFactorDest.OneMinusDstColor;
+
+ case Blend.InverseSourceAlpha:
+ return BlendingFactorDest.OneMinusSrcAlpha;
+
+ case Blend.InverseSourceColor:
+ return BlendingFactorDest.OneMinusSrcColor;
+
+ case Blend.One:
+ return BlendingFactorDest.One;
+
+ case Blend.SourceColor:
+ return BlendingFactorDest.SrcColor;
+
+ case Blend.Zero:
+ return BlendingFactorDest.Zero;
+ }
+ }
+ #endregion
+
+ #region TranslateBlendFunction
+ ///
+ /// Translate the ANX Blend Function to the OpenGL Blend Equation Mode.
+ ///
+ /// ANX Blend Function.
+ /// OpenGL Blend Equation Mode.
+ private BlendEquationMode TranslateBlendFunction(BlendFunction func)
+ {
+ switch (func)
+ {
+ default:
+ case BlendFunction.Add:
+ return BlendEquationMode.FuncAdd;
+
+ case BlendFunction.Subtract:
+ return BlendEquationMode.FuncSubtract;
+
+ case BlendFunction.ReverseSubtract:
+ return BlendEquationMode.FuncReverseSubtract;
+
+ case BlendFunction.Min:
+ return BlendEquationMode.Min;
+
+ case BlendFunction.Max:
+ return BlendEquationMode.Max;
+ }
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs b/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs
new file mode 100644
index 00000000..f2a88183
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs
@@ -0,0 +1,289 @@
+using System;
+using System.IO;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
+using System.Collections.ObjectModel;
+using OpenTK;
+using System.Collections.Generic;
+using System.Windows.Forms;
+using ANX.Framework.NonXNA.RenderSystem;
+
+#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.Windows.GL3
+{
+ ///
+ /// OpenGL graphics creator.
+ ///
+ public class Creator : IRenderSystemCreator
+ {
+ #region Public
+ ///
+ /// Name of the Creator implementation.
+ ///
+ public string Name
+ {
+ get
+ {
+ return "OpenGL3";
+ }
+ }
+ #endregion
+
+ #region RegisterRenderSystemCreator
+ public void RegisterCreator(AddInSystemFactory factory)
+ {
+ factory.AddCreator(this);
+ }
+ #endregion
+
+ #region CreateGameHost
+ public GameHost CreateGameHost(Game game)
+ {
+ return new WindowsGameHost(game);
+ }
+ #endregion
+
+ #region CreateEffect
+ public INativeEffect CreateEffect(GraphicsDevice graphics, Stream byteCode)
+ {
+ return new EffectGL3(byteCode);
+ }
+
+ public INativeEffect CreateEffect(GraphicsDevice graphics,
+ Stream vertexShaderByteCode, Stream pixelShaderByteCode)
+ {
+ return new EffectGL3(vertexShaderByteCode, pixelShaderByteCode);
+ }
+ #endregion
+
+ #region CreateGraphicsDevice
+ INativeGraphicsDevice IRenderSystemCreator.CreateGraphicsDevice(
+ PresentationParameters presentationParameters)
+ {
+ return new GraphicsDeviceWindowsGL3(presentationParameters);
+ }
+ #endregion
+
+ #region CreateTexture
+ ///
+ /// Create a new native texture.
+ ///
+ /// Graphics device.
+ /// The format of the texture.
+ /// The width of the texture.
+ /// The height of the texture.
+ /// The number of mipmaps in the texture.
+ ///
+ public INativeTexture2D CreateTexture(GraphicsDevice graphics,
+ SurfaceFormat surfaceFormat, int width, int height, int mipCount)
+ {
+ return new Texture2DGL3(surfaceFormat, width, height, mipCount);
+ }
+ #endregion
+
+ #region CreateIndexBuffer
+ ///
+ /// Create a native index buffer.
+ ///
+ /// The current graphics device.
+ /// The size of a single index element.
+ /// The number of indices stored in the buffer.
+ ///
+ /// The usage type of the buffer.
+ /// Native OpenGL index buffer.
+ public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics,
+ IndexElementSize size, int indexCount, BufferUsage usage)
+ {
+ return new IndexBufferGL3(size, indexCount, usage);
+ }
+ #endregion
+
+ #region CreateVertexBuffer
+ ///
+ /// Create a native vertex buffer.
+ ///
+ /// The current graphics device.
+ /// The vertex declaration for the buffer.
+ /// The number of vertices stored in the buffer.
+ ///
+ /// The usage type of the buffer.
+ /// Native OpenGL vertex buffer.
+ public INativeBuffer CreateVertexBuffer(GraphicsDevice graphics,
+ VertexDeclaration vertexDeclaration, int vertexCount,
+ BufferUsage usage)
+ {
+ return new VertexBufferGL3(vertexDeclaration, vertexCount, usage);
+ }
+ #endregion
+
+ #region CreateBlendState
+ ///
+ /// Create a new native blend state.
+ ///
+ /// Native Blend State.
+ public INativeBlendState CreateBlendState()
+ {
+ return new BlendStateGL3();
+ }
+ #endregion
+
+ #region CreateBlendState
+ ///
+ /// Create a new native rasterizer state.
+ ///
+ /// Native Rasterizer State.
+ public INativeRasterizerState CreateRasterizerState()
+ {
+ return new RasterizerStateGL3();
+ }
+ #endregion
+
+ #region CreateDepthStencilState
+ ///
+ /// Create a new native Depth Stencil State.
+ ///
+ /// Native Depth Stencil State.
+ public INativeDepthStencilState CreateDepthStencilState()
+ {
+ return new DepthStencilStateGL3();
+ }
+ #endregion
+
+ #region CreateSamplerState
+ ///
+ /// Create a new native sampler state.
+ ///
+ /// Native Sampler State.
+ public INativeSamplerState CreateSamplerState()
+ {
+ return new SamplerStateGL3();
+ }
+ #endregion
+
+ #region GetShaderByteCode (TODO)
+ ///
+ /// Get the byte code of a pre defined shader.
+ ///
+ /// Pre defined shader type.
+ /// Byte code of the shader.
+ public byte[] GetShaderByteCode(PreDefinedShader type)
+ {
+ switch (type)
+ {
+ case PreDefinedShader.SpriteBatch:
+ return ShaderByteCode.SpriteBatchByteCode;
+
+ default:
+ throw new NotSupportedException("The predefined shader '" + type +
+ "' isn't supported yet!");
+ }
+ }
+ #endregion
+
+ #region GetAdapterList
+ ///
+ /// Get a list of available graphics adapter information.
+ ///
+ /// List of graphics adapters.
+ public ReadOnlyCollection GetAdapterList()
+ {
+ var result = new List();
+ foreach (DisplayDevice device in DisplayDevice.AvailableDisplays)
+ {
+ var displayModeCollection = new DisplayModeCollection();
+ foreach (string format in Enum.GetNames(typeof(SurfaceFormat)))
+ {
+ SurfaceFormat surfaceFormat =
+ (SurfaceFormat)Enum.Parse(typeof(SurfaceFormat), format);
+
+ // TODO: device.BitsPerPixel
+ if (surfaceFormat != SurfaceFormat.Color)//adapter.Supports(surfaceFormat) == false)
+ {
+ continue;
+ }
+
+ var modes = new List();
+
+ foreach (DisplayResolution res in device.AvailableResolutions)
+ {
+ float aspect = (float)res.Width / (float)res.Height;
+ modes.Add(new DisplayMode
+ {
+ AspectRatio = aspect,
+ Width = res.Width,
+ Height = res.Height,
+ TitleSafeArea = new Rectangle(0, 0, res.Width, res.Height),
+ Format = surfaceFormat,
+ });
+ }
+
+ displayModeCollection[surfaceFormat] = modes.ToArray();
+ }
+
+ GraphicsAdapter newAdapter = new GraphicsAdapter
+ {
+ SupportedDisplayModes = displayModeCollection,
+ IsDefaultAdapter = device.IsPrimary,
+
+ // TODO:
+ DeviceId = 0,
+ DeviceName = "",
+ Revision = 0,
+ SubSystemId = 0,
+ VendorId = 0,
+ };
+
+ result.Add(newAdapter);
+ }
+
+ return new ReadOnlyCollection(result);
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/DatatypesMapping.cs b/RenderSystems/ANX.Framework.Windows.GL3/DatatypesMapping.cs
new file mode 100644
index 00000000..6a2854fa
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/DatatypesMapping.cs
@@ -0,0 +1,252 @@
+using System;
+using ANX.Framework.Graphics;
+using OpenTK.Graphics;
+using OpenTK.Graphics.OpenGL;
+
+#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.Windows.GL3
+{
+ internal static class DatatypesMapping
+ {
+ #region Constants
+ public const float ColorMultiplier = 1f / 255f;
+ #endregion
+
+ #region Convert ANX.Color -> OpenTK.Color4
+ public static void Convert(ref Color anxColor, out Color4 otkColor)
+ {
+ otkColor.R = anxColor.R * ColorMultiplier;
+ otkColor.G = anxColor.G * ColorMultiplier;
+ otkColor.B = anxColor.B * ColorMultiplier;
+ otkColor.A = anxColor.A * ColorMultiplier;
+ }
+ #endregion
+
+ #region Convert OpenTK.Color4 -> ANX.Color
+ public static void Convert(ref Color4 otkColor, out Color anxColor)
+ {
+ byte r = (byte)(otkColor.R * 255);
+ byte g = (byte)(otkColor.G * 255);
+ byte b = (byte)(otkColor.B * 255);
+ byte a = (byte)(otkColor.A * 255);
+ anxColor.packedValue = (uint)(r + (g << 8) + (b << 16) + (a << 24));
+ }
+ #endregion
+
+ #region Convert ANX.Vector4 -> ANX.Color
+ public static void Convert(ref Vector4 anxVector, out Color anxColor)
+ {
+ byte r = (byte)(anxVector.X * 255);
+ byte g = (byte)(anxVector.Y * 255);
+ byte b = (byte)(anxVector.Z * 255);
+ byte a = (byte)(anxVector.W * 255);
+ anxColor.packedValue = (uint)(r + (g << 8) + (b << 16) + (a << 24));
+ }
+ #endregion
+
+ #region SurfaceToColorFormat (TODO)
+ ///
+ /// Translate the XNA surface format to an OpenGL ColorFormat.
+ ///
+ /// XNA surface format.
+ /// Translated color format for OpenGL.
+ public static ColorFormat SurfaceToColorFormat(SurfaceFormat format)
+ {
+ switch (format)
+ {
+ // TODO
+ case SurfaceFormat.Dxt1:
+ case SurfaceFormat.Dxt3:
+ case SurfaceFormat.Dxt5:
+ case SurfaceFormat.HdrBlendable:
+ throw new NotImplementedException("Surface Format '" + format +
+ "' isn't implemented yet!");
+
+ // TODO: CHECK!
+ case SurfaceFormat.NormalizedByte2:
+ return new ColorFormat(8, 8, 0, 0);
+
+ //DONE
+ default:
+ case SurfaceFormat.Color:
+ case SurfaceFormat.NormalizedByte4:
+ return new ColorFormat(8, 8, 8, 8);
+
+ case SurfaceFormat.HalfVector2:
+ return new ColorFormat(16, 16, 0, 0);
+
+ case SurfaceFormat.HalfVector4:
+ return new ColorFormat(16, 16, 16, 16);
+
+ case SurfaceFormat.Bgra4444:
+ return new ColorFormat(4, 4, 4, 4);
+
+ case SurfaceFormat.Bgra5551:
+ return new ColorFormat(5, 5, 5, 1);
+
+ case SurfaceFormat.Alpha8:
+ return new ColorFormat(0, 0, 0, 8);
+
+ case SurfaceFormat.Bgr565:
+ return new ColorFormat(5, 6, 5, 0);
+
+ case SurfaceFormat.Rg32:
+ return new ColorFormat(16, 16, 0, 0);
+
+ case SurfaceFormat.Rgba1010102:
+ return new ColorFormat(10, 10, 10, 2);
+
+ case SurfaceFormat.Rgba64:
+ return new ColorFormat(16, 16, 16, 16);
+
+ case SurfaceFormat.HalfSingle:
+ return new ColorFormat(16, 0, 0, 0);
+
+ case SurfaceFormat.Single:
+ return new ColorFormat(32, 0, 0, 0);
+
+ case SurfaceFormat.Vector2:
+ return new ColorFormat(32, 32, 0, 0);
+
+ case SurfaceFormat.Vector4:
+ return new ColorFormat(32, 32, 32, 32);
+ }
+ }
+ #endregion
+
+ #region SurfaceToPixelInternalFormat (TODO)
+ ///
+ /// Translate the XNA surface format to an OpenGL PixelInternalFormat.
+ ///
+ /// XNA surface format.
+ /// Translated format for OpenGL.
+ public static PixelInternalFormat SurfaceToPixelInternalFormat(
+ SurfaceFormat format)
+ {
+ switch (format)
+ {
+ // TODO
+ case SurfaceFormat.HdrBlendable:
+ case SurfaceFormat.Bgr565:
+ throw new NotImplementedException("Surface Format '" + format +
+ "' isn't implemented yet!");
+
+ // TODO: CHECK!
+ case SurfaceFormat.NormalizedByte2:
+ return PixelInternalFormat.Rg8;
+
+ default:
+ case SurfaceFormat.Color:
+ case SurfaceFormat.NormalizedByte4:
+ return PixelInternalFormat.Rgba;
+
+ case SurfaceFormat.Dxt1:
+ return PixelInternalFormat.CompressedRgbaS3tcDxt1Ext;
+
+ case SurfaceFormat.Dxt3:
+ return PixelInternalFormat.CompressedRgbaS3tcDxt3Ext;
+
+ case SurfaceFormat.Dxt5:
+ return PixelInternalFormat.CompressedRgbaS3tcDxt5Ext;
+
+ case SurfaceFormat.HalfVector2:
+ return PixelInternalFormat.Rg16;
+
+ case SurfaceFormat.HalfVector4:
+ return PixelInternalFormat.Rgba16f;
+
+ case SurfaceFormat.Bgra4444:
+ return PixelInternalFormat.Rgba4;
+
+ case SurfaceFormat.Bgra5551:
+ return PixelInternalFormat.Rgb5A1;
+
+ case SurfaceFormat.Alpha8:
+ return PixelInternalFormat.Alpha8;
+
+ case SurfaceFormat.Rg32:
+ return PixelInternalFormat.Rg32f;
+
+ case SurfaceFormat.Rgba1010102:
+ return PixelInternalFormat.Rgb10A2;
+
+ case SurfaceFormat.Rgba64:
+ return PixelInternalFormat.Rgba16f;
+
+ case SurfaceFormat.HalfSingle:
+ return PixelInternalFormat.R16f;
+
+ case SurfaceFormat.Single:
+ return PixelInternalFormat.R32f;
+
+ case SurfaceFormat.Vector2:
+ return PixelInternalFormat.Rg32f;
+
+ case SurfaceFormat.Vector4:
+ return PixelInternalFormat.Rgba32f;
+ }
+ }
+ #endregion
+
+ #region Tests
+ private class Tests
+ {
+ #region TestConvertVector4ToColor
+ public static void TestConvertVector4ToColor()
+ {
+ Vector4 vector = new Vector4(1f, 0.5f, 0.75f, 0f);
+ Color color;
+ DatatypesMapping.Convert(ref vector, out color);
+ Console.WriteLine(color.ToString());
+ }
+ #endregion
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/DepthStencilStateGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/DepthStencilStateGL3.cs
new file mode 100644
index 00000000..b9765782
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/DepthStencilStateGL3.cs
@@ -0,0 +1,420 @@
+using System;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+using OpenTK.Graphics.OpenGL;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native Depth Stencil State object for OpenGL.
+ ///
+ /// Basically this is a wrapper class for setting the different values all
+ /// at once, because OpenGL has no State objects like DirectX.
+ ///
+ public class DepthStencilStateGL3 : INativeDepthStencilState
+ {
+ #region Public
+ #region IsBound
+ ///
+ /// Flag if the state object is bound to the device.
+ ///
+ public bool IsBound
+ {
+ get;
+ private set;
+ }
+ #endregion
+
+ #region DepthBufferEnable
+ public bool DepthBufferEnable
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region DepthBufferFunction
+ public CompareFunction DepthBufferFunction
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region DepthBufferWriteEnable
+ public bool DepthBufferWriteEnable
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region StencilEnable
+ public bool StencilEnable
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region StencilFunction
+ public CompareFunction StencilFunction
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region StencilMask
+ public int StencilMask
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region StencilDepthBufferFail
+ public StencilOperation StencilDepthBufferFail
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region StencilFail
+ public StencilOperation StencilFail
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region StencilPass
+ public StencilOperation StencilPass
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region CounterClockwiseStencilDepthBufferFail
+ public StencilOperation CounterClockwiseStencilDepthBufferFail
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region CounterClockwiseStencilFail
+ public StencilOperation CounterClockwiseStencilFail
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region CounterClockwiseStencilFunction
+ public CompareFunction CounterClockwiseStencilFunction
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region CounterClockwiseStencilPass
+ public StencilOperation CounterClockwiseStencilPass
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region TwoSidedStencilMode
+ public bool TwoSidedStencilMode
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region ReferenceStencil
+ public int ReferenceStencil
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region StencilWriteMask
+ public int StencilWriteMask
+ {
+ set;
+ private get;
+ }
+ #endregion
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new depth stencil state object.
+ ///
+ internal DepthStencilStateGL3()
+ {
+ IsBound = false;
+ }
+ #endregion
+
+ #region Apply
+ ///
+ /// Apply the depth stencil state to the graphics device.
+ ///
+ /// The current graphics device.
+ public void Apply(GraphicsDevice graphicsDevice)
+ {
+ IsBound = true;
+
+ #region Depth
+ if (DepthBufferEnable)
+ {
+ GL.Enable(EnableCap.DepthTest);
+ }
+ else
+ {
+ GL.Disable(EnableCap.DepthTest);
+ }
+
+ GL.DepthFunc(TranslateDepthFunction(DepthBufferFunction));
+
+ GL.DepthMask(DepthBufferWriteEnable);
+ #endregion
+
+ #region Stencil
+ if (StencilEnable)
+ {
+ GL.Enable(EnableCap.StencilTest);
+ }
+ else
+ {
+ GL.Disable(EnableCap.StencilTest);
+ }
+
+ GL.StencilMask(StencilWriteMask);
+
+ if (TwoSidedStencilMode)
+ {
+ GL.StencilOpSeparate(StencilFace.Front,
+ TranslateStencilOp(StencilFail),
+ TranslateStencilOp(StencilDepthBufferFail),
+ TranslateStencilOp(StencilPass));
+
+ GL.StencilOpSeparate(StencilFace.Back,
+ TranslateStencilOp(CounterClockwiseStencilFail),
+ TranslateStencilOp(CounterClockwiseStencilDepthBufferFail),
+ TranslateStencilOp(CounterClockwiseStencilPass));
+
+ GL.StencilFuncSeparate(StencilFace.Front,
+ TranslateStencilFunction(StencilFunction),
+ ReferenceStencil, StencilMask);
+
+ GL.StencilFuncSeparate(StencilFace.Back,
+ TranslateStencilFunction(CounterClockwiseStencilFunction),
+ ReferenceStencil, StencilMask);
+ }
+ else
+ {
+ GL.StencilOp(
+ TranslateStencilOp(StencilFail),
+ TranslateStencilOp(StencilDepthBufferFail),
+ TranslateStencilOp(StencilPass));
+
+ GL.StencilFunc(TranslateStencilFunction(StencilFunction),
+ ReferenceStencil, StencilMask);
+ }
+ #endregion
+ }
+ #endregion
+
+ #region TranslateStencilOp
+ ///
+ /// Translate the ANX stencil operation to OpenGL.
+ ///
+ /// ANX stencil operation.
+ /// Translated OpenGL stencil operation.
+ private OpenTK.Graphics.OpenGL.StencilOp TranslateStencilOp(
+ StencilOperation operation)
+ {
+ switch (operation)
+ {
+ default:
+ case StencilOperation.Decrement:
+ return StencilOp.Decr;
+
+ case StencilOperation.DecrementSaturation:
+ return StencilOp.DecrWrap;
+
+ case StencilOperation.Increment:
+ return StencilOp.Incr;
+
+ case StencilOperation.IncrementSaturation:
+ return StencilOp.IncrWrap;
+
+ case StencilOperation.Invert:
+ return StencilOp.Invert;
+
+ case StencilOperation.Keep:
+ return StencilOp.Keep;
+
+ case StencilOperation.Replace:
+ return StencilOp.Replace;
+
+ case StencilOperation.Zero:
+ return StencilOp.Zero;
+ }
+ }
+ #endregion
+
+ #region TranslateDepthFunction
+ ///
+ /// Translate the ANX compare function to the OpenGL depth function.
+ ///
+ /// ANX compare function.
+ /// Translated OpenGL depth function.
+ private OpenTK.Graphics.OpenGL.DepthFunction TranslateDepthFunction(
+ CompareFunction func)
+ {
+ switch (func)
+ {
+ default:
+ case CompareFunction.Always:
+ return OpenTK.Graphics.OpenGL.DepthFunction.Always;
+
+ case CompareFunction.Equal:
+ return OpenTK.Graphics.OpenGL.DepthFunction.Equal;
+
+ case CompareFunction.Greater:
+ return OpenTK.Graphics.OpenGL.DepthFunction.Greater;
+
+ case CompareFunction.GreaterEqual:
+ return OpenTK.Graphics.OpenGL.DepthFunction.Gequal;
+
+ case CompareFunction.Less:
+ return OpenTK.Graphics.OpenGL.DepthFunction.Less;
+
+ case CompareFunction.LessEqual:
+ return OpenTK.Graphics.OpenGL.DepthFunction.Lequal;
+
+ case CompareFunction.Never:
+ return OpenTK.Graphics.OpenGL.DepthFunction.Never;
+
+ case CompareFunction.NotEqual:
+ return OpenTK.Graphics.OpenGL.DepthFunction.Notequal;
+ }
+ }
+ #endregion
+
+ #region TranslateStencilFunction
+ ///
+ /// Translate the ANX compare function to the OpenGL stencil function.
+ ///
+ /// ANX compare function.
+ /// Translated OpenGL stencil function.
+ private OpenTK.Graphics.OpenGL.StencilFunction TranslateStencilFunction(
+ CompareFunction func)
+ {
+ switch (func)
+ {
+ default:
+ case CompareFunction.Always:
+ return OpenTK.Graphics.OpenGL.StencilFunction.Always;
+
+ case CompareFunction.Equal:
+ return OpenTK.Graphics.OpenGL.StencilFunction.Equal;
+
+ case CompareFunction.Greater:
+ return OpenTK.Graphics.OpenGL.StencilFunction.Greater;
+
+ case CompareFunction.GreaterEqual:
+ return OpenTK.Graphics.OpenGL.StencilFunction.Gequal;
+
+ case CompareFunction.Less:
+ return OpenTK.Graphics.OpenGL.StencilFunction.Less;
+
+ case CompareFunction.LessEqual:
+ return OpenTK.Graphics.OpenGL.StencilFunction.Lequal;
+
+ case CompareFunction.Never:
+ return OpenTK.Graphics.OpenGL.StencilFunction.Never;
+
+ case CompareFunction.NotEqual:
+ return OpenTK.Graphics.OpenGL.StencilFunction.Notequal;
+ }
+ }
+ #endregion
+
+ #region Release
+ ///
+ /// Release the depth stencil state.
+ ///
+ public void Release()
+ {
+ IsBound = false;
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose the depth stencil state object.
+ ///
+ public void Dispose()
+ {
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs
new file mode 100644
index 00000000..a1e8118a
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs
@@ -0,0 +1,245 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
+using OpenTK.Graphics.OpenGL;
+using System.Text;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native OpenGL Effect implementation.
+ ///
+ public class EffectGL3 : INativeEffect
+ {
+ #region Constants
+ private const string FragmentSeparator = "##!fragment!##";
+ #endregion
+
+ #region Private
+ ///
+ /// The native shader handle.
+ ///
+ private int programHandle;
+ #endregion
+
+ #region Public
+ #region Techniques (TODO)
+ public IEnumerable Techniques
+ {
+ get
+ {
+ List techniques = new List();
+
+ // TODO: dummy, fill with actual data.
+ techniques.Add(new EffectTechnique());
+
+ return techniques;
+ }
+ }
+ #endregion
+
+ #region Parameters (TODO)
+ public IEnumerable Parameters
+ {
+ get
+ {
+ List parameters = new List();
+
+ int uniformCount;
+ GL.GetProgram(programHandle, ProgramParameter.ActiveUniforms, out uniformCount);
+
+ string[] uniformNames = new string[uniformCount];
+ int[] uniformIndices = new int[uniformCount];
+
+ //TODO: this command doesn't work ?!?! -> GL.GetUniformIndices(programHandle, uniformCount, uniformNames, uniformIndices);
+
+
+ // TODO: dummy, fill with actual data.
+ parameters.Add(new EffectParameter());
+
+ return parameters;
+ }
+ }
+ #endregion
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new effect instance of separate streams.
+ ///
+ /// The vertex shader code.
+ /// The fragment shader code.
+ public EffectGL3(Stream vertexShaderByteCode,
+ Stream pixelShaderByteCode)
+ {
+ byte[] vertexBytes = new byte[vertexShaderByteCode.Length];
+ vertexShaderByteCode.Read(vertexBytes, 0,
+ (int)vertexShaderByteCode.Length);
+
+ byte[] fragmentBytes = new byte[pixelShaderByteCode.Length];
+ pixelShaderByteCode.Read(fragmentBytes, 0,
+ (int)pixelShaderByteCode.Length);
+
+ CreateShader(Encoding.ASCII.GetString(vertexBytes),
+ Encoding.ASCII.GetString(fragmentBytes));
+ }
+
+ ///
+ /// Create a new effect instance of one streams.
+ ///
+ /// The byte code of the shader.
+ public EffectGL3(Stream byteCode)
+ {
+ byte[] byteData = new byte[byteCode.Length];
+ byteCode.Read(byteData, 0, (int)byteCode.Length);
+
+ string source = Encoding.ASCII.GetString(byteData);
+ string[] parts = source.Split(new string[] { FragmentSeparator },
+ StringSplitOptions.RemoveEmptyEntries);
+
+ CreateShader(parts[0], parts[1]);
+ }
+ #endregion
+
+ #region CreateShader
+ private void CreateShader(string vertexSource, string fragmentSource)
+ {
+ int vertexShader = GL.CreateShader(ShaderType.VertexShader);
+ string vertexError = CompileShader(vertexShader, vertexSource);
+ if (String.IsNullOrEmpty(vertexError) == false)
+ {
+ throw new InvalidDataException("Failed to compile the vertex " +
+ "shader because of: " + vertexError);
+ }
+
+ int fragmentShader = GL.CreateShader(ShaderType.FragmentShader);
+ string fragmentError = CompileShader(fragmentShader, fragmentSource);
+ if (String.IsNullOrEmpty(fragmentError) == false)
+ {
+ throw new InvalidDataException("Failed to compile the fragment " +
+ "shader because of: " + fragmentError);
+ }
+
+ programHandle = GL.CreateProgram();
+ GL.AttachShader(programHandle, vertexShader);
+ GL.AttachShader(programHandle, fragmentShader);
+ GL.LinkProgram(programHandle);
+
+ int result;
+ GL.GetProgram(programHandle, ProgramParameter.LinkStatus, out result);
+ if (result == 0)
+ {
+ string programError;
+ GL.GetProgramInfoLog(programHandle, out programError);
+ throw new InvalidDataException("Failed to link the shader program " +
+ "because of: " + programError);
+ }
+ }
+ #endregion
+
+ #region CompileShader
+ private string CompileShader(int shader, string source)
+ {
+ GL.ShaderSource(shader, source);
+ GL.CompileShader(shader);
+
+ int result;
+ GL.GetShader(shader, ShaderParameter.CompileStatus, out result);
+ if (result == 0)
+ {
+ string error = "";
+ GL.GetShaderInfoLog(shader, out error);
+
+ GL.DeleteShader(shader);
+
+ return error;
+ }
+
+ return null;
+ }
+ #endregion
+
+ #region CompileShader (for external)
+ public static byte[] CompileShader(string effectCode)
+ {
+ return Encoding.ASCII.GetBytes(effectCode);
+ }
+ #endregion
+
+ #region Apply (TODO)
+ public void Apply(GraphicsDevice graphicsDevice)
+ {
+ throw new NotImplementedException();
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose the native shader data.
+ ///
+ public void Dispose()
+ {
+ GL.DeleteProgram(programHandle);
+
+ int result;
+ GL.GetProgram(programHandle, ProgramParameter.DeleteStatus, out result);
+ if (result == 0)
+ {
+ string deleteError;
+ GL.GetProgramInfoLog(programHandle, out deleteError);
+ throw new Exception("Failed to delete the shader program because of: " +
+ deleteError);
+ }
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectParameterGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectParameterGL3.cs
new file mode 100644
index 00000000..57292f6a
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectParameterGL3.cs
@@ -0,0 +1,97 @@
+using System;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native OpenGL implementation of an effect parameter.
+ ///
+ public class EffectParameterGL3 : INativeEffectParameter
+ {
+ #region Public
+ ///
+ /// The name of the effect parameter.
+ ///
+ public string Name
+ {
+ get;
+ private set;
+ }
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a ne effect parameter object.
+ ///
+ internal EffectParameterGL3()
+ {
+ }
+ #endregion
+
+ #region SetValue (TODO)
+ ///
+ /// Set a matrix value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Matrix value)
+ {
+ }
+
+ ///
+ /// Set a texture value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Texture value)
+ {
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs
new file mode 100644
index 00000000..12fd7d10
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs
@@ -0,0 +1,78 @@
+using System;
+using ANX.Framework.NonXNA;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native OpenGL implementation of an effect technique.
+ ///
+ public class EffectTechniqueGL3 : INativeEffectTechnique
+ {
+ #region Public
+ ///
+ /// The name of the effect technique.
+ ///
+ public string Name
+ {
+ get;
+ private set;
+ }
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a ne effect technique object.
+ ///
+ internal EffectTechniqueGL3()
+ {
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs
new file mode 100644
index 00000000..dbc529e6
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs
@@ -0,0 +1,321 @@
+using System;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
+using OpenTK.Graphics;
+using OpenTK.Graphics.OpenGL;
+using OpenTK.Platform;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native OpenGL implementation for a graphics device.
+ ///
+ public class GraphicsDeviceWindowsGL3 : INativeGraphicsDevice
+ {
+ #region Constants
+ private const float ColorMultiplier = 1f / 255f;
+ #endregion
+
+ #region Private
+ ///
+ /// Native graphics context.
+ ///
+ private GraphicsContext nativeContext;
+
+ ///
+ /// The OpenTK window info helper class to provide window informations
+ /// to the graphics device.
+ ///
+ private IWindowInfo nativeWindowInfo;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new OpenGL graphics context.
+ ///
+ /// Parameters for the window
+ /// and graphics context.
+ internal GraphicsDeviceWindowsGL3(
+ PresentationParameters presentationParameters)
+ {
+ ResetDevice(presentationParameters);
+ }
+ #endregion
+
+ #region ResetDevice
+ ///
+ /// Reset the graphics device with the given presentation paramters.
+ /// If a device is currently set, then we dispose the old one.
+ ///
+ /// Parameters for the
+ /// graphics device.
+ private void ResetDevice(PresentationParameters presentationParameters)
+ {
+ #region Validation
+ if (nativeContext != null)
+ {
+ nativeContext.Dispose();
+ nativeContext = null;
+ }
+
+ if (nativeWindowInfo != null)
+ {
+ nativeWindowInfo.Dispose();
+ nativeWindowInfo = null;
+ }
+ #endregion
+
+ // OpenGL Depth Buffer Size: 0/16/24/32
+ int depth = 0;
+ int stencil = 0;
+ switch (presentationParameters.DepthStencilFormat)
+ {
+ case DepthFormat.None:
+ break;
+
+ case DepthFormat.Depth16:
+ depth = 16;
+ break;
+
+ case DepthFormat.Depth24:
+ depth = 24;
+ break;
+
+ case DepthFormat.Depth24Stencil8:
+ depth = 24;
+ stencil = 8;
+ break;
+ }
+
+ nativeWindowInfo = Utilities.CreateWindowsWindowInfo(
+ presentationParameters.DeviceWindowHandle);
+
+ GraphicsMode graphicsMode = new GraphicsMode(
+ DatatypesMapping.SurfaceToColorFormat(
+ presentationParameters.BackBufferFormat),
+ depth, stencil,
+ // AntiAlias Samples: 2/4/8/16/32
+ presentationParameters.MultiSampleCount);
+
+ nativeContext = new GraphicsContext(graphicsMode, nativeWindowInfo);
+ nativeContext.MakeCurrent(nativeWindowInfo);
+ nativeContext.LoadAll();
+ }
+ #endregion
+
+ #region SetViewport
+ ///
+ /// Set the OpenGL viewport.
+ ///
+ /// Viewport data to set natively.
+ public void SetViewport(Viewport viewport)
+ {
+ GL.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height);
+ }
+ #endregion
+
+ #region Clear
+ private uint lastClearColor;
+ ///
+ /// Clear the current screen by the specified clear color.
+ ///
+ /// Clear color.
+ public void Clear(ref Color color)
+ {
+ uint newClearColor = color.PackedValue;
+ if (lastClearColor != newClearColor)
+ {
+ lastClearColor = newClearColor;
+ GL.ClearColor(color.R * ColorMultiplier, color.G * ColorMultiplier,
+ color.B * ColorMultiplier, color.A * ColorMultiplier);
+ }
+ GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
+ }
+
+ ///
+ /// Clear the current screen by the specified clear color and options.
+ ///
+ /// Clear options defining which components
+ /// should be cleared.
+ /// Clear color.
+ /// Depth value.
+ /// Stencil value.
+ public void Clear(ClearOptions options, Vector4 color, float depth,
+ int stencil)
+ {
+ Color anxColor;
+ DatatypesMapping.Convert(ref color, out anxColor);
+ uint newClearColor = anxColor.PackedValue;
+ if (lastClearColor != newClearColor)
+ {
+ lastClearColor = newClearColor;
+ GL.ClearColor(anxColor.R * ColorMultiplier, anxColor.G * ColorMultiplier,
+ anxColor.B * ColorMultiplier, anxColor.A * ColorMultiplier);
+ }
+
+ ClearBufferMask mask = (ClearBufferMask)0;
+ if ((options | ClearOptions.Target) == options)
+ {
+ mask |= ClearBufferMask.ColorBufferBit;
+ }
+ if ((options | ClearOptions.Stencil) == options)
+ {
+ mask |= ClearBufferMask.StencilBufferBit;
+ }
+ if ((options | ClearOptions.DepthBuffer) == options)
+ {
+ mask |= ClearBufferMask.DepthBufferBit;
+ }
+
+ GL.ClearDepth(depth);
+ GL.ClearStencil(stencil);
+ GL.Clear(mask);
+ }
+ #endregion
+
+ #region Present
+ ///
+ /// Swap the graphics buffers.
+ ///
+ public void Present()
+ {
+ if (WindowsGameWindow.Form != null &&
+ WindowsGameWindow.Form.IsDisposed == false)
+ {
+ nativeContext.SwapBuffers();
+ }
+ }
+ #endregion
+
+ public void DrawIndexedPrimitives(PrimitiveType primitiveType,
+ int baseVertex, int minVertexIndex, int numVertices, int startIndex,
+ int primitiveCount)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawInstancedPrimitives(PrimitiveType primitiveType,
+ int baseVertex, int minVertexIndex, int numVertices, int startIndex,
+ int primitiveCount, int instanceCount)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawUserIndexedPrimitives(PrimitiveType primitiveType,
+ T[] vertexData, int vertexOffset, int numVertices, Array indexData,
+ int indexOffset, int primitiveCount, VertexDeclaration vertexDeclaration,
+ IndexElementSize indexFormat) where T : struct, IVertexType
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawUserPrimitives(PrimitiveType primitiveType,
+ T[] vertexData, int vertexOffset, int primitiveCount,
+ VertexDeclaration vertexDeclaration) where T : struct, IVertexType
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset,
+ int primitiveCount)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SetVertexBuffers(VertexBufferBinding[] vertexBuffers)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SetIndexBuffer(IndexBuffer indexBuffer)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SetRenderTargets(params RenderTargetBinding[] renderTargets)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void GetBackBufferData(Rectangle? rect, T[] data,
+ int startIndex, int elementCount) where T : struct
+ {
+ throw new NotImplementedException();
+ }
+
+ public void GetBackBufferData(T[] data) where T : struct
+ {
+ throw new NotImplementedException();
+ }
+
+ public void GetBackBufferData(T[] data, int startIndex, int elementCount) where T : struct
+ {
+ throw new NotImplementedException();
+ }
+
+ public void ResizeBuffers(PresentationParameters presentationParameters)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public bool VSync
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs
new file mode 100644
index 00000000..2cb2496c
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs
@@ -0,0 +1,170 @@
+using System;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+using OpenTK.Graphics.OpenGL;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native OpenGL implementation of a Index Buffer.
+ ///
+ public class IndexBufferGL3 : INativeBuffer
+ {
+ #region Private
+ ///
+ /// Native index buffer handle.
+ ///
+ private int bufferHandle;
+
+ private int indexCount;
+
+ private IndexElementSize elementSize;
+
+ private BufferUsage usage;
+
+ private BufferUsageHint usageHint;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new Index Buffer object.
+ ///
+ internal IndexBufferGL3(IndexElementSize setElementSize,
+ int setIndexCount, BufferUsage setUsage)
+ {
+ indexCount = setIndexCount;
+ elementSize = setElementSize;
+ usage = setUsage;
+
+ // TODO: evaluate whats best
+ // StaticDraw: set once, use often
+ // DynamicDraw: set frequently, use repeatadly
+ // StreamDraw: set every tick, use once
+ usageHint = BufferUsageHint.DynamicDraw;
+
+ GL.GenBuffers(1, out bufferHandle);
+ }
+ #endregion
+
+ #region SetData
+ public void SetData(GraphicsDevice graphicsDevice, T[] data)
+ where T : struct
+ {
+ BufferData(data, 0);
+ }
+ #endregion
+
+ #region SetData
+ public void SetData(GraphicsDevice graphicsDevice, T[] data,
+ int startIndex, int elementCount) where T : struct
+ {
+ if (startIndex != 0 ||
+ elementCount != data.Length)
+ {
+ T[] subArray = new T[elementCount];
+ Array.Copy(data, startIndex, subArray, 0, elementCount);
+ BufferData(subArray, 0);
+ }
+ else
+ {
+ BufferData(data, 0);
+ }
+ }
+ #endregion
+
+ #region SetData
+ public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes,
+ T[] data, int startIndex, int elementCount) where T : struct
+ {
+ if (startIndex != 0 ||
+ elementCount != data.Length)
+ {
+ T[] subArray = new T[elementCount];
+ Array.Copy(data, startIndex, subArray, 0, elementCount);
+ BufferData(subArray, offsetInBytes);
+ }
+ else
+ {
+ BufferData(data, offsetInBytes);
+ }
+ }
+ #endregion
+
+ #region BufferData (private helper)
+ private void BufferData(T[] data, int offset) where T : struct
+ {
+ IntPtr size = (IntPtr)((elementSize == IndexElementSize.SixteenBits ?
+ 2 : 4) * data.Length);
+
+ GL.BindBuffer(BufferTarget.ElementArrayBuffer, bufferHandle);
+
+ if (offset != 0)
+ {
+ GL.BufferData(BufferTarget.ElementArrayBuffer, size, data, usageHint);
+ }
+ else
+ {
+ GL.BufferSubData(BufferTarget.ElementArrayBuffer, (IntPtr)offset,
+ size, data);
+ }
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose the native index buffer data.
+ ///
+ public void Dispose()
+ {
+ GL.DeleteBuffers(1, ref bufferHandle);
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs b/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..f8286661
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs
@@ -0,0 +1,38 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("ANX.Framework.Windows.GL3")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("ANX.Framework Team")]
+[assembly: AssemblyProduct("ANX.Framework.Windows.GL3")]
+[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("14d07c57-8b86-4f6e-bacb-69f65aba5633")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
+// übernehmen, indem Sie "*" eingeben:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("0.5.1.0")]
+[assembly: AssemblyFileVersion("0.5.1.0")]
+
+[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/RasterizerStateGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/RasterizerStateGL3.cs
new file mode 100644
index 00000000..e2fcbcf6
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/RasterizerStateGL3.cs
@@ -0,0 +1,243 @@
+using System;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+using OpenTK.Graphics.OpenGL;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native Rasterizer State object for OpenGL.
+ ///
+ /// Basically this is a wrapper class for setting the different values all
+ /// at once, because OpenGL has no State objects like DirectX.
+ ///
+ public class RasterizerStateGL3 : INativeRasterizerState
+ {
+ #region Public
+ #region IsBound
+ ///
+ /// Flag if the state object is bound to the device.
+ ///
+ public bool IsBound
+ {
+ get;
+ private set;
+ }
+ #endregion
+
+ #region CullMode
+ ///
+ /// The cull mode of the state object.
+ ///
+ public CullMode CullMode
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region ScissorTestEnable
+ ///
+ /// Flag if the state object has scissor test enabled.
+ ///
+ public bool ScissorTestEnable
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region FillMode
+ ///
+ /// The fill mode of the state object.
+ ///
+ public FillMode FillMode
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region SlopeScaleDepthBias
+ ///
+ /// The SlopeScaleDepthBias of the state object.
+ ///
+ public float SlopeScaleDepthBias
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region DepthBias
+ ///
+ /// The depth bias of the state object.
+ ///
+ public float DepthBias
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region MultiSampleAntiAlias
+ ///
+ /// Flag if the state object has MSAA enabled.
+ ///
+ public bool MultiSampleAntiAlias
+ {
+ set;
+ private get;
+ }
+ #endregion
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new rasterizer state object.
+ ///
+ internal RasterizerStateGL3()
+ {
+ IsBound = false;
+ }
+ #endregion
+
+ #region Apply
+ ///
+ /// Apply the rasterizer state to the graphics device.
+ ///
+ /// The current graphics device.
+ public void Apply(GraphicsDevice graphicsDevice)
+ {
+ IsBound = true;
+
+ #region Cull Mode
+ GL.FrontFace(FrontFaceDirection.Cw);
+ if (CullMode == CullMode.None)
+ {
+ GL.Disable(EnableCap.CullFace);
+ GL.CullFace(CullFaceMode.FrontAndBack);
+ }
+ else
+ {
+ GL.Enable(EnableCap.CullFace);
+ GL.CullFace(CullMode == CullMode.None ?
+ CullFaceMode.FrontAndBack :
+ CullMode == CullMode.CullClockwiseFace ?
+ CullFaceMode.Front :
+ CullFaceMode.Back);
+ }
+ #endregion
+
+ GL.PolygonMode(MaterialFace.FrontAndBack,
+ FillMode == FillMode.WireFrame ? PolygonMode.Line : PolygonMode.Fill);
+
+ #region ScissorTestEnable
+ if (ScissorTestEnable)
+ {
+ GL.Enable(EnableCap.ScissorTest);
+ }
+ else
+ {
+ GL.Disable(EnableCap.ScissorTest);
+ }
+ #endregion
+
+ #region DepthBias / SlopeScaleDepthBias (TODO: test!)
+ // NOTE: http://www.opengl.org/sdk/docs/man/xhtml/glPolygonOffset.xml
+
+ // Good article about difference between OpenGL and DirectX concerning
+ // Depth Bias: http://aras-p.info/blog/2008/06/12/depth-bias-and-the-power-of-deceiving-yourself/
+
+ if (DepthBias != 0f &&
+ SlopeScaleDepthBias != 0f)
+ {
+ GL.Enable(EnableCap.PolygonOffsetFill);
+ GL.PolygonOffset(SlopeScaleDepthBias, DepthBias);
+ }
+ else
+ {
+ GL.Disable(EnableCap.PolygonOffsetFill);
+ }
+ #endregion
+
+ #region MultiSampleAntiAlias
+ if (MultiSampleAntiAlias)
+ {
+ GL.Enable(EnableCap.Multisample);
+ }
+ else
+ {
+ GL.Disable(EnableCap.Multisample);
+ }
+ #endregion
+ }
+ #endregion
+
+ #region Release
+ ///
+ /// Release the rasterizer state.
+ ///
+ public void Release()
+ {
+ IsBound = false;
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose the rasterizer state object.
+ ///
+ public void Dispose()
+ {
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/SamplerStateGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/SamplerStateGL3.cs
new file mode 100644
index 00000000..a425d0c5
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/SamplerStateGL3.cs
@@ -0,0 +1,181 @@
+using System;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
+using OpenTK.Graphics.OpenGL;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native Sampler State object for OpenGL.
+ ///
+ /// Basically this is a wrapper class for setting the different values all
+ /// at once, because OpenGL has no State objects like DirectX.
+ ///
+ /// Info for OpenGL filter states:
+ /// http://gregs-blog.com/2008/01/17/opengl-texture-filter-parameters-explained/
+ ///
+ /// Info for OGL 3.3 sampler objects (sadly not implemented in OpenTK yet):
+ /// http://www.sinanc.org/blog/?p=215
+ ///
+ public class SamplerStateGL3 : INativeSamplerState
+ {
+ #region Public
+ #region IsBound
+ ///
+ /// Flag if the state object is bound to the device.
+ ///
+ public bool IsBound
+ {
+ get;
+ private set;
+ }
+ #endregion
+
+ #region AddressU
+ public TextureAddressMode AddressU
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region AddressV
+ public TextureAddressMode AddressV
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region AddressW
+ public TextureAddressMode AddressW
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region Filter
+ public TextureFilter Filter
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region MaxAnisotropy
+ public int MaxAnisotropy
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region MaxMipLevel
+ public int MaxMipLevel
+ {
+ set;
+ private get;
+ }
+ #endregion
+
+ #region MipMapLevelOfDetailBias
+ public float MipMapLevelOfDetailBias
+ {
+ set;
+ private get;
+ }
+ #endregion
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new sampler state object.
+ ///
+ internal SamplerStateGL3()
+ {
+ IsBound = false;
+ }
+ #endregion
+
+ #region Apply
+ ///
+ /// Apply the sampler state.
+ ///
+ /// Graphics device.
+ ///
+ public void Apply(GraphicsDevice graphicsDevice, int index)
+ {
+ IsBound = true;
+
+ // TODO: set stuff
+ }
+ #endregion
+
+ #region Release
+ ///
+ /// Release the sampler state.
+ ///
+ public void Release()
+ {
+ IsBound = false;
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose the sampler state object.
+ ///
+ public void Dispose()
+ {
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/ShaderByteCode.cs b/RenderSystems/ANX.Framework.Windows.GL3/ShaderByteCode.cs
new file mode 100644
index 00000000..0ddb806e
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/ShaderByteCode.cs
@@ -0,0 +1,275 @@
+#region Using Statements
+using System;
+#endregion // Using Statements
+
+#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.Windows.GL3
+{
+ internal static class ShaderByteCode
+ {
+ #region SpriteBatchShader
+ internal static byte[] SpriteBatchByteCode = new byte[]
+ {
+ 047,
+ 047, 013, 010, 047, 047, 032, 084, 104, 105, 115, 032, 102, 105, 108, 101, 032, 105, 115, 032, 112,
+ 097, 114, 116, 032, 111, 102, 032, 116, 104, 101, 032, 065, 078, 088, 046, 070, 114, 097, 109, 101,
+ 119, 111, 114, 107, 032, 099, 114, 101, 097, 116, 101, 100, 032, 098, 121, 032, 116, 104, 101, 032,
+ 034, 065, 078, 088, 046, 070, 114, 097, 109, 101, 119, 111, 114, 107, 032, 100, 101, 118, 101, 108,
+ 111, 112, 101, 114, 032, 103, 114, 111, 117, 112, 034, 046, 013, 010, 047, 047, 013, 010, 047, 047,
+ 032, 084, 104, 105, 115, 032, 102, 105, 108, 101, 032, 105, 115, 032, 114, 101, 108, 101, 097, 115,
+ 101, 100, 032, 117, 110, 100, 101, 114, 032, 116, 104, 101, 032, 077, 115, 045, 080, 076, 032, 108,
+ 105, 099, 101, 110, 115, 101, 046, 013, 010, 047, 047, 013, 010, 047, 047, 013, 010, 047, 047, 013,
+ 010, 047, 047, 032, 077, 105, 099, 114, 111, 115, 111, 102, 116, 032, 080, 117, 098, 108, 105, 099,
+ 032, 076, 105, 099, 101, 110, 115, 101, 032, 040, 077, 115, 045, 080, 076, 041, 013, 010, 047, 047,
+ 013, 010, 047, 047, 032, 084, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 032, 103, 111,
+ 118, 101, 114, 110, 115, 032, 117, 115, 101, 032, 111, 102, 032, 116, 104, 101, 032, 097, 099, 099,
+ 111, 109, 112, 097, 110, 121, 105, 110, 103, 032, 115, 111, 102, 116, 119, 097, 114, 101, 046, 032,
+ 073, 102, 032, 121, 111, 117, 032, 117, 115, 101, 032, 116, 104, 101, 032, 115, 111, 102, 116, 119,
+ 097, 114, 101, 044, 032, 121, 111, 117, 032, 097, 099, 099, 101, 112, 116, 032, 116, 104, 105, 115,
+ 032, 108, 105, 099, 101, 110, 115, 101, 046, 032, 013, 010, 047, 047, 032, 073, 102, 032, 121, 111,
+ 117, 032, 100, 111, 032, 110, 111, 116, 032, 097, 099, 099, 101, 112, 116, 032, 116, 104, 101, 032,
+ 108, 105, 099, 101, 110, 115, 101, 044, 032, 100, 111, 032, 110, 111, 116, 032, 117, 115, 101, 032,
+ 116, 104, 101, 032, 115, 111, 102, 116, 119, 097, 114, 101, 046, 013, 010, 047, 047, 013, 010, 047,
+ 047, 032, 049, 046, 068, 101, 102, 105, 110, 105, 116, 105, 111, 110, 115, 013, 010, 047, 047, 032,
+ 032, 032, 084, 104, 101, 032, 116, 101, 114, 109, 115, 032, 034, 114, 101, 112, 114, 111, 100, 117,
+ 099, 101, 044, 034, 032, 034, 114, 101, 112, 114, 111, 100, 117, 099, 116, 105, 111, 110, 044, 034,
+ 032, 034, 100, 101, 114, 105, 118, 097, 116, 105, 118, 101, 032, 119, 111, 114, 107, 115, 044, 034,
+ 032, 097, 110, 100, 032, 034, 100, 105, 115, 116, 114, 105, 098, 117, 116, 105, 111, 110, 034, 032,
+ 104, 097, 118, 101, 032, 116, 104, 101, 032, 115, 097, 109, 101, 032, 109, 101, 097, 110, 105, 110,
+ 103, 032, 013, 010, 047, 047, 032, 032, 032, 104, 101, 114, 101, 032, 097, 115, 032, 117, 110, 100,
+ 101, 114, 032, 085, 046, 083, 046, 032, 099, 111, 112, 121, 114, 105, 103, 104, 116, 032, 108, 097,
+ 119, 046, 013, 010, 047, 047, 032, 032, 032, 065, 032, 034, 099, 111, 110, 116, 114, 105, 098, 117,
+ 116, 105, 111, 110, 034, 032, 105, 115, 032, 116, 104, 101, 032, 111, 114, 105, 103, 105, 110, 097,
+ 108, 032, 115, 111, 102, 116, 119, 097, 114, 101, 044, 032, 111, 114, 032, 097, 110, 121, 032, 097,
+ 100, 100, 105, 116, 105, 111, 110, 115, 032, 111, 114, 032, 099, 104, 097, 110, 103, 101, 115, 032,
+ 116, 111, 032, 116, 104, 101, 032, 115, 111, 102, 116, 119, 097, 114, 101, 046, 013, 010, 047, 047,
+ 032, 032, 032, 065, 032, 034, 099, 111, 110, 116, 114, 105, 098, 117, 116, 111, 114, 034, 032, 105,
+ 115, 032, 097, 110, 121, 032, 112, 101, 114, 115, 111, 110, 032, 116, 104, 097, 116, 032, 100, 105,
+ 115, 116, 114, 105, 098, 117, 116, 101, 115, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105,
+ 098, 117, 116, 105, 111, 110, 032, 117, 110, 100, 101, 114, 032, 116, 104, 105, 115, 032, 108, 105,
+ 099, 101, 110, 115, 101, 046, 013, 010, 047, 047, 032, 032, 032, 034, 076, 105, 099, 101, 110, 115,
+ 101, 100, 032, 112, 097, 116, 101, 110, 116, 115, 034, 032, 097, 114, 101, 032, 097, 032, 099, 111,
+ 110, 116, 114, 105, 098, 117, 116, 111, 114, 039, 115, 032, 112, 097, 116, 101, 110, 116, 032, 099,
+ 108, 097, 105, 109, 115, 032, 116, 104, 097, 116, 032, 114, 101, 097, 100, 032, 100, 105, 114, 101,
+ 099, 116, 108, 121, 032, 111, 110, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117,
+ 116, 105, 111, 110, 046, 013, 010, 047, 047, 013, 010, 047, 047, 032, 050, 046, 071, 114, 097, 110,
+ 116, 032, 111, 102, 032, 082, 105, 103, 104, 116, 115, 013, 010, 047, 047, 032, 032, 032, 040, 065,
+ 041, 032, 067, 111, 112, 121, 114, 105, 103, 104, 116, 032, 071, 114, 097, 110, 116, 045, 032, 083,
+ 117, 098, 106, 101, 099, 116, 032, 116, 111, 032, 116, 104, 101, 032, 116, 101, 114, 109, 115, 032,
+ 111, 102, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 044, 032, 105, 110, 099,
+ 108, 117, 100, 105, 110, 103, 032, 116, 104, 101, 032, 108, 105, 099, 101, 110, 115, 101, 032, 099,
+ 111, 110, 100, 105, 116, 105, 111, 110, 115, 032, 097, 110, 100, 032, 108, 105, 109, 105, 116, 097,
+ 116, 105, 111, 110, 115, 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 105, 110, 032,
+ 115, 101, 099, 116, 105, 111, 110, 032, 051, 044, 032, 101, 097, 099, 104, 032, 099, 111, 110, 116,
+ 114, 105, 098, 117, 116, 111, 114, 032, 103, 114, 097, 110, 116, 115, 032, 121, 111, 117, 032, 097,
+ 032, 110, 111, 110, 045, 101, 120, 099, 108, 117, 115, 105, 118, 101, 044, 032, 119, 111, 114, 108,
+ 100, 119, 105, 100, 101, 044, 032, 114, 111, 121, 097, 108, 116, 121, 045, 102, 114, 101, 101, 032,
+ 099, 111, 112, 121, 114, 105, 103, 104, 116, 032, 108, 105, 099, 101, 110, 115, 101, 032, 116, 111,
+ 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 114, 101, 112, 114, 111, 100, 117, 099,
+ 101, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 105, 111, 110, 044, 032,
+ 112, 114, 101, 112, 097, 114, 101, 032, 100, 101, 114, 105, 118, 097, 116, 105, 118, 101, 032, 119,
+ 111, 114, 107, 115, 032, 111, 102, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117,
+ 116, 105, 111, 110, 044, 032, 097, 110, 100, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 101,
+ 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 105, 111, 110, 013, 010, 047,
+ 047, 032, 032, 032, 032, 032, 032, 032, 111, 114, 032, 097, 110, 121, 032, 100, 101, 114, 105, 118,
+ 097, 116, 105, 118, 101, 032, 119, 111, 114, 107, 115, 032, 116, 104, 097, 116, 032, 121, 111, 117,
+ 032, 099, 114, 101, 097, 116, 101, 046, 013, 010, 047, 047, 032, 032, 032, 040, 066, 041, 032, 080,
+ 097, 116, 101, 110, 116, 032, 071, 114, 097, 110, 116, 045, 032, 083, 117, 098, 106, 101, 099, 116,
+ 032, 116, 111, 032, 116, 104, 101, 032, 116, 101, 114, 109, 115, 032, 111, 102, 032, 116, 104, 105,
+ 115, 032, 108, 105, 099, 101, 110, 115, 101, 044, 032, 105, 110, 099, 108, 117, 100, 105, 110, 103,
+ 032, 116, 104, 101, 032, 108, 105, 099, 101, 110, 115, 101, 032, 099, 111, 110, 100, 105, 116, 105,
+ 111, 110, 115, 032, 097, 110, 100, 032, 108, 105, 109, 105, 116, 097, 116, 105, 111, 110, 115, 032,
+ 105, 110, 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 115, 101, 099, 116, 105, 111,
+ 110, 032, 051, 044, 032, 101, 097, 099, 104, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 111,
+ 114, 032, 103, 114, 097, 110, 116, 115, 032, 121, 111, 117, 032, 097, 032, 110, 111, 110, 045, 101,
+ 120, 099, 108, 117, 115, 105, 118, 101, 044, 032, 119, 111, 114, 108, 100, 119, 105, 100, 101, 044,
+ 032, 114, 111, 121, 097, 108, 116, 121, 045, 102, 114, 101, 101, 032, 108, 105, 099, 101, 110, 115,
+ 101, 032, 117, 110, 100, 101, 114, 032, 105, 116, 115, 032, 108, 105, 099, 101, 110, 115, 101, 100,
+ 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 112, 097, 116, 101, 110, 116, 115, 032, 116,
+ 111, 032, 109, 097, 107, 101, 044, 032, 104, 097, 118, 101, 032, 109, 097, 100, 101, 044, 032, 117,
+ 115, 101, 044, 032, 115, 101, 108, 108, 044, 032, 111, 102, 102, 101, 114, 032, 102, 111, 114, 032,
+ 115, 097, 108, 101, 044, 032, 105, 109, 112, 111, 114, 116, 044, 032, 097, 110, 100, 047, 111, 114,
+ 032, 111, 116, 104, 101, 114, 119, 105, 115, 101, 032, 100, 105, 115, 112, 111, 115, 101, 032, 111,
+ 102, 032, 105, 116, 115, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 105, 111, 110, 032, 013,
+ 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 105, 110, 032, 116, 104, 101, 032, 115, 111, 102,
+ 116, 119, 097, 114, 101, 032, 111, 114, 032, 100, 101, 114, 105, 118, 097, 116, 105, 118, 101, 032,
+ 119, 111, 114, 107, 115, 032, 111, 102, 032, 116, 104, 101, 032, 099, 111, 110, 116, 114, 105, 098,
+ 117, 116, 105, 111, 110, 032, 105, 110, 032, 116, 104, 101, 032, 115, 111, 102, 116, 119, 097, 114,
+ 101, 046, 013, 010, 047, 047, 013, 010, 047, 047, 032, 051, 046, 067, 111, 110, 100, 105, 116, 105,
+ 111, 110, 115, 032, 097, 110, 100, 032, 076, 105, 109, 105, 116, 097, 116, 105, 111, 110, 115, 013,
+ 010, 047, 047, 032, 032, 032, 040, 065, 041, 032, 078, 111, 032, 084, 114, 097, 100, 101, 109, 097,
+ 114, 107, 032, 076, 105, 099, 101, 110, 115, 101, 045, 032, 084, 104, 105, 115, 032, 108, 105, 099,
+ 101, 110, 115, 101, 032, 100, 111, 101, 115, 032, 110, 111, 116, 032, 103, 114, 097, 110, 116, 032,
+ 121, 111, 117, 032, 114, 105, 103, 104, 116, 115, 032, 116, 111, 032, 117, 115, 101, 032, 097, 110,
+ 121, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 111, 114, 115, 039, 032, 110, 097, 109, 101,
+ 044, 032, 108, 111, 103, 111, 044, 032, 111, 114, 032, 116, 114, 097, 100, 101, 109, 097, 114, 107,
+ 115, 046, 013, 010, 047, 047, 032, 032, 032, 040, 066, 041, 032, 073, 102, 032, 121, 111, 117, 032,
+ 098, 114, 105, 110, 103, 032, 097, 032, 112, 097, 116, 101, 110, 116, 032, 099, 108, 097, 105, 109,
+ 032, 097, 103, 097, 105, 110, 115, 116, 032, 097, 110, 121, 032, 099, 111, 110, 116, 114, 105, 098,
+ 117, 116, 111, 114, 032, 111, 118, 101, 114, 032, 112, 097, 116, 101, 110, 116, 115, 032, 116, 104,
+ 097, 116, 032, 121, 111, 117, 032, 099, 108, 097, 105, 109, 032, 097, 114, 101, 032, 105, 110, 102,
+ 114, 105, 110, 103, 101, 100, 032, 098, 121, 032, 116, 104, 101, 032, 115, 111, 102, 116, 119, 097,
+ 114, 101, 044, 032, 121, 111, 117, 114, 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032,
+ 112, 097, 116, 101, 110, 116, 032, 108, 105, 099, 101, 110, 115, 101, 032, 102, 114, 111, 109, 032,
+ 115, 117, 099, 104, 032, 099, 111, 110, 116, 114, 105, 098, 117, 116, 111, 114, 032, 116, 111, 032,
+ 116, 104, 101, 032, 115, 111, 102, 116, 119, 097, 114, 101, 032, 101, 110, 100, 115, 032, 097, 117,
+ 116, 111, 109, 097, 116, 105, 099, 097, 108, 108, 121, 046, 013, 010, 047, 047, 032, 032, 032, 040,
+ 067, 041, 032, 073, 102, 032, 121, 111, 117, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 101,
+ 032, 097, 110, 121, 032, 112, 111, 114, 116, 105, 111, 110, 032, 111, 102, 032, 116, 104, 101, 032,
+ 115, 111, 102, 116, 119, 097, 114, 101, 044, 032, 121, 111, 117, 032, 109, 117, 115, 116, 032, 114,
+ 101, 116, 097, 105, 110, 032, 097, 108, 108, 032, 099, 111, 112, 121, 114, 105, 103, 104, 116, 044,
+ 032, 112, 097, 116, 101, 110, 116, 044, 032, 116, 114, 097, 100, 101, 109, 097, 114, 107, 044, 032,
+ 097, 110, 100, 032, 097, 116, 116, 114, 105, 098, 117, 116, 105, 111, 110, 032, 013, 010, 047, 047,
+ 032, 032, 032, 032, 032, 032, 032, 110, 111, 116, 105, 099, 101, 115, 032, 116, 104, 097, 116, 032,
+ 097, 114, 101, 032, 112, 114, 101, 115, 101, 110, 116, 032, 105, 110, 032, 116, 104, 101, 032, 115,
+ 111, 102, 116, 119, 097, 114, 101, 046, 013, 010, 047, 047, 032, 032, 032, 040, 068, 041, 032, 073,
+ 102, 032, 121, 111, 117, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 101, 032, 097, 110, 121,
+ 032, 112, 111, 114, 116, 105, 111, 110, 032, 111, 102, 032, 116, 104, 101, 032, 115, 111, 102, 116,
+ 119, 097, 114, 101, 032, 105, 110, 032, 115, 111, 117, 114, 099, 101, 032, 099, 111, 100, 101, 032,
+ 102, 111, 114, 109, 044, 032, 121, 111, 117, 032, 109, 097, 121, 032, 100, 111, 032, 115, 111, 032,
+ 111, 110, 108, 121, 032, 117, 110, 100, 101, 114, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101,
+ 110, 115, 101, 032, 098, 121, 032, 105, 110, 099, 108, 117, 100, 105, 110, 103, 013, 010, 047, 047,
+ 032, 032, 032, 032, 032, 032, 032, 097, 032, 099, 111, 109, 112, 108, 101, 116, 101, 032, 099, 111,
+ 112, 121, 032, 111, 102, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 032, 119,
+ 105, 116, 104, 032, 121, 111, 117, 114, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 105, 111,
+ 110, 046, 032, 073, 102, 032, 121, 111, 117, 032, 100, 105, 115, 116, 114, 105, 098, 117, 116, 101,
+ 032, 097, 110, 121, 032, 112, 111, 114, 116, 105, 111, 110, 032, 111, 102, 032, 116, 104, 101, 032,
+ 115, 111, 102, 116, 119, 097, 114, 101, 032, 105, 110, 032, 099, 111, 109, 112, 105, 108, 101, 100,
+ 032, 111, 114, 032, 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 111, 098, 106, 101, 099,
+ 116, 032, 099, 111, 100, 101, 032, 102, 111, 114, 109, 044, 032, 121, 111, 117, 032, 109, 097, 121,
+ 032, 111, 110, 108, 121, 032, 100, 111, 032, 115, 111, 032, 117, 110, 100, 101, 114, 032, 097, 032,
+ 108, 105, 099, 101, 110, 115, 101, 032, 116, 104, 097, 116, 032, 099, 111, 109, 112, 108, 105, 101,
+ 115, 032, 119, 105, 116, 104, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 046,
+ 013, 010, 047, 047, 032, 032, 032, 040, 069, 041, 032, 084, 104, 101, 032, 115, 111, 102, 116, 119,
+ 097, 114, 101, 032, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 100, 032, 034, 097, 115, 045,
+ 105, 115, 046, 034, 032, 089, 111, 117, 032, 098, 101, 097, 114, 032, 116, 104, 101, 032, 114, 105,
+ 115, 107, 032, 111, 102, 032, 117, 115, 105, 110, 103, 032, 105, 116, 046, 032, 084, 104, 101, 032,
+ 099, 111, 110, 116, 114, 105, 098, 117, 116, 111, 114, 115, 032, 103, 105, 118, 101, 032, 110, 111,
+ 032, 101, 120, 112, 114, 101, 115, 115, 032, 119, 097, 114, 114, 097, 110, 116, 105, 101, 115, 044,
+ 032, 103, 117, 097, 114, 097, 110, 116, 101, 101, 115, 044, 013, 010, 047, 047, 032, 032, 032, 032,
+ 032, 032, 032, 111, 114, 032, 099, 111, 110, 100, 105, 116, 105, 111, 110, 115, 046, 032, 089, 111,
+ 117, 032, 109, 097, 121, 032, 104, 097, 118, 101, 032, 097, 100, 100, 105, 116, 105, 111, 110, 097,
+ 108, 032, 099, 111, 110, 115, 117, 109, 101, 114, 032, 114, 105, 103, 104, 116, 115, 032, 117, 110,
+ 100, 101, 114, 032, 121, 111, 117, 114, 032, 108, 111, 099, 097, 108, 032, 108, 097, 119, 115, 032,
+ 119, 104, 105, 099, 104, 032, 116, 104, 105, 115, 032, 108, 105, 099, 101, 110, 115, 101, 032, 099,
+ 097, 110, 110, 111, 116, 032, 099, 104, 097, 110, 103, 101, 046, 032, 084, 111, 032, 116, 104, 101,
+ 013, 010, 047, 047, 032, 032, 032, 032, 032, 032, 032, 101, 120, 116, 101, 110, 116, 032, 112, 101,
+ 114, 109, 105, 116, 116, 101, 100, 032, 117, 110, 100, 101, 114, 032, 121, 111, 117, 114, 032, 108,
+ 111, 099, 097, 108, 032, 108, 097, 119, 115, 044, 032, 116, 104, 101, 032, 099, 111, 110, 116, 114,
+ 105, 098, 117, 116, 111, 114, 115, 032, 101, 120, 099, 108, 117, 100, 101, 032, 116, 104, 101, 032,
+ 105, 109, 112, 108, 105, 101, 100, 032, 119, 097, 114, 114, 097, 110, 116, 105, 101, 115, 032, 111,
+ 102, 032, 109, 101, 114, 099, 104, 097, 110, 116, 097, 098, 105, 108, 105, 116, 121, 044, 032, 102,
+ 105, 116, 110, 101, 115, 115, 032, 102, 111, 114, 032, 097, 032, 013, 010, 047, 047, 032, 032, 032,
+ 032, 032, 032, 032, 112, 097, 114, 116, 105, 099, 117, 108, 097, 114, 032, 112, 117, 114, 112, 111,
+ 115, 101, 032, 097, 110, 100, 032, 110, 111, 110, 045, 105, 110, 102, 114, 105, 110, 103, 101, 109,
+ 101, 110, 116, 046, 013, 010, 013, 010, 117, 110, 105, 102, 111, 114, 109, 032, 109, 097, 116, 052,
+ 032, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114, 109, 059, 013, 010, 013,
+ 010, 047, 047, 084, 079, 068, 079, 058, 032, 114, 101, 119, 114, 105, 116, 101, 032, 116, 111, 032,
+ 071, 076, 083, 076, 032, 102, 114, 111, 109, 032, 104, 101, 114, 101, 032, 111, 110, 013, 010, 013,
+ 010, 047, 047, 013, 010, 047, 047, 032, 086, 101, 114, 116, 101, 120, 032, 083, 104, 097, 100, 101,
+ 114, 013, 010, 047, 047, 013, 010, 013, 010, 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118,
+ 111, 105, 100, 041, 013, 010, 123, 013, 010, 009, 103, 108, 095, 080, 111, 115, 105, 116, 105, 111,
+ 110, 032, 061, 032, 103, 108, 095, 077, 111, 100, 101, 108, 086, 105, 101, 119, 080, 114, 111, 106,
+ 101, 099, 116, 105, 111, 110, 077, 097, 116, 114, 105, 120, 032, 042, 032, 103, 108, 095, 086, 101,
+ 114, 116, 101, 120, 059, 013, 010, 125, 013, 010, 013, 010, 035, 035, 033, 102, 114, 097, 103, 109,
+ 101, 110, 116, 033, 035, 035, 013, 010, 013, 010, 047, 047, 013, 010, 047, 047, 032, 070, 114, 097,
+ 103, 109, 101, 110, 116, 032, 083, 104, 097, 100, 101, 114, 013, 010, 047, 047, 013, 010, 013, 010,
+ 118, 111, 105, 100, 032, 109, 097, 105, 110, 040, 118, 111, 105, 100, 041, 013, 010, 123, 013, 010,
+ 009, 103, 108, 095, 070, 114, 097, 103, 067, 111, 108, 111, 114, 032, 061, 032, 118, 101, 099, 052,
+ 040, 049, 046, 048, 044, 032, 049, 046, 048, 044, 032, 049, 046, 048, 044, 032, 049, 046, 048, 041,
+ 059, 013, 010, 125, 013, 010, 013, 010, 047, 042, 013, 010, 084, 101, 120, 116, 117, 114, 101, 050,
+ 068, 060, 102, 108, 111, 097, 116, 052, 062, 032, 084, 101, 120, 116, 117, 114, 101, 032, 058, 032,
+ 114, 101, 103, 105, 115, 116, 101, 114, 040, 116, 048, 041, 059, 013, 010, 032, 032, 032, 115, 097,
+ 109, 112, 108, 101, 114, 032, 084, 101, 120, 116, 117, 114, 101, 083, 097, 109, 112, 108, 101, 114,
+ 032, 058, 032, 114, 101, 103, 105, 115, 116, 101, 114, 040, 115, 048, 041, 059, 013, 010, 013, 010,
+ 115, 116, 114, 117, 099, 116, 032, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 073,
+ 110, 112, 117, 116, 013, 010, 123, 013, 010, 009, 102, 108, 111, 097, 116, 052, 032, 112, 111, 115,
+ 032, 058, 032, 080, 079, 083, 073, 084, 073, 079, 078, 059, 013, 010, 009, 102, 108, 111, 097, 116,
+ 052, 032, 099, 111, 108, 032, 058, 032, 067, 079, 076, 079, 082, 059, 013, 010, 009, 102, 108, 111,
+ 097, 116, 050, 032, 116, 101, 120, 032, 058, 032, 084, 069, 088, 067, 079, 079, 082, 068, 048, 059,
+ 013, 010, 125, 059, 013, 010, 013, 010, 115, 116, 114, 117, 099, 116, 032, 080, 105, 120, 101, 108,
+ 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 013, 010, 123, 013, 010, 009, 102, 108, 111,
+ 097, 116, 052, 032, 112, 111, 115, 032, 058, 032, 083, 086, 095, 080, 079, 083, 073, 084, 073, 079,
+ 078, 059, 013, 010, 009, 102, 108, 111, 097, 116, 052, 032, 099, 111, 108, 032, 058, 032, 067, 079,
+ 076, 079, 082, 059, 013, 010, 009, 102, 108, 111, 097, 116, 050, 032, 116, 101, 120, 032, 058, 032,
+ 084, 069, 088, 067, 079, 079, 082, 068, 048, 059, 013, 010, 125, 059, 013, 010, 013, 010, 080, 105,
+ 120, 101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 032, 083, 112, 114, 105, 116,
+ 101, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114, 040, 032, 086, 101, 114, 116, 101,
+ 120, 083, 104, 097, 100, 101, 114, 073, 110, 112, 117, 116, 032, 105, 110, 112, 117, 116, 032, 041,
+ 013, 010, 123, 013, 010, 009, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 073, 110, 112,
+ 117, 116, 032, 111, 117, 116, 112, 117, 116, 032, 061, 032, 040, 080, 105, 120, 101, 108, 083, 104,
+ 097, 100, 101, 114, 073, 110, 112, 117, 116, 041, 048, 059, 013, 010, 009, 013, 010, 009, 111, 117,
+ 116, 112, 117, 116, 046, 112, 111, 115, 032, 061, 032, 109, 117, 108, 040, 105, 110, 112, 117, 116,
+ 046, 112, 111, 115, 044, 032, 077, 097, 116, 114, 105, 120, 084, 114, 097, 110, 115, 102, 111, 114,
+ 109, 041, 059, 013, 010, 009, 111, 117, 116, 112, 117, 116, 046, 099, 111, 108, 032, 061, 032, 105,
+ 110, 112, 117, 116, 046, 099, 111, 108, 059, 013, 010, 009, 111, 117, 116, 112, 117, 116, 046, 116,
+ 101, 120, 032, 061, 032, 105, 110, 112, 117, 116, 046, 116, 101, 120, 059, 013, 010, 013, 010, 009,
+ 114, 101, 116, 117, 114, 110, 032, 111, 117, 116, 112, 117, 116, 059, 013, 010, 125, 013, 010, 013,
+ 010, 102, 108, 111, 097, 116, 052, 032, 083, 112, 114, 105, 116, 101, 080, 105, 120, 101, 108, 083,
+ 104, 097, 100, 101, 114, 040, 032, 080, 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 073, 110,
+ 112, 117, 116, 032, 105, 110, 112, 117, 116, 032, 041, 032, 058, 032, 083, 086, 095, 084, 097, 114,
+ 103, 101, 116, 013, 010, 123, 013, 010, 009, 114, 101, 116, 117, 114, 110, 032, 084, 101, 120, 116,
+ 117, 114, 101, 046, 083, 097, 109, 112, 108, 101, 040, 084, 101, 120, 116, 117, 114, 101, 083, 097,
+ 109, 112, 108, 101, 114, 044, 032, 105, 110, 112, 117, 116, 046, 116, 101, 120, 041, 032, 042, 032,
+ 105, 110, 112, 117, 116, 046, 099, 111, 108, 059, 013, 010, 125, 013, 010, 013, 010, 116, 101, 099,
+ 104, 110, 105, 113, 117, 101, 049, 048, 032, 083, 112, 114, 105, 116, 101, 084, 101, 099, 104, 110,
+ 105, 113, 117, 101, 013, 010, 123, 013, 010, 009, 112, 097, 115, 115, 032, 083, 112, 114, 105, 116,
+ 101, 067, 111, 108, 111, 114, 080, 097, 115, 115, 013, 010, 009, 123, 013, 010, 009, 009, 083, 101,
+ 116, 071, 101, 111, 109, 101, 116, 114, 121, 083, 104, 097, 100, 101, 114, 040, 032, 048, 032, 041,
+ 059, 013, 010, 009, 009, 083, 101, 116, 086, 101, 114, 116, 101, 120, 083, 104, 097, 100, 101, 114,
+ 040, 032, 067, 111, 109, 112, 105, 108, 101, 083, 104, 097, 100, 101, 114, 040, 032, 118, 115, 095,
+ 052, 095, 048, 044, 032, 083, 112, 114, 105, 116, 101, 086, 101, 114, 116, 101, 120, 083, 104, 097,
+ 100, 101, 114, 040, 041, 032, 041, 032, 041, 059, 013, 010, 009, 009, 083, 101, 116, 080, 105, 120,
+ 101, 108, 083, 104, 097, 100, 101, 114, 040, 032, 067, 111, 109, 112, 105, 108, 101, 083, 104, 097,
+ 100, 101, 114, 040, 032, 112, 115, 095, 052, 095, 048, 044, 032, 083, 112, 114, 105, 116, 101, 080,
+ 105, 120, 101, 108, 083, 104, 097, 100, 101, 114, 040, 041, 032, 041, 032, 041, 059, 013, 010, 009,
+ 125, 013, 010, 125, 013, 010, 042, 047
+ };
+ #endregion //SpriteBatchShader
+
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/Texture2DGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/Texture2DGL3.cs
new file mode 100644
index 00000000..07eb9cd4
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/Texture2DGL3.cs
@@ -0,0 +1,224 @@
+using System;
+using System.Runtime.InteropServices;
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA.RenderSystem;
+using OpenTK.Graphics.OpenGL;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native OpenGL Texture implementation.
+ ///
+ public class Texture2DGL3 : INativeTexture2D
+ {
+ #region Private
+ ///
+ /// The native OpenGL pixel format of the texture.
+ ///
+ private PixelInternalFormat nativeFormat;
+
+ ///
+ /// The number of mipmaps used by this texture [1-n].
+ ///
+ private int numberOfMipMaps;
+
+ ///
+ /// Width of the texture.
+ ///
+ private int width;
+
+ ///
+ /// Height of the texture.
+ ///
+ private int height;
+
+ ///
+ /// Flag if the texture is a compressed format or not.
+ ///
+ private bool isCompressed;
+ #endregion
+
+ #region Public
+ ///
+ /// The OpenGL texture handle.
+ ///
+ internal int NativeHandle
+ {
+ get;
+ private set;
+ }
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new native OpenGL texture.
+ ///
+ /// Surface format of the texture.
+ /// Width of the first mip level.
+ /// Height of the first mip level.
+ /// Number of mip levels [1-n].
+ internal Texture2DGL3(SurfaceFormat surfaceFormat, int setWidth,
+ int setHeight, int mipCount)
+ {
+ width = setWidth;
+ height = setHeight;
+ numberOfMipMaps = mipCount;
+ isCompressed = nativeFormat.ToString().StartsWith("Compressed");
+
+ NativeHandle = GL.GenTexture();
+ GL.BindTexture(TextureTarget.Texture2D, NativeHandle);
+
+ int wrapMode = (int)All.ClampToEdge;
+ int filter = (int)(mipCount > 1 ? All.LinearMipmapLinear : All.Linear);
+
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureWrapS, wrapMode);
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureWrapT, wrapMode);
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMagFilter, filter);
+ GL.TexParameter(TextureTarget.Texture2D,
+ TextureParameterName.TextureMinFilter, filter);
+
+ nativeFormat =
+ DatatypesMapping.SurfaceToPixelInternalFormat(surfaceFormat);
+ }
+ #endregion
+
+ // TODO: offsetInBytes
+ // TODO: startIndex
+ // TODO: elementCount
+ // TODO: get size of first mipmap!
+ #region SetData
+ public void SetData(GraphicsDevice graphicsDevice, T[] data)
+ where T : struct
+ {
+ SetData(graphicsDevice, data, 0, data.Length);
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data,
+ int startIndex, int elementCount) where T : struct
+ {
+ SetData(graphicsDevice, 0, data, 0, data.Length);
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes,
+ T[] data, int startIndex, int elementCount) where T : struct
+ {
+ if (numberOfMipMaps > 1)
+ {
+ throw new NotImplementedException(
+ "Loading mipmaps is not correctly implemented yet!");
+ }
+
+ GCHandle handle = GCHandle.Alloc(data, GCHandleType.Pinned);
+
+ // TODO: get size of first mipmap!
+ int mipmapByteSize = data.Length;
+
+ try
+ {
+ IntPtr dataPointer = handle.AddrOfPinnedObject();
+
+ if (isCompressed)
+ {
+ GL.CompressedTexImage2D(TextureTarget.Texture2D, 0, nativeFormat,
+ width, height, 0, mipmapByteSize, dataPointer);
+ }
+ else
+ {
+ GL.TexImage2D(TextureTarget.Texture2D, 0, nativeFormat,
+ width, height, 0, (PixelFormat)nativeFormat,
+ PixelType.UnsignedByte, dataPointer);
+ }
+
+ int mipmapWidth = width;
+ int mipmapHeight = height;
+ for (int index = 1; index < numberOfMipMaps; index++)
+ {
+ dataPointer += mipmapByteSize;
+ mipmapByteSize /= 4;
+ mipmapWidth /= 2;
+ mipmapHeight /= 2;
+ mipmapWidth = Math.Max(mipmapWidth, 1);
+ mipmapHeight = Math.Max(mipmapHeight, 1);
+
+ if (isCompressed)
+ {
+ GL.CompressedTexImage2D(TextureTarget.Texture2D, index,
+ nativeFormat, width, height, 0, mipmapByteSize,
+ dataPointer);
+ }
+ else
+ {
+ GL.TexImage2D(TextureTarget.Texture2D, index, nativeFormat,
+ mipmapWidth, mipmapHeight, 0, (PixelFormat)nativeFormat,
+ PixelType.UnsignedByte, dataPointer);
+ }
+ }
+ }
+ finally
+ {
+ handle.Free();
+ }
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose the native OpenGL texture handle.
+ ///
+ public void Dispose()
+ {
+ GL.DeleteTexture(NativeHandle);
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/VertexBufferGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/VertexBufferGL3.cs
new file mode 100644
index 00000000..43168167
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/VertexBufferGL3.cs
@@ -0,0 +1,166 @@
+using System;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+using OpenTK.Graphics.OpenGL;
+
+#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.Windows.GL3
+{
+ ///
+ /// Native OpenGL implementation of a Vertex Buffer.
+ ///
+ /// Information about vbo/ibo: http://playcontrol.net/ewing/jibberjabber/opengl_vertex_buffer_object.html
+ ///
+ public class VertexBufferGL3 : INativeBuffer
+ {
+ #region Private
+ ///
+ /// Native vertex buffer handle.
+ ///
+ private int bufferHandle;
+
+ private VertexDeclaration vertexDeclaration;
+
+ private BufferUsage usage;
+
+ private int vertexCount;
+
+ private BufferUsageHint usageHint;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new Vertex Buffer object.
+ ///
+ internal VertexBufferGL3(VertexDeclaration setVertexDeclaration,
+ int setVertexCount, BufferUsage setUsage)
+ {
+ vertexDeclaration = setVertexDeclaration;
+ usage = setUsage;
+ vertexCount = setVertexCount;
+
+ // TODO: evaluate whats best
+ // StaticDraw: set once, use often
+ // DynamicDraw: set frequently, use repeatadly
+ // StreamDraw: set every tick, use once
+ usageHint = BufferUsageHint.DynamicDraw;
+
+ GL.GenBuffers(1, out bufferHandle);
+ IntPtr size = (IntPtr)(vertexDeclaration.VertexStride * setVertexCount);
+ GL.BufferData(BufferTarget.ArrayBuffer, size, IntPtr.Zero, usageHint);
+ }
+ #endregion
+
+ #region SetData
+ public void SetData(GraphicsDevice graphicsDevice, T[] data)
+ where T : struct
+ {
+ BufferData(data, 0);
+ }
+ #endregion
+
+ #region SetData
+ public void SetData(GraphicsDevice graphicsDevice, T[] data,
+ int startIndex, int elementCount) where T : struct
+ {
+ if (startIndex != 0 ||
+ elementCount != data.Length)
+ {
+ T[] subArray = new T[elementCount];
+ Array.Copy(data, startIndex, subArray, 0, elementCount);
+ BufferData(subArray, 0);
+ }
+ else
+ {
+ BufferData(data, 0);
+ }
+ }
+ #endregion
+
+ #region SetData
+ public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes,
+ T[] data, int startIndex, int elementCount) where T : struct
+ {
+ if (startIndex != 0 ||
+ elementCount != data.Length)
+ {
+ T[] subArray = new T[elementCount];
+ Array.Copy(data, startIndex, subArray, 0, elementCount);
+ BufferData(subArray, offsetInBytes);
+ }
+ else
+ {
+ BufferData(data, offsetInBytes);
+ }
+ }
+ #endregion
+
+ #region BufferData (private helper) (TODO)
+ private void BufferData(T[] data, int offset) where T : struct
+ {
+ IntPtr size = (IntPtr)(vertexDeclaration.VertexStride * data.Length);
+
+ GL.BindBuffer(BufferTarget.ArrayBuffer, bufferHandle);
+
+ // TODO: check the different handling with MapBuffer etc. (See link above)
+ //GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr)offset, size, data);
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose the native index buffer data.
+ ///
+ public void Dispose()
+ {
+ GL.DeleteBuffers(1, ref bufferHandle);
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameHost.cs b/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameHost.cs
new file mode 100644
index 00000000..df564c86
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameHost.cs
@@ -0,0 +1,114 @@
+using System;
+using System.Windows.Forms;
+
+
+#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.Windows.GL3
+{
+ public class WindowsGameHost : GameHost
+ {
+ #region Private
+ private Game game;
+ private WindowsGameWindow gameWindow;
+ private bool isQuitting;
+ #endregion
+
+ #region Public
+ public override GameWindow Window
+ {
+ get
+ {
+ return this.gameWindow;
+ }
+ }
+ #endregion
+
+ #region Constructor
+ public WindowsGameHost(Game setGame)
+ : base(setGame)
+ {
+ isQuitting = false;
+ game = setGame;
+ gameWindow = new WindowsGameWindow();
+ gameWindow.Activated += delegate
+ {
+ OnActivated();
+ };
+ gameWindow.Deactivated += delegate
+ {
+ OnDeactivated();
+ };
+ WindowsGameWindow.Form.FormClosing += delegate
+ {
+ isQuitting = true;
+ };
+ }
+ #endregion
+
+ #region Run
+ public override void Run()
+ {
+ WindowsGameWindow.Form.Show();
+ while (isQuitting == false)
+ {
+ Application.DoEvents();
+ base.OnIdle();
+ }
+ gameWindow.Close();
+ }
+ #endregion
+
+ #region Exit
+ public override void Exit()
+ {
+ isQuitting = true;
+ }
+ #endregion
+ }
+}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameWindow.cs b/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameWindow.cs
new file mode 100644
index 00000000..17700622
--- /dev/null
+++ b/RenderSystems/ANX.Framework.Windows.GL3/WindowsGameWindow.cs
@@ -0,0 +1,169 @@
+using System;
+using System.Windows.Forms;
+using OpenTK;
+using OpenTK.Platform.Windows;
+
+#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.Windows.GL3
+{
+ internal class WindowsGameWindow : ANX.Framework.GameWindow
+ {
+ #region Public
+ internal static Form Form
+ {
+ get;
+ private set;
+ }
+
+ public override IntPtr Handle
+ {
+ get
+ {
+ return Form.Handle;
+ }
+ }
+
+ public override bool IsMinimized
+ {
+ get
+ {
+ return Form.WindowState == FormWindowState.Minimized;
+ }
+ }
+
+ #region AllowUserResizing
+ public override bool AllowUserResizing
+ {
+ get
+ {
+ return Form.FormBorderStyle == FormBorderStyle.Sizable;
+ }
+ set
+ {
+ Form.FormBorderStyle = value ?
+ FormBorderStyle.Sizable :
+ FormBorderStyle.Fixed3D;
+ }
+ }
+ #endregion
+
+ #region ClientBounds
+ public override Rectangle ClientBounds
+ {
+ get
+ {
+ System.Drawing.Rectangle rect = Form.ClientRectangle;
+ return new Rectangle(rect.X, rect.Y, rect.Width, rect.Height);
+ }
+ }
+ #endregion
+
+ #region CurrentOrientation
+ public override DisplayOrientation CurrentOrientation
+ {
+ get
+ {
+ return DisplayOrientation.Default;
+ }
+ }
+ #endregion
+ #endregion
+
+ #region Constructor
+ internal WindowsGameWindow()
+ {
+ Form = new Form()
+ {
+ Text = "ANX Framework",
+ MaximizeBox = false,
+ FormBorderStyle = FormBorderStyle.Fixed3D,
+ ClientSize = new System.Drawing.Size(800, 600),
+ };
+ }
+ #endregion
+
+ #region Close
+ public void Close()
+ {
+ if (Form != null)
+ {
+ Form.Close();
+ Form.Dispose();
+ Form = null;
+ }
+ }
+ #endregion
+
+ #region SetTitle
+ protected override void SetTitle(string title)
+ {
+ Form.Text = title;
+ }
+ #endregion
+
+ public override void BeginScreenDeviceChange(bool willBeFullScreen)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override void EndScreenDeviceChange(string screenDeviceName,
+ int clientWidth, int clientHeight)
+ {
+ throw new NotImplementedException();
+ }
+
+ public override string ScreenDeviceName
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj b/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj
new file mode 100644
index 00000000..736b55f1
--- /dev/null
+++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj
@@ -0,0 +1,81 @@
+
+
+
+ Debug
+ x86
+ 8.0.30703
+ 2.0
+ {B30DE9C2-0926-46B6-8351-9AF276C472D5}
+ Library
+ Properties
+ ANX.RenderSystem.Windows.DX11._1
+ ANX.RenderSystem.Windows.DX11.1
+ v4.0
+ Client
+ 512
+
+
+ x86
+ true
+ full
+ false
+ ..\..\bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+ true
+
+
+ x86
+ pdbonly
+ true
+ ..\..\bin\Release\
+ TRACE
+ prompt
+ 4
+ true
+
+
+
+
+
+
+ {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35}
+ ANX.Framework
+
+
+
+
+
+ False
+ ..\lib\SharpDX\Bin\SharpDX.dll
+
+
+ False
+ ..\lib\SharpDX\Bin\SharpDX.D3DCompiler.dll
+
+
+ ..\lib\SharpDX\Bin\SharpDX.Direct3D11.dll
+
+
+ False
+ ..\lib\SharpDX\Bin\SharpDX.DXGI.dll
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs
new file mode 100644
index 00000000..bb94b2e6
--- /dev/null
+++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs
@@ -0,0 +1,233 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.Graphics;
+using System.IO;
+using ANX.Framework.NonXNA;
+using System.Runtime.InteropServices;
+using ANX.Framework;
+
+#endregion // Using Statements
+
+#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.RenderSystem.Windows.DX11
+{
+ public class Creator : IRenderSystemCreator
+ {
+
+ public void RegisterCreator(AddInSystemFactory factory)
+ {
+ factory.AddCreator(this);
+ }
+
+ public string Name
+ {
+ get { return "DirectX11"; }
+ }
+
+ public GameHost CreateGameHost(Game game)
+ {
+ throw new NotImplementedException();
+ //return new WindowsGameHost(game);
+ }
+
+ public INativeGraphicsDevice CreateGraphicsDevice(PresentationParameters presentationParameters)
+ {
+ throw new NotImplementedException();
+ //return new GraphicsDeviceWindowsDX11_1(presentationParameters);
+ }
+
+ public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics, IndexElementSize size, int indexCount, BufferUsage usage)
+ {
+ throw new NotImplementedException();
+ //return new IndexBuffer_DX 11(graphics, size, indexCount, usage);
+ }
+
+ public INativeBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
+ {
+ return new VertexBuffer_DX11(graphics, vertexDeclaration, vertexCount, usage);
+ }
+
+ public INativeEffect CreateEffect(GraphicsDevice graphics, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
+ {
+ throw new NotImplementedException();
+ //return new Effect_DX11(graphics, vertexShaderByteCode, pixelShaderByteCode);
+ }
+
+ public INativeEffect CreateEffect(GraphicsDevice graphics, System.IO.Stream byteCode)
+ {
+ throw new NotImplementedException();
+ //return new Effect_DX11(graphics, byteCode);
+ }
+
+ public Texture2D CreateTexture(GraphicsDevice graphics, string fileName)
+ {
+ throw new NotImplementedException();
+
+ //GraphicsDeviceWindowsDX10 graphicsDX10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
+ //SharpDX.Direct3D10.Texture2D nativeTexture = SharpDX.Direct3D10.Texture2D.FromFile(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)
+ {
+ throw new NotImplementedException();
+
+/*
+ if (mipCount > 1)
+ {
+ throw new Exception("creating textures with mip map not yet implemented");
+ }
+
+ GraphicsDeviceWindowsDX10 graphicsDX10 = graphics.NativeDevice as GraphicsDeviceWindowsDX10;
+ SharpDX.Direct3D10.Device device = graphicsDX10.NativeDevice;
+ Texture2D_DX10 texture = new Texture2D_DX10(graphics, width, height);
+
+ SharpDX.Direct3D10.Texture2DDescription description = new SharpDX.Direct3D10.Texture2DDescription()
+ {
+ Width = width,
+ Height = height,
+ MipLevels = mipCount,
+ ArraySize = mipCount,
+ Format = SharpDX.DXGI.Format.R8G8B8A8_UNorm,
+ SampleDescription = new SharpDX.DXGI.SampleDescription(1, 0),
+ Usage = SharpDX.Direct3D10.ResourceUsage.Dynamic,
+ BindFlags = SharpDX.Direct3D10.BindFlags.ShaderResource,
+ CpuAccessFlags = SharpDX.Direct3D10.CpuAccessFlags.Write,
+ };
+ texture.NativeTexture = new SharpDX.Direct3D10.Texture2D(graphicsDX10.NativeDevice, description);
+
+ // description of texture formats of DX10: http://msdn.microsoft.com/en-us/library/bb694531(v=VS.85).aspx
+ // more helpfull information on DX10 textures: http://msdn.microsoft.com/en-us/library/windows/desktop/bb205131(v=vs.85).aspx
+
+ if (surfaceFormat == SurfaceFormat.Color)
+ {
+ int subresource = SharpDX.Direct3D10.Texture2D.CalculateSubresourceIndex(0, 0, 1);
+ SharpDX.DataRectangle rectangle = texture.NativeTexture.Map(subresource, SharpDX.Direct3D10.MapMode.WriteDiscard, SharpDX.Direct3D10.MapFlags.None);
+ int rowPitch = rectangle.Pitch;
+
+ unsafe
+ {
+ byte* pTexels = (byte*)rectangle.DataPointer;
+ int srcIndex = 0;
+
+ for (int row = 0; row < height; row++)
+ {
+ int rowStart = row * rowPitch;
+
+ for (int col = 0; col < width; col++)
+ {
+ int colStart = col * 4;
+ pTexels[rowStart + colStart + 0] = colorData[srcIndex++];
+ pTexels[rowStart + colStart + 1] = colorData[srcIndex++];
+ pTexels[rowStart + colStart + 2] = colorData[srcIndex++];
+ pTexels[rowStart + colStart + 3] = colorData[srcIndex++];
+ }
+ }
+ }
+
+ texture.NativeTexture.Unmap(subresource);
+ }
+ else
+ {
+ throw new Exception(string.Format("creating textures of format {0} not yet implemented...", surfaceFormat.ToString()));
+ }
+
+ return texture;
+*/
+ }
+
+
+ public INativeBlendState CreateBlendState()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public INativeRasterizerState CreateRasterizerState()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public INativeDepthStencilState CreateDepthStencilState()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public INativeSamplerState CreateSamplerState()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public byte[] GetShaderByteCode(PreDefinedShader type)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public System.Collections.ObjectModel.ReadOnlyCollection GetAdapterList()
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public Framework.NonXNA.RenderSystem.INativeTexture2D CreateTexture(GraphicsDevice graphics, SurfaceFormat surfaceFormat, int width, int height, int mipCount)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/Effect_DX11.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/Effect_DX11.cs
new file mode 100644
index 00000000..b38cd071
--- /dev/null
+++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/Effect_DX11.cs
@@ -0,0 +1,248 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SharpDX.Direct3D11;
+using SharpDX.D3DCompiler;
+using System.IO;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+
+#endregion // Using Statements
+
+#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.RenderSystem.Windows.DX11
+{
+ public class Effect_DX11 : INativeEffect
+ {
+ private ShaderBytecode pixelShaderByteCode;
+ private ShaderBytecode vertexShaderByteCode;
+ private VertexShader vertexShader;
+ private PixelShader pixelShader;
+
+ private ShaderBytecode effectByteCode;
+ private SharpDX.Direct3D11.Effect nativeEffect;
+
+ public Effect_DX11(GraphicsDevice device, Stream vertexShaderByteCode, Stream pixelShaderByteCode)
+ {
+ if (vertexShaderByteCode.CanSeek)
+ {
+ vertexShaderByteCode.Seek(0, SeekOrigin.Begin);
+ }
+ this.vertexShaderByteCode = ShaderBytecode.FromStream(vertexShaderByteCode);
+ this.vertexShader = new VertexShader((SharpDX.Direct3D11.Device)device.NativeDevice, this.vertexShaderByteCode);
+
+ if (pixelShaderByteCode.CanSeek)
+ {
+ pixelShaderByteCode.Seek(0, SeekOrigin.Begin);
+ }
+ this.pixelShaderByteCode = ShaderBytecode.FromStream(pixelShaderByteCode);
+ this.pixelShader = new PixelShader((SharpDX.Direct3D11.Device)device.NativeDevice, this.pixelShaderByteCode);
+ }
+
+ public Effect_DX11(GraphicsDevice device, Stream effectByteCode)
+ {
+ if (effectByteCode.CanSeek)
+ {
+ effectByteCode.Seek(0, SeekOrigin.Begin);
+ }
+ this.effectByteCode = ShaderBytecode.FromStream(effectByteCode);
+ this.nativeEffect = new SharpDX.Direct3D11.Effect(((GraphicsDeviceWindowsDX11)device.NativeDevice).NativeDevice, this.effectByteCode);
+ }
+
+ public void Apply(GraphicsDevice graphicsDevice)
+ {
+ //TODO: dummy
+ ((GraphicsDeviceWindowsDX11)graphicsDevice.NativeDevice).currentEffect = this;
+ }
+
+ internal SharpDX.Direct3D11.Effect NativeEffect
+ {
+ get
+ {
+ return this.nativeEffect;
+ }
+ }
+
+ internal ShaderBytecode PixelShaderByteCode
+ {
+ get
+ {
+ return this.pixelShaderByteCode;
+ }
+ }
+
+ internal ShaderBytecode VertexShaderByteCode
+ {
+ get
+ {
+ return this.vertexShaderByteCode;
+ }
+ }
+
+ internal VertexShader VertexShader
+ {
+ get
+ {
+ return this.vertexShader;
+ }
+ }
+
+ internal PixelShader PixelShader
+ {
+ get
+ {
+ return this.pixelShader;
+ }
+ }
+
+ public static byte[] CompileVertexShader(string effectCode)
+ {
+ ShaderBytecode vertexShaderByteCode = ShaderBytecode.Compile(effectCode, "VS", "vs_4_0", ShaderFlags.None, EffectFlags.None);
+ byte[] bytecode = new byte[vertexShaderByteCode.BufferSize];
+ vertexShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
+ return bytecode;
+ }
+
+ public static byte[] CompilePixelShader(string effectCode)
+ {
+ ShaderBytecode pixelShaderByteCode = ShaderBytecode.Compile(effectCode, "PS", "ps_4_0", ShaderFlags.None, EffectFlags.None);
+ byte[] bytecode = new byte[pixelShaderByteCode.BufferSize];
+ pixelShaderByteCode.Data.Read(bytecode, 0, bytecode.Length);
+ return bytecode;
+ }
+
+ public static byte[] CompileFXShader(string effectCode)
+ {
+ ShaderBytecode effectByteCode = ShaderBytecode.Compile(effectCode, "fx_4_0", ShaderFlags.None, EffectFlags.None);
+ byte[] bytecode = new byte[effectByteCode.BufferSize];
+ effectByteCode.Data.Read(bytecode, 0, bytecode.Length);
+ return bytecode;
+ }
+
+ public void Dispose()
+ {
+ if (this.pixelShaderByteCode != null)
+ {
+ this.pixelShaderByteCode.Dispose();
+ this.pixelShaderByteCode = null;
+ }
+
+ if (this.pixelShader != null)
+ {
+ this.pixelShader.Dispose();
+ this.pixelShader = null;
+ }
+
+ if (this.vertexShaderByteCode != null)
+ {
+ this.vertexShaderByteCode.Dispose();
+ this.vertexShaderByteCode = null;
+ }
+
+ if (this.vertexShader != null)
+ {
+ this.vertexShader.Dispose();
+ this.vertexShader = null;
+ }
+
+ if (this.effectByteCode != null)
+ {
+ this.effectByteCode.Dispose();
+ this.effectByteCode = null;
+ }
+
+ if (this.nativeEffect != null)
+ {
+ this.nativeEffect.Dispose();
+ this.nativeEffect = null;
+ }
+ }
+
+
+ public IEnumerable Techniques
+ {
+ get
+ {
+ throw new NotImplementedException();
+
+ //for (int i = 0; i < nativeEffect.Description.TechniqueCount; i++)
+ //{
+ // EffectTechnique_DX11 teqDx11 = new EffectTechnique_DX11();
+ // teqDx10.NativeTechnique = nativeEffect.GetTechniqueByIndex(i);
+
+ // ANX.Framework.Graphics.EffectTechnique teq = new ANX.Framework.Graphics.EffectTechnique();
+ // teq.NativeTechnique = teqDx11;
+
+ // yield return teq;
+ //}
+ }
+ }
+
+ public IEnumerable Parameters
+ {
+ get
+ {
+ throw new NotImplementedException();
+
+ //for (int i = 0; i < nativeEffect.Description.GlobalVariableCount; i++)
+ //{
+ // EffectParameter_DX10 parDx10 = new EffectParameter_DX10();
+ // parDx10.NativeParameter = nativeEffect.GetVariableByIndex(i);
+
+ // Graphics.EffectParameter par = new Graphics.EffectParameter();
+ // par.NativeParameter = parDx10;
+
+ // yield return par;
+ //}
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs
new file mode 100644
index 00000000..ac5d65cb
--- /dev/null
+++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs
@@ -0,0 +1,653 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using SharpDX;
+using SharpDX.DXGI;
+using SharpDX.Direct3D;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+using SharpDX.Direct3D11;
+using ANX.Framework;
+using ANX.Framework.Graphics;
+using SharpDX.D3DCompiler;
+
+#endregion // Using Statements
+
+#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
+
+using Device = SharpDX.Direct3D11.Device;
+using Buffer = SharpDX.Direct3D11.Buffer;
+
+namespace ANX.RenderSystem.Windows.DX11
+{
+ public class GraphicsDeviceWindowsDX11 : INativeGraphicsDevice
+ {
+ private Device device;
+ private SwapChain swapChain;
+ private RenderTargetView renderView;
+ private SharpDX.Direct3D11.Texture2D backBuffer;
+ internal Effect_DX11 currentEffect;
+ private VertexBuffer currentVertexBuffer;
+ private IndexBuffer currentIndexBuffer;
+ private SharpDX.Direct3D11.Viewport currentViewport;
+
+ public GraphicsDeviceWindowsDX11(PresentationParameters presentationParameters)
+ {
+ // SwapChain description
+ var desc = new SwapChainDescription()
+ {
+ BufferCount = 1,
+ ModeDescription = new ModeDescription(presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight, new Rational(60, 1), Format.R8G8B8A8_UNorm),
+ IsWindowed = true,
+ OutputHandle = presentationParameters.DeviceWindowHandle,
+ SampleDescription = new SampleDescription(1, 0),
+ SwapEffect = SwapEffect.Discard,
+ Usage = Usage.RenderTargetOutput
+ };
+
+ // Create Device and SwapChain
+#if DIRECTX_DEBUG_LAYER
+ // http://msdn.microsoft.com/en-us/library/windows/desktop/bb205068(v=vs.85).aspx
+ Device.CreateWithSwapChain(SharpDX.Direct3D10.DriverType.Hardware, DeviceCreationFlags.Debug, desc, out device, out swapChain);
+#else
+ Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, desc, out device, out swapChain);
+#endif
+
+ // Ignore all windows events
+ Factory factory = swapChain.GetParent();
+ factory.MakeWindowAssociation(presentationParameters.DeviceWindowHandle, WindowAssociationFlags.IgnoreAll);
+
+ // New RenderTargetView from the backbuffer
+ backBuffer = SharpDX.Direct3D11.Texture2D.FromSwapChain(swapChain, 0);
+ renderView = new RenderTargetView(device, backBuffer);
+
+ currentViewport = new SharpDX.Direct3D11.Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight);
+ }
+
+ public void Clear(ref Color color)
+ {
+ throw new NotImplementedException();
+ //device.ClearRenderTargetView(renderView, new SharpDX.Color4(color.A / 255f, color.R / 255f, color.G / 255f, color.B / 255f));
+ }
+
+ public void Present()
+ {
+ swapChain.Present(0, PresentFlags.None);
+ }
+
+ internal Device NativeDevice
+ {
+ get
+ {
+ return this.device;
+ }
+ }
+
+ private void SetupEffectForDraw(out SharpDX.Direct3D11.EffectPass pass, out SharpDX.Direct3D11.EffectTechnique technique, out ShaderBytecode passSignature)
+ {
+ // get the current effect
+ //TODO: check for null and throw exception
+ Effect_DX11 effect = this.currentEffect;
+
+ // get the input semantic of the current effect / technique that is used
+ //TODO: check for null's and throw exceptions
+ technique = effect.NativeEffect.GetTechniqueByIndex(0);
+ pass = technique.GetPassByIndex(0);
+ passSignature = pass.Description.Signature;
+ }
+
+ private void SetupInputLayout(ShaderBytecode passSignature)
+ {
+ // get the VertexDeclaration from current VertexBuffer to create input layout for the input assembler
+ //TODO: check for null and throw exception
+ VertexDeclaration vertexDeclaration = currentVertexBuffer.VertexDeclaration;
+ var layout = CreateInputLayout(device, passSignature, vertexDeclaration);
+
+ throw new NotImplementedException();
+
+ //device.InputAssembler.InputLayout = layout;
+ }
+
+ private int CalculateVertexCount(PrimitiveType type, int primitiveCount)
+ {
+ if (type == PrimitiveType.TriangleList)
+ {
+ return primitiveCount * 3;
+ }
+ else if (type == PrimitiveType.LineList)
+ {
+ return primitiveCount * 2;
+ }
+ else if (type == PrimitiveType.LineStrip)
+ {
+ return primitiveCount + 1;
+ }
+ else if (type == PrimitiveType.TriangleStrip)
+ {
+ return primitiveCount + 2;
+ }
+ else
+ {
+ throw new NotImplementedException("couldn't calculate vertex count for PrimitiveType '" + type.ToString() + "'");
+ }
+ }
+
+ public void DrawIndexedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount)
+ {
+ SharpDX.Direct3D11.EffectPass pass; SharpDX.Direct3D11.EffectTechnique technique; ShaderBytecode passSignature;
+ SetupEffectForDraw(out pass, out technique, out passSignature);
+
+ SetupInputLayout(passSignature);
+
+ throw new NotImplementedException();
+
+ // Prepare All the stages
+ //device.InputAssembler.PrimitiveTopology = Translate(primitiveType);
+ //device.Rasterizer.SetViewports(currentViewport);
+
+ //device.OutputMerger.SetTargets(this.renderView);
+
+ //for (int i = 0; i < technique.Description.PassCount; ++i)
+ //{
+ // pass.Apply();
+ // device.DrawIndexed(CalculateVertexCount(primitiveType, primitiveCount), startIndex, baseVertex);
+ //}
+ }
+
+ public void DrawPrimitives(PrimitiveType primitiveType, int vertexOffset, int primitiveCount)
+ {
+ SharpDX.Direct3D11.EffectPass pass; SharpDX.Direct3D11.EffectTechnique technique; ShaderBytecode passSignature;
+ SetupEffectForDraw(out pass, out technique, out passSignature);
+
+ SetupInputLayout(passSignature);
+
+ throw new NotImplementedException();
+
+ // Prepare All the stages
+ //device.InputAssembler.PrimitiveTopology = Translate(primitiveType);
+ //device.Rasterizer.SetViewports(currentViewport);
+ //device.OutputMerger.SetTargets(this.renderView);
+
+ //for (int i = 0; i < technique.Description.PassCount; ++i)
+ //{
+ // pass.Apply();
+ // device.Draw(primitiveCount, vertexOffset);
+ //}
+ }
+
+ public void SetIndexBuffer(IndexBuffer indexBuffer)
+ {
+ if (indexBuffer == null)
+ {
+ throw new ArgumentNullException("indexBuffer");
+ }
+
+ this.currentIndexBuffer = indexBuffer;
+
+ throw new NotImplementedException();
+
+ //IndexBuffer_DX11 nativeIndexBuffer = indexBuffer.NativeIndexBuffer as IndexBuffer_DX11;
+
+ //if (nativeIndexBuffer != null)
+ //{
+ // device.InputAssembler.SetIndexBuffer(nativeIndexBuffer.NativeBuffer, Translate(indexBuffer.IndexElementSize), 0);
+ //}
+ //else
+ //{
+ // throw new Exception("couldn't fetch native DirectX11.1 IndexBuffer");
+ //}
+ }
+
+ public void SetVertexBuffers(ANX.Framework.Graphics.VertexBufferBinding[] vertexBuffers)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void SetViewport(ANX.Framework.Graphics.Viewport viewport)
+ {
+ this.currentViewport = new SharpDX.Direct3D11.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height, viewport.MinDepth, viewport.MaxDepth);
+ }
+
+ public void ApplyStateObject(ANX.Framework.Graphics.BlendState blendState)
+ {
+ throw new NotImplementedException();
+
+ //BlendStateDescription description = new BlendStateDescription();
+ //description.AlphaBlendOperation = Translate(blendState.AlphaBlendFunction);
+ //description.BlendOperation = Translate(blendState.ColorBlendFunction);
+ //description.DestinationAlphaBlend = Translate(blendState.AlphaDestinationBlend);
+ //description.DestinationBlend = Translate(blendState.ColorDestinationBlend);
+
+ //for (int i = 0; i < 4; i++)
+ //{
+ // description.IsBlendEnabled[i] = true;
+ //}
+
+ //description.RenderTargetWriteMask[0] = Translate(blendState.ColorWriteChannels);
+ //description.RenderTargetWriteMask[1] = Translate(blendState.ColorWriteChannels1);
+ //description.RenderTargetWriteMask[2] = Translate(blendState.ColorWriteChannels2);
+ //description.RenderTargetWriteMask[3] = Translate(blendState.ColorWriteChannels3);
+
+ //description.SourceAlphaBlend = Translate(blendState.AlphaSourceBlend);
+ //description.SourceBlend = Translate(blendState.ColorSourceBlend);
+
+ //SharpDX.Direct3D11.BlendState nativeBlendState = new SharpDX.Direct3D11.BlendState(device, description);
+
+ //Vector4 tempVector = blendState.BlendFactor.ToVector4();
+ //SharpDX.Color4 blendFactor = new Color4(tempVector.X, tempVector.Y, tempVector.Z, tempVector.W);
+ //device.OutputMerger.SetBlendState(nativeBlendState, blendFactor, blendState.MultiSampleMask);
+ }
+
+ public void ApplyStateObject(ANX.Framework.Graphics.RasterizerState rasterizerState)
+ {
+ RasterizerStateDescription description = new RasterizerStateDescription();
+ description.CullMode = Translate(rasterizerState.CullMode);
+ description.DepthBias = (int)rasterizerState.DepthBias; //TODO: this looks wrong!!!
+ description.IsScissorEnabled = rasterizerState.ScissorTestEnable;
+ description.SlopeScaledDepthBias = rasterizerState.SlopeScaleDepthBias;
+ description.IsMultisampleEnabled = rasterizerState.MultiSampleAntiAlias;
+ description.FillMode = Translate(rasterizerState.FillMode);
+
+ description.IsAntialiasedLineEnabled = false; //TODO: this should be ok
+
+ SharpDX.Direct3D11.RasterizerState nativeRasterizerState = new SharpDX.Direct3D11.RasterizerState(device, description);
+
+ //device.Rasterizer.State = nativeRasterizerState;
+ throw new NotImplementedException();
+ }
+
+ public void ApplyStateObject(ANX.Framework.Graphics.DepthStencilState depthStencilState)
+ {
+ DepthStencilStateDescription description = new DepthStencilStateDescription();
+ description.IsStencilEnabled = depthStencilState.StencilEnable;
+ description.IsDepthEnabled = depthStencilState.DepthBufferEnable;
+ description.DepthComparison = Translate(depthStencilState.DepthBufferFunction);
+
+ //TODO: more to implement
+
+ SharpDX.Direct3D11.DepthStencilState nativeDepthStencilState = new SharpDX.Direct3D11.DepthStencilState(device, description);
+ //device.OutputMerger.SetDepthStencilState(nativeDepthStencilState, depthStencilState.ReferenceStencil);
+ throw new NotImplementedException();
+ }
+
+ public void ApplyStateObject(int slot, ANX.Framework.Graphics.SamplerState samplerState)
+ {
+ SamplerStateDescription description = new SamplerStateDescription();
+ description.AddressU = Translate(samplerState.AddressU);
+ description.AddressV = Translate(samplerState.AddressV);
+ description.AddressW = Translate(samplerState.AddressW);
+ description.Filter = Translate(samplerState.Filter);
+ description.MaximumAnisotropy = samplerState.MaxAnisotropy;
+ description.MaximumLod = samplerState.MaxMipLevel; //TODO: is this correct?
+ description.MipLodBias = samplerState.MipMapLevelOfDetailBias;
+
+ SharpDX.Direct3D11.SamplerState nativeSamplerState = new SharpDX.Direct3D11.SamplerState(device, description);
+ //device.PixelShader.SetSampler(slot, nativeSamplerState);
+ throw new NotImplementedException();
+ }
+
+ private Filter Translate(TextureFilter filter)
+ {
+ switch (filter)
+ {
+ case TextureFilter.Anisotropic:
+ return Filter.Anisotropic;
+ case TextureFilter.Linear:
+ return Filter.MinMagMipLinear;
+ case TextureFilter.LinearMipPoint:
+ return Filter.MinMagMipPoint;
+ case TextureFilter.MinLinearMagPointMipLinear:
+ return Filter.MinLinearMagPointMipLinear;
+ case TextureFilter.MinLinearMagPointMipPoint:
+ return Filter.MinLinearMagMipPoint;
+ case TextureFilter.MinPointMagLinearMipLinear:
+ return Filter.MinPointMagMipLinear;
+ case TextureFilter.MinPointMagLinearMipPoint:
+ return Filter.MinPointMagLinearMipPoint;
+ case TextureFilter.Point:
+ return Filter.MinMagMipPoint;
+ case TextureFilter.PointMipLinear:
+ return Filter.MinMagPointMipLinear;
+ }
+
+ throw new NotImplementedException();
+ }
+
+ private SharpDX.Direct3D11.TextureAddressMode Translate(ANX.Framework.Graphics.TextureAddressMode addressMode)
+ {
+ switch (addressMode)
+ {
+ case ANX.Framework.Graphics.TextureAddressMode.Clamp:
+ return SharpDX.Direct3D11.TextureAddressMode.Clamp;
+ case ANX.Framework.Graphics.TextureAddressMode.Mirror:
+ return SharpDX.Direct3D11.TextureAddressMode.Mirror;
+ case ANX.Framework.Graphics.TextureAddressMode.Wrap:
+ return SharpDX.Direct3D11.TextureAddressMode.Wrap;
+ }
+
+ return SharpDX.Direct3D11.TextureAddressMode.Clamp;
+ }
+
+ ///
+ /// This method creates a InputLayout which is needed by DirectX 10 for rendering primitives. The VertexDeclaration of ANX/XNA needs to be mapped
+ /// to the DirectX 10 types. This is what this method is for.
+ ///
+ private InputLayout CreateInputLayout(Device device, ShaderBytecode passSignature, VertexDeclaration vertexDeclaration)
+ {
+ VertexElement[] vertexElements = vertexDeclaration.GetVertexElements();
+ int elementCount = vertexElements.Length;
+ InputElement[] inputElements = new InputElement[elementCount];
+
+ for (int i = 0; i < elementCount; i++)
+ {
+ inputElements[i] = CreateInputElementFromVertexElement(vertexElements[i]);
+ }
+
+ // Layout from VertexShader input signature
+ return new InputLayout(device, passSignature, inputElements);
+ }
+
+ private InputElement CreateInputElementFromVertexElement(VertexElement vertexElement)
+ {
+ string elementName = Translate(vertexElement.VertexElementUsage);
+
+ Format elementFormat;
+ switch (vertexElement.VertexElementFormat)
+ {
+ case VertexElementFormat.Vector2:
+ elementFormat = Format.R32G32_Float;
+ break;
+ case VertexElementFormat.Vector3:
+ elementFormat = Format.R32G32B32_Float;
+ break;
+ case VertexElementFormat.Vector4:
+ elementFormat = Format.R32G32B32A32_Float;
+ break;
+ case VertexElementFormat.Color:
+ elementFormat = Format.R8G8B8A8_UNorm;
+ break;
+ default:
+ throw new Exception("can't map '" + vertexElement.VertexElementFormat.ToString() + "' to DXGI.Format in DirectX10 RenderSystem CreateInputElementFromVertexElement");
+ }
+
+ return new InputElement(elementName, vertexElement.UsageIndex, elementFormat, vertexElement.Offset, 0);
+ }
+
+ private PrimitiveTopology Translate(PrimitiveType primitiveType)
+ {
+ switch (primitiveType)
+ {
+ case PrimitiveType.LineList:
+ return PrimitiveTopology.LineList;
+ case PrimitiveType.LineStrip:
+ return PrimitiveTopology.LineStrip;
+ case PrimitiveType.TriangleList:
+ return PrimitiveTopology.TriangleList;
+ case PrimitiveType.TriangleStrip:
+ return PrimitiveTopology.TriangleStrip;
+ default:
+ throw new InvalidOperationException("unknown PrimitiveType: " + primitiveType.ToString());
+ }
+ }
+
+ private SharpDX.DXGI.Format Translate(IndexElementSize indexElementSize)
+ {
+ switch (indexElementSize)
+ {
+ case IndexElementSize.SixteenBits:
+ return Format.R16_UInt;
+ case IndexElementSize.ThirtyTwoBits:
+ return Format.R32_UInt;
+ default:
+ throw new InvalidOperationException("unknown IndexElementSize: " + indexElementSize.ToString());
+ }
+ }
+
+ private string Translate(VertexElementUsage usage)
+ {
+ //TODO: map the other Usages
+ if (usage == VertexElementUsage.TextureCoordinate)
+ {
+ return "TEXCOORD";
+ }
+ else
+ {
+ return usage.ToString().ToUpperInvariant();
+ }
+ }
+
+ private ColorWriteMaskFlags Translate(ColorWriteChannels colorWriteChannels)
+ {
+ switch (colorWriteChannels)
+ {
+ case ColorWriteChannels.All:
+ return ColorWriteMaskFlags.All;
+ case ColorWriteChannels.Alpha:
+ return ColorWriteMaskFlags.Alpha;
+ case ColorWriteChannels.Blue:
+ return ColorWriteMaskFlags.Blue;
+ case ColorWriteChannels.Green:
+ return ColorWriteMaskFlags.Green;
+ case ColorWriteChannels.Red:
+ return ColorWriteMaskFlags.Red;
+ }
+
+ return 0;
+ }
+
+ private BlendOption Translate(Blend blend)
+ {
+ switch (blend)
+ {
+ case Blend.BlendFactor:
+ return BlendOption.BlendFactor;
+ case Blend.DestinationAlpha:
+ return BlendOption.DestinationAlpha;
+ case Blend.DestinationColor:
+ return BlendOption.DestinationColor;
+ case Blend.InverseBlendFactor:
+ return BlendOption.InverseBlendFactor;
+ case Blend.InverseDestinationAlpha:
+ return BlendOption.InverseDestinationAlpha;
+ case Blend.InverseDestinationColor:
+ return BlendOption.InverseDestinationColor;
+ case Blend.InverseSourceAlpha:
+ return BlendOption.InverseSourceAlpha;
+ case Blend.InverseSourceColor:
+ return BlendOption.InverseSourceColor;
+ case Blend.One:
+ return BlendOption.One;
+ case Blend.SourceAlpha:
+ return BlendOption.SourceAlpha;
+ case Blend.SourceAlphaSaturation:
+ return BlendOption.SourceAlphaSaturate;
+ case Blend.SourceColor:
+ return BlendOption.SourceColor;
+ case Blend.Zero:
+ return BlendOption.Zero;
+ }
+
+ return BlendOption.One;
+ }
+
+ private BlendOperation Translate(BlendFunction blendFunction)
+ {
+ switch (blendFunction)
+ {
+ case BlendFunction.Add:
+ return BlendOperation.Add;
+ case BlendFunction.Max:
+ return BlendOperation.Maximum;
+ case BlendFunction.Min:
+ return BlendOperation.Minimum;
+ case BlendFunction.ReverseSubtract:
+ return BlendOperation.ReverseSubtract;
+ case BlendFunction.Subtract:
+ return BlendOperation.Subtract;
+ }
+
+ return BlendOperation.Add;
+ }
+
+ private SharpDX.Direct3D11.FillMode Translate(ANX.Framework.Graphics.FillMode fillMode)
+ {
+ if (fillMode == ANX.Framework.Graphics.FillMode.WireFrame)
+ {
+ return SharpDX.Direct3D11.FillMode.Wireframe;
+ }
+ else
+ {
+ return SharpDX.Direct3D11.FillMode.Solid;
+ }
+ }
+
+ private SharpDX.Direct3D11.CullMode Translate(ANX.Framework.Graphics.CullMode cullMode)
+ {
+ if (cullMode == ANX.Framework.Graphics.CullMode.CullClockwiseFace)
+ {
+ return SharpDX.Direct3D11.CullMode.Front;
+ }
+ else if (cullMode == ANX.Framework.Graphics.CullMode.CullCounterClockwiseFace)
+ {
+ return SharpDX.Direct3D11.CullMode.Back;
+ }
+ else
+ {
+ return SharpDX.Direct3D11.CullMode.None;
+ }
+ }
+
+ private Comparison Translate(CompareFunction compareFunction)
+ {
+ switch (compareFunction)
+ {
+ case CompareFunction.Always:
+ return Comparison.Always;
+ case CompareFunction.Equal:
+ return Comparison.Equal;
+ case CompareFunction.Greater:
+ return Comparison.Greater;
+ case CompareFunction.GreaterEqual:
+ return Comparison.GreaterEqual;
+ case CompareFunction.Less:
+ return Comparison.Less;
+ case CompareFunction.LessEqual:
+ return Comparison.LessEqual;
+ case CompareFunction.Never:
+ return Comparison.Never;
+ case CompareFunction.NotEqual:
+ return Comparison.NotEqual;
+ }
+
+ return Comparison.Always;
+ }
+
+ public void SetRenderTargets(params Framework.Graphics.RenderTargetBinding[] renderTargets)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public void GetBackBufferData(Framework.Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ throw new NotImplementedException();
+ }
+
+ public void GetBackBufferData(T[] data) where T : struct
+ {
+ throw new NotImplementedException();
+ }
+
+ public void GetBackBufferData(T[] data, int startIndex, int elementCount) where T : struct
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public void Clear(Framework.Graphics.ClearOptions options, Framework.Vector4 color, float depth, int stencil)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawInstancedPrimitives(Framework.Graphics.PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount)
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawUserIndexedPrimitives(Framework.Graphics.PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int numVertices, Array indexData, int indexOffset, int primitiveCount, Framework.Graphics.VertexDeclaration vertexDeclaration, Framework.Graphics.IndexElementSize indexFormat) where T : struct, Framework.Graphics.IVertexType
+ {
+ throw new NotImplementedException();
+ }
+
+ public void DrawUserPrimitives(Framework.Graphics.PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, Framework.Graphics.VertexDeclaration vertexDeclaration) where T : struct, Framework.Graphics.IVertexType
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public void ResizeBuffers(Framework.Graphics.PresentationParameters presentationParameters)
+ {
+ throw new NotImplementedException();
+ }
+
+
+ public bool VSync
+ {
+ get
+ {
+ throw new NotImplementedException();
+ }
+ set
+ {
+ throw new NotImplementedException();
+ }
+ }
+ }
+}
diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/Properties/AssemblyInfo.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/Properties/AssemblyInfo.cs
new file mode 100644
index 00000000..91a5d86a
--- /dev/null
+++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/Properties/AssemblyInfo.cs
@@ -0,0 +1,33 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// Allgemeine Informationen über eine Assembly werden über die folgenden
+// Attribute gesteuert. Ändern Sie diese Attributwerte, um die Informationen zu ändern,
+// die mit einer Assembly verknüpft sind.
+[assembly: AssemblyTitle("ANX.RenderSystem.Windows.DX11.1")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("ANX.Framework Team")]
+[assembly: AssemblyProduct("ANX.RenderSystem.Windows.DX11.1")]
+[assembly: AssemblyCopyright("Copyright (c) ANX.Framework Team 2011")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Durch Festlegen von ComVisible auf "false" werden die Typen in dieser Assembly unsichtbar
+// für COM-Komponenten. Wenn Sie auf einen Typ in dieser Assembly von
+// COM zugreifen müssen, legen Sie das ComVisible-Attribut für diesen Typ auf "true" fest.
+[assembly: ComVisible(false)]
+
+// Die folgende GUID bestimmt die ID der Typbibliothek, wenn dieses Projekt für COM verfügbar gemacht wird
+[assembly: Guid("6feac6f6-2540-45ab-bbc1-391405fba77c")]
+
+// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten:
+//
+// Hauptversion
+// Nebenversion
+// Buildnummer
+// Revision
+//
+[assembly: AssemblyVersion("0.1.1.0")]
+[assembly: AssemblyFileVersion("0.1.1.0")]
diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/VertexBuffer_DX11.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/VertexBuffer_DX11.cs
new file mode 100644
index 00000000..b6d728ea
--- /dev/null
+++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/VertexBuffer_DX11.cs
@@ -0,0 +1,146 @@
+#region Using Statements
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using ANX.Framework.NonXNA;
+using SharpDX.Direct3D11;
+using ANX.Framework.Graphics;
+
+#endregion // Using Statements
+
+#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.RenderSystem.Windows.DX11
+{
+ public class VertexBuffer_DX11 : INativeBuffer, IDisposable
+ {
+ SharpDX.Direct3D11.Buffer buffer;
+ int vertexStride;
+
+ public VertexBuffer_DX11(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
+ {
+ this.vertexStride = vertexDeclaration.VertexStride;
+
+ //TODO: translate and use usage
+
+ GraphicsDeviceWindowsDX11 gd11 = graphics.NativeDevice as GraphicsDeviceWindowsDX11;
+ SharpDX.Direct3D11.Device device = gd11 != null ? gd11.NativeDevice as SharpDX.Direct3D11.Device : null;
+
+ if (device != null)
+ {
+ BufferDescription description = new BufferDescription()
+ {
+ Usage = ResourceUsage.Dynamic,
+ SizeInBytes = vertexDeclaration.VertexStride * vertexCount,
+ BindFlags = BindFlags.VertexBuffer,
+ CpuAccessFlags = CpuAccessFlags.Write,
+ OptionFlags = ResourceOptionFlags.None
+ };
+
+ this.buffer = new SharpDX.Direct3D11.Buffer(device, description);
+ //this.buffer.Unmap();
+ }
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ if (startIndex > 0 || elementCount < data.Length)
+ {
+ throw new NotImplementedException("currently starIndex and elementCount of SetData are not implemented");
+ }
+
+ //TODO: check offsetInBytes parameter for bounds etc.
+
+ throw new NotImplementedException();
+
+ /*
+ using (var vData = new SharpDX.DataStream(data, true, false))
+ {
+ if (offsetInBytes > 0)
+ {
+ vData.Seek(offsetInBytes / vertexStride, System.IO.SeekOrigin.Begin);
+ }
+
+ using (var d = buffer.Map(MapMode.WriteDiscard))
+ {
+ vData.CopyTo(d);
+ buffer.Unmap();
+ }
+ }
+ */
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data) where T : struct
+ {
+ SetData(graphicsDevice, data, 0, data.Length);
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data, int startIndex, int elementCount) where T : struct
+ {
+ SetData(graphicsDevice, 0, data, startIndex, elementCount);
+ }
+
+ public SharpDX.Direct3D11.Buffer NativeBuffer
+ {
+ get
+ {
+ return this.buffer;
+ }
+ }
+
+ public void Dispose()
+ {
+ if (this.buffer != null)
+ {
+ buffer.Dispose();
+ buffer = null;
+ }
+ }
+ }
+}