From d8d88b141c310d0535383378885ddfadcc14603b Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Tue, 22 Nov 2011 14:51:30 +0000 Subject: [PATCH] added new target "create_packages" in build script PreferredBackBufferWidth and PreferredBackBufferHeight are returning values now added EffectPass handling applying effects is not a workaround anymore --- ANX.Framework/ANX.Framework.csproj | 1 + ANX.Framework/Graphics/Effect.cs | 5 +- ANX.Framework/Graphics/EffectPass.cs | 13 ++- .../Graphics/EffectPassCollection.cs | 56 +++++++++---- ANX.Framework/Graphics/EffectTechnique.cs | 17 ++-- ANX.Framework/Graphics/GraphicsDevice.cs | 60 ++++++++----- ANX.Framework/GraphicsDeviceManager.cs | 14 +++- .../NonXNA/RenderSystem/INativeEffectPass.cs | 61 ++++++++++++++ .../RenderSystem/INativeEffectTechnique.cs | 4 + .../RenderSystem/INativeGraphicsDevice.cs | 2 +- .../RenderSystem/IRenderSystemCreator.cs | 4 +- ANX.Framework/Properties/AssemblyInfo.cs | 6 +- .../ANX.Framework.Windows.DX10.csproj | 1 + .../ANX.Framework.Windows.DX10/Creator.cs | 8 +- .../EffectPass_DX10.cs | 84 +++++++++++++++++++ .../EffectTechnique_DX10.cs | 28 +++++++ .../ANX.Framework.Windows.DX10/Effect_DX10.cs | 23 +++-- .../GraphicsDeviceWindowsDX10.cs | 5 ++ .../Properties/AssemblyInfo.cs | 4 +- .../ANX.Framework.Windows.GL3/Creator.cs | 8 +- .../ANX.Framework.Windows.GL3/EffectGL3.cs | 19 ++--- .../EffectTechniqueGL3.cs | 12 ++- .../GraphicsDeviceWindowsGL3.cs | 7 +- .../Properties/AssemblyInfo.cs | 4 +- .../ANX.RenderSystem.Windows.DX11.csproj | 4 +- .../ANX.RenderSystem.Windows.DX11/Creator.cs | 4 +- .../GraphicsDeviceWindowsDX11.cs | 5 ++ Samples/VertexIndexBuffer/Game1.cs | 3 +- build/ANX.Framework.build | 7 +- 29 files changed, 376 insertions(+), 93 deletions(-) create mode 100644 ANX.Framework/NonXNA/RenderSystem/INativeEffectPass.cs create mode 100644 RenderSystems/ANX.Framework.Windows.DX10/EffectPass_DX10.cs diff --git a/ANX.Framework/ANX.Framework.csproj b/ANX.Framework/ANX.Framework.csproj index 213dce7c..b364cc71 100644 --- a/ANX.Framework/ANX.Framework.csproj +++ b/ANX.Framework/ANX.Framework.csproj @@ -432,6 +432,7 @@ + diff --git a/ANX.Framework/Graphics/Effect.cs b/ANX.Framework/Graphics/Effect.cs index 5bff9b8e..45413ddb 100644 --- a/ANX.Framework/Graphics/Effect.cs +++ b/ANX.Framework/Graphics/Effect.cs @@ -76,7 +76,7 @@ namespace ANX.Framework.Graphics public Effect(GraphicsDevice graphicsDevice, byte[] byteCode) : base(graphicsDevice) { - this.nativeEffect = AddInSystemFactory.Instance.GetDefaultCreator().CreateEffect(graphicsDevice, new MemoryStream(byteCode, false)); + this.nativeEffect = AddInSystemFactory.Instance.GetDefaultCreator().CreateEffect(graphicsDevice, this, new MemoryStream(byteCode, false)); this.techniqueCollection = new EffectTechniqueCollection(this, this.nativeEffect); this.currentTechnique = this.techniqueCollection[0]; @@ -89,8 +89,7 @@ namespace ANX.Framework.Graphics throw new NotImplementedException(); } - [Obsolete("This is not a original XNA property")] - public INativeEffect NativeEffect + internal INativeEffect NativeEffect { get { diff --git a/ANX.Framework/Graphics/EffectPass.cs b/ANX.Framework/Graphics/EffectPass.cs index 79247a31..8d786aa0 100644 --- a/ANX.Framework/Graphics/EffectPass.cs +++ b/ANX.Framework/Graphics/EffectPass.cs @@ -56,10 +56,21 @@ namespace ANX.Framework.Graphics { private string name; private EffectAnnotationCollection annotations; + private Effect parentEffect; + + internal EffectPass(Effect parentEffect) + { + if (parentEffect == null) + { + throw new ArgumentNullException("parentEffect"); + } + + this.parentEffect = parentEffect; + } public void Apply() { - throw new NotImplementedException(); + this.parentEffect.NativeEffect.Apply(this.parentEffect.GraphicsDevice); } public string Name diff --git a/ANX.Framework/Graphics/EffectPassCollection.cs b/ANX.Framework/Graphics/EffectPassCollection.cs index 1571ccbd..4a5d948a 100644 --- a/ANX.Framework/Graphics/EffectPassCollection.cs +++ b/ANX.Framework/Graphics/EffectPassCollection.cs @@ -2,6 +2,7 @@ using System; using System.Collections.Generic; using System.Collections; +using ANX.Framework.NonXNA; #endregion // Using Statements @@ -56,12 +57,37 @@ namespace ANX.Framework.Graphics { public sealed class EffectPassCollection : IEnumerable { + #region Private Members + private Effect parentEffect; + private INativeEffect nativeEffect; + private INativeEffectTechnique parentTechnique; + private List passes; + + #endregion // Private Members + + internal EffectPassCollection(Effect parentEffect, INativeEffect nativeEffect, INativeEffectTechnique parentTechnique) + { + this.parentEffect = parentEffect; + this.nativeEffect = nativeEffect; + this.parentTechnique = parentTechnique; + this.passes = new List(); + + foreach (EffectPass pass in parentTechnique.Passes) + { + this.passes.Add(pass); + } + } public EffectPass this[int index] { get { - throw new NotImplementedException(); + if (index >= passes.Count) + { + throw new ArgumentOutOfRangeException("index"); + } + + return passes[index]; } } @@ -71,28 +97,28 @@ namespace ANX.Framework.Graphics { throw new NotImplementedException(); } - } + } - IEnumerator IEnumerable.GetEnumerator() - { - throw new NotImplementedException(); - } + IEnumerator IEnumerable.GetEnumerator() + { + throw new NotImplementedException(); + } - IEnumerator IEnumerable.GetEnumerator() - { - throw new NotImplementedException(); - } + IEnumerator IEnumerable.GetEnumerator() + { + throw new NotImplementedException(); + } - public List.Enumerator GetEnumerator() - { - throw new NotImplementedException(); - } + public List.Enumerator GetEnumerator() + { + throw new NotImplementedException(); + } public int Count { get { - throw new NotImplementedException(); + return this.passes.Count; } } } diff --git a/ANX.Framework/Graphics/EffectTechnique.cs b/ANX.Framework/Graphics/EffectTechnique.cs index 4b209633..b958f3dd 100644 --- a/ANX.Framework/Graphics/EffectTechnique.cs +++ b/ANX.Framework/Graphics/EffectTechnique.cs @@ -58,18 +58,23 @@ namespace ANX.Framework.Graphics { public sealed class EffectTechnique { + private Effect parentEffect; private INativeEffectTechnique nativeTechnique; + private EffectPassCollection effectPassCollection; - public INativeEffectTechnique NativeTechnique + internal EffectTechnique(Effect parentEffect, INativeEffectTechnique nativeTechnique) + { + this.parentEffect = parentEffect; + this.nativeTechnique = nativeTechnique; + this.effectPassCollection = new EffectPassCollection(parentEffect, parentEffect.NativeEffect, nativeTechnique); + } + + internal INativeEffectTechnique NativeTechnique { get { return this.nativeTechnique; } - set - { - this.nativeTechnique = value; - } } public string Name @@ -92,7 +97,7 @@ namespace ANX.Framework.Graphics { get { - throw new NotImplementedException(); + return this.effectPassCollection; } } } diff --git a/ANX.Framework/Graphics/GraphicsDevice.cs b/ANX.Framework/Graphics/GraphicsDevice.cs index 5fdabd38..1af5e08f 100644 --- a/ANX.Framework/Graphics/GraphicsDevice.cs +++ b/ANX.Framework/Graphics/GraphicsDevice.cs @@ -103,6 +103,10 @@ namespace ANX.Framework.Graphics this.samplerStateCollection = new SamplerStateCollection(this, 8); //TODO: get maximum number of sampler states from capabilities this.textureCollection = new TextureCollection(); this.vertexTextureCollection = new TextureCollection(); + + this.BlendState = BlendState.Opaque; + this.DepthStencilState = DepthStencilState.Default; + this.RasterizerState = RasterizerState.CullCounterClockwise; } ~GraphicsDevice() @@ -138,6 +142,7 @@ namespace ANX.Framework.Graphics public void Present(Nullable sourceRectangle, Nullable destinationRectangle, IntPtr overrideWindowHandle) { + //TODO: implement throw new NotImplementedException(); } @@ -326,7 +331,13 @@ namespace ANX.Framework.Graphics public void Dispose() { - throw new NotImplementedException(); + if (this.nativeDevice != null) + { + this.nativeDevice.Dispose(); + this.nativeDevice = null; + } + + //TODO: more to dispose? } protected virtual void Dispose(Boolean disposeManaged) @@ -334,7 +345,7 @@ namespace ANX.Framework.Graphics //TODO: implement } - public INativeGraphicsDevice NativeDevice + internal INativeGraphicsDevice NativeDevice { get { @@ -342,6 +353,7 @@ namespace ANX.Framework.Graphics } } + #region Public Properties public IndexBuffer Indices { get @@ -452,31 +464,11 @@ namespace ANX.Framework.Graphics } } - public Rectangle ScissorRectangle - { - get - { - throw new NotImplementedException(); - } - set - { - throw new NotImplementedException(); - } - } - public DisplayMode DisplayMode { get { - throw new NotImplementedException(); - } - } - - public GraphicsDeviceStatus GraphicsDeviceStatus - { - get - { - throw new NotImplementedException(); + return this.currentAdapter.CurrentDisplayMode; } } @@ -565,6 +557,28 @@ namespace ANX.Framework.Graphics } } + #endregion // Public Properties + + public Rectangle ScissorRectangle + { + get + { + throw new NotImplementedException(); + } + set + { + throw new NotImplementedException(); + } + } + + public GraphicsDeviceStatus GraphicsDeviceStatus + { + get + { + throw new NotImplementedException(); + } + } + public SamplerStateCollection VertexSamplerStates { get diff --git a/ANX.Framework/GraphicsDeviceManager.cs b/ANX.Framework/GraphicsDeviceManager.cs index e9f8feee..ff536cc3 100644 --- a/ANX.Framework/GraphicsDeviceManager.cs +++ b/ANX.Framework/GraphicsDeviceManager.cs @@ -70,6 +70,9 @@ namespace ANX.Framework public static readonly int DefaultBackBufferWidth = 800; public static readonly int DefaultBackBufferHeight = 600; //TODO: this is 480 in the original XNA + private int backBufferWidth = DefaultBackBufferWidth; + private int backBufferHeight = DefaultBackBufferHeight; + public event EventHandler Disposed; public event EventHandler DeviceCreated; public event EventHandler DeviceDisposing; @@ -194,7 +197,6 @@ namespace ANX.Framework { CreateDevice(graphicsDeviceInformation); } - } public void ToggleFullScreen() @@ -302,13 +304,19 @@ namespace ANX.Framework public int PreferredBackBufferWidth { - get { throw new NotImplementedException(); } + get + { + return this.backBufferHeight; + } set { throw new NotImplementedException(); } } public int PreferredBackBufferHeight { - get { throw new NotImplementedException(); } + get + { + return this.backBufferWidth; + } set { throw new NotImplementedException(); } } diff --git a/ANX.Framework/NonXNA/RenderSystem/INativeEffectPass.cs b/ANX.Framework/NonXNA/RenderSystem/INativeEffectPass.cs new file mode 100644 index 00000000..8377b9c4 --- /dev/null +++ b/ANX.Framework/NonXNA/RenderSystem/INativeEffectPass.cs @@ -0,0 +1,61 @@ +#region Using Statements +using System; +using System.Collections.Generic; +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.NonXNA +{ + public interface INativeEffectPass + { + string Name { get; } + } +} diff --git a/ANX.Framework/NonXNA/RenderSystem/INativeEffectTechnique.cs b/ANX.Framework/NonXNA/RenderSystem/INativeEffectTechnique.cs index 42b3e0a5..20179d52 100644 --- a/ANX.Framework/NonXNA/RenderSystem/INativeEffectTechnique.cs +++ b/ANX.Framework/NonXNA/RenderSystem/INativeEffectTechnique.cs @@ -1,5 +1,7 @@ #region Using Statements using System; +using System.Collections.Generic; +using ANX.Framework.Graphics; #endregion // Using Statements @@ -55,5 +57,7 @@ namespace ANX.Framework.NonXNA public interface INativeEffectTechnique { string Name { get; } + + IEnumerable Passes { get; } } } diff --git a/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs b/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs index a333ff0a..4e202c78 100644 --- a/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs +++ b/ANX.Framework/NonXNA/RenderSystem/INativeGraphicsDevice.cs @@ -53,7 +53,7 @@ using ANX.Framework.Graphics; namespace ANX.Framework.NonXNA { - public interface INativeGraphicsDevice + public interface INativeGraphicsDevice : IDisposable { void Clear(ref Color color); void Clear(ClearOptions options, Vector4 color, float depth, int stencil); diff --git a/ANX.Framework/NonXNA/RenderSystem/IRenderSystemCreator.cs b/ANX.Framework/NonXNA/RenderSystem/IRenderSystemCreator.cs index 0156de3d..42e792fb 100644 --- a/ANX.Framework/NonXNA/RenderSystem/IRenderSystemCreator.cs +++ b/ANX.Framework/NonXNA/RenderSystem/IRenderSystemCreator.cs @@ -69,8 +69,8 @@ namespace ANX.Framework INativeBuffer CreateVertexBuffer(GraphicsDevice graphics, VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage); - INativeEffect CreateEffect(GraphicsDevice graphics, Stream byteCode); - INativeEffect CreateEffect(GraphicsDevice graphics, Stream vertexShaderByteCode, Stream pixelShaderByteCode); + INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode); + INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode); INativeBlendState CreateBlendState(); INativeRasterizerState CreateRasterizerState(); diff --git a/ANX.Framework/Properties/AssemblyInfo.cs b/ANX.Framework/Properties/AssemblyInfo.cs index b373e597..74a06c6f 100644 --- a/ANX.Framework/Properties/AssemblyInfo.cs +++ b/ANX.Framework/Properties/AssemblyInfo.cs @@ -31,11 +31,11 @@ using System.Runtime.InteropServices; // // Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern // übernehmen, indem Sie "*" eingeben: -[assembly: AssemblyVersion("0.4.23.*")] -[assembly: AssemblyFileVersion("0.4.23.0")] +[assembly: AssemblyVersion("0.4.24.*")] +[assembly: AssemblyFileVersion("0.4.24.0")] [assembly:InternalsVisibleTo("ANX.Framework.Windows.DX10")] -[assembly:InternalsVisibleTo("ANX.Framework.Windows.DX11.1")] +[assembly:InternalsVisibleTo("ANX.RenderSystem.Windows.DX11")] [assembly:InternalsVisibleTo("ANX.Framework.Windows.GL3")] [assembly:InternalsVisibleTo("ANX.Framework.Windows.Kinect")] [assembly:InternalsVisibleTo("ANX.Framework.Windows.XInput")] diff --git a/RenderSystems/ANX.Framework.Windows.DX10/ANX.Framework.Windows.DX10.csproj b/RenderSystems/ANX.Framework.Windows.DX10/ANX.Framework.Windows.DX10.csproj index a18aaa04..71de3536 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/ANX.Framework.Windows.DX10.csproj +++ b/RenderSystems/ANX.Framework.Windows.DX10/ANX.Framework.Windows.DX10.csproj @@ -71,6 +71,7 @@ + diff --git a/RenderSystems/ANX.Framework.Windows.DX10/Creator.cs b/RenderSystems/ANX.Framework.Windows.DX10/Creator.cs index 3709052d..f4858267 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/Creator.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/Creator.cs @@ -88,16 +88,16 @@ namespace ANX.Framework.Windows.DX10 return new VertexBuffer_DX10(graphics, vertexDeclaration, vertexCount, usage); } - public INativeEffect CreateEffect(GraphicsDevice graphics, Stream vertexShaderByteCode, Stream pixelShaderByteCode) + public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) { - Effect_DX10 effect = new Effect_DX10(graphics, vertexShaderByteCode, pixelShaderByteCode); + Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, vertexShaderByteCode, pixelShaderByteCode); return effect; } - public INativeEffect CreateEffect(GraphicsDevice graphics, System.IO.Stream byteCode) + public INativeEffect CreateEffect(GraphicsDevice graphics, ANX.Framework.Graphics.Effect managedEffect, System.IO.Stream byteCode) { - Effect_DX10 effect = new Effect_DX10(graphics, byteCode); + Effect_DX10 effect = new Effect_DX10(graphics, managedEffect, byteCode); return effect; } diff --git a/RenderSystems/ANX.Framework.Windows.DX10/EffectPass_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/EffectPass_DX10.cs new file mode 100644 index 00000000..56743c9d --- /dev/null +++ b/RenderSystems/ANX.Framework.Windows.DX10/EffectPass_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 EffectPass_DX10 : INativeEffectPass + { + private EffectPass nativePass; + + public EffectPass NativePass + { + get + { + return this.nativePass; + } + internal set + { + this.nativePass = value; + } + } + + public string Name + { + get + { + return nativePass.Description.Name; + } + } + } +} diff --git a/RenderSystems/ANX.Framework.Windows.DX10/EffectTechnique_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/EffectTechnique_DX10.cs index 2acf74de..6aae7fd7 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/EffectTechnique_DX10.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/EffectTechnique_DX10.cs @@ -60,6 +60,17 @@ namespace ANX.Framework.Windows.DX10 public class EffectTechnique_DX10 : INativeEffectTechnique { private EffectTechnique nativeTechnique; + private ANX.Framework.Graphics.Effect parentEffect; + + internal EffectTechnique_DX10(ANX.Framework.Graphics.Effect parentEffect) + { + if (parentEffect == null) + { + throw new ArgumentNullException("parentEffect"); + } + + this.parentEffect = parentEffect; + } public EffectTechnique NativeTechnique { @@ -80,5 +91,22 @@ namespace ANX.Framework.Windows.DX10 return nativeTechnique.Description.Name; } } + + + public IEnumerable Passes + { + get + { + for (int i = 0; i < nativeTechnique.Description.PassCount; i++) + { + EffectPass_DX10 passDx10 = new EffectPass_DX10(); + passDx10.NativePass = nativeTechnique.GetPassByIndex(i); + + Graphics.EffectPass pass = new Graphics.EffectPass(this.parentEffect); + + yield return pass; + } + } + } } } diff --git a/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs index e1b2f77f..55819ba7 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/Effect_DX10.cs @@ -66,12 +66,18 @@ namespace ANX.Framework.Windows.DX10 private ShaderBytecode vertexShaderByteCode; private VertexShader vertexShader; private PixelShader pixelShader; - + private ANX.Framework.Graphics.Effect managedEffect; private ShaderBytecode effectByteCode; private SharpDX.Direct3D10.Effect nativeEffect; - public Effect_DX10(GraphicsDevice device, Stream vertexShaderByteCode, Stream pixelShaderByteCode) + public Effect_DX10(GraphicsDevice device, ANX.Framework.Graphics.Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) { + if (this.managedEffect == null) + { + throw new ArgumentNullException("managedEffect"); + } + this.managedEffect = managedEffect; + if (vertexShaderByteCode.CanSeek) { vertexShaderByteCode.Seek(0, SeekOrigin.Begin); @@ -87,8 +93,14 @@ namespace ANX.Framework.Windows.DX10 this.pixelShader = new PixelShader((SharpDX.Direct3D10.Device)device.NativeDevice, this.pixelShaderByteCode); } - public Effect_DX10(GraphicsDevice device, Stream effectByteCode) + public Effect_DX10(GraphicsDevice device, ANX.Framework.Graphics.Effect managedEffect, Stream effectByteCode) { + if (managedEffect == null) + { + throw new ArgumentNullException("managedEffect"); + } + this.managedEffect = managedEffect; + if (effectByteCode.CanSeek) { effectByteCode.Seek(0, SeekOrigin.Begin); @@ -213,11 +225,10 @@ namespace ANX.Framework.Windows.DX10 { for (int i = 0; i < nativeEffect.Description.TechniqueCount; i++) { - EffectTechnique_DX10 teqDx10 = new EffectTechnique_DX10(); + EffectTechnique_DX10 teqDx10 = new EffectTechnique_DX10(this.managedEffect); teqDx10.NativeTechnique = nativeEffect.GetTechniqueByIndex(i); - Graphics.EffectTechnique teq = new Graphics.EffectTechnique(); - teq.NativeTechnique = teqDx10; + Graphics.EffectTechnique teq = new Graphics.EffectTechnique(this.managedEffect, teqDx10); yield return teq; } diff --git a/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs index 289d434e..3e0a62d6 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs @@ -477,5 +477,10 @@ namespace ANX.Framework.Windows.DX10 this.vSyncEnabled = value; } } + + public void Dispose() + { + //TODO: implement + } } } diff --git a/RenderSystems/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs b/RenderSystems/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs index 74e3d100..d7cfe99b 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/Properties/AssemblyInfo.cs @@ -32,7 +32,7 @@ using System.Runtime.InteropServices; // 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: AssemblyVersion("0.7.5.0")] +[assembly: AssemblyFileVersion("0.7.5.0")] [assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")] diff --git a/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs b/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs index f2a88183..edc3f292 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/Creator.cs @@ -90,15 +90,15 @@ namespace ANX.Framework.Windows.GL3 #endregion #region CreateEffect - public INativeEffect CreateEffect(GraphicsDevice graphics, Stream byteCode) + public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream byteCode) { - return new EffectGL3(byteCode); + return new EffectGL3(managedEffect, byteCode); } - public INativeEffect CreateEffect(GraphicsDevice graphics, + public INativeEffect CreateEffect(GraphicsDevice graphics, Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) { - return new EffectGL3(vertexShaderByteCode, pixelShaderByteCode); + return new EffectGL3(managedEffect, vertexShaderByteCode, pixelShaderByteCode); } #endregion diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs index c88c684e..b6b5cd30 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs @@ -72,6 +72,8 @@ namespace ANX.Framework.Windows.GL3 /// The native shader handle. /// internal int programHandle; + + private Effect managedEffect; #endregion #region Public @@ -83,12 +85,9 @@ namespace ANX.Framework.Windows.GL3 List techniques = new List(); // TODO: dummy, fill with actual data. - techniques.Add(new EffectTechnique() - { - NativeTechnique = new EffectTechniqueGL3(), - }); + techniques.Add(new EffectTechnique(this.managedEffect, new EffectTechniqueGL3())); - return techniques; + return techniques; } } #endregion @@ -137,19 +136,19 @@ namespace ANX.Framework.Windows.GL3 /// /// The vertex shader code. /// The fragment shader code. - public EffectGL3(Stream vertexShaderByteCode, - Stream pixelShaderByteCode) + public EffectGL3(Effect managedEffect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) { - CreateShader(LoadShaderCode(vertexShaderByteCode), - LoadShaderCode(pixelShaderByteCode)); + this.managedEffect = managedEffect; + CreateShader(LoadShaderCode(vertexShaderByteCode), LoadShaderCode(pixelShaderByteCode)); } /// /// Create a new effect instance of one streams. /// /// The byte code of the shader. - public EffectGL3(Stream byteCode) + public EffectGL3(Effect managedEffect, Stream byteCode) { + this.managedEffect = managedEffect; string source = LoadShaderCode(byteCode); string[] parts = source.Split(new string[] { FragmentSeparator }, StringSplitOptions.RemoveEmptyEntries); diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs index 12fd7d10..5875ed9e 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs @@ -74,5 +74,15 @@ namespace ANX.Framework.Windows.GL3 { } #endregion - } + + + public System.Collections.Generic.IEnumerable Passes + { + get + { + //TODO: implement + yield return null; + } + } + } } diff --git a/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs index 7572ee4a..39a914fd 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs @@ -406,5 +406,10 @@ namespace ANX.Framework.Windows.GL3 { throw new NotImplementedException(); } - } + + public void Dispose() + { + //TODO: implement + } + } } diff --git a/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs b/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs index f8286661..6a636f5a 100644 --- a/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs +++ b/RenderSystems/ANX.Framework.Windows.GL3/Properties/AssemblyInfo.cs @@ -32,7 +32,7 @@ using System.Runtime.InteropServices; // 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: AssemblyVersion("0.5.2.0")] +[assembly: AssemblyFileVersion("0.5.2.0")] [assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")] diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj b/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj index a99596a6..e5806fe5 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/ANX.RenderSystem.Windows.DX11.csproj @@ -8,8 +8,8 @@ {B30DE9C2-0926-46B6-8351-9AF276C472D5} Library Properties - ANX.RenderSystem.Windows.DX11._1 - ANX.RenderSystem.Windows.DX11.1 + ANX.RenderSystem.Windows.DX11 + ANX.RenderSystem.Windows.DX11 v4.0 Client 512 diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs index bb94b2e6..7992f203 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/Creator.cs @@ -96,13 +96,13 @@ namespace ANX.RenderSystem.Windows.DX11 return new VertexBuffer_DX11(graphics, vertexDeclaration, vertexCount, usage); } - public INativeEffect CreateEffect(GraphicsDevice graphics, Stream vertexShaderByteCode, Stream pixelShaderByteCode) + public INativeEffect CreateEffect(GraphicsDevice graphics, Effect effect, Stream vertexShaderByteCode, Stream pixelShaderByteCode) { throw new NotImplementedException(); //return new Effect_DX11(graphics, vertexShaderByteCode, pixelShaderByteCode); } - public INativeEffect CreateEffect(GraphicsDevice graphics, System.IO.Stream byteCode) + public INativeEffect CreateEffect(GraphicsDevice graphics, Effect effect, System.IO.Stream byteCode) { throw new NotImplementedException(); //return new Effect_DX11(graphics, byteCode); diff --git a/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs b/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs index 3b2ba8bf..03860877 100644 --- a/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs +++ b/RenderSystems/ANX.RenderSystem.Windows.DX11/GraphicsDeviceWindowsDX11.cs @@ -648,5 +648,10 @@ namespace ANX.RenderSystem.Windows.DX11 throw new NotImplementedException(); } } + + public void Dispose() + { + //TODO: implement } + } } diff --git a/Samples/VertexIndexBuffer/Game1.cs b/Samples/VertexIndexBuffer/Game1.cs index d05cf6f5..ef667e8d 100644 --- a/Samples/VertexIndexBuffer/Game1.cs +++ b/Samples/VertexIndexBuffer/Game1.cs @@ -121,7 +121,8 @@ namespace VertexIndexBuffer { GraphicsDevice.Clear(Color.CornflowerBlue); - miniTriEffect.NativeEffect.Apply(GraphicsDevice); //TODO: this is not the right way to do that + miniTriEffect.CurrentTechnique.Passes[0].Apply(); + GraphicsDevice.SetVertexBuffer(vb); GraphicsDevice.DrawPrimitives(PrimitiveType.TriangleList, 0, 6); diff --git a/build/ANX.Framework.build b/build/ANX.Framework.build index a2859ded..00a21044 100644 --- a/build/ANX.Framework.build +++ b/build/ANX.Framework.build @@ -263,6 +263,11 @@ + + + + + @@ -278,7 +283,7 @@ - +