diff --git a/ANX.Framework/Graphics/BasicEffect.cs b/ANX.Framework/Graphics/BasicEffect.cs index 78559194..958ebba1 100644 --- a/ANX.Framework/Graphics/BasicEffect.cs +++ b/ANX.Framework/Graphics/BasicEffect.cs @@ -60,10 +60,18 @@ namespace ANX.Framework.Graphics { public class BasicEffect : Effect, IEffectMatrices, IEffectLights, IEffectFog { + private bool vertexColorEnabled; + + private EffectParameter world; + private EffectParameter view; + private EffectParameter projection; + public BasicEffect(GraphicsDevice graphics) : base(graphics, AddInSystemFactory.Instance.GetDefaultCreator().GetShaderByteCode(NonXNA.PreDefinedShader.BasicEffect)) { - throw new NotImplementedException(); + world = base.Parameters["World"]; + view = base.Parameters["View"]; + projection = base.Parameters["Projection"]; } protected BasicEffect(BasicEffect cloneSource) @@ -88,11 +96,11 @@ namespace ANX.Framework.Graphics { get { - throw new NotImplementedException(); + return this.projection.GetValueMatrix(); } set { - throw new NotImplementedException(); + this.projection.SetValue(value); } } @@ -100,11 +108,11 @@ namespace ANX.Framework.Graphics { get { - throw new NotImplementedException(); + return this.view.GetValueMatrix(); } set { - throw new NotImplementedException(); + this.view.SetValue(value); } } @@ -112,11 +120,11 @@ namespace ANX.Framework.Graphics { get { - throw new NotImplementedException(); + return this.world.GetValueMatrix(); } set { - throw new NotImplementedException(); + this.world.SetValue(value); } } @@ -300,11 +308,12 @@ namespace ANX.Framework.Graphics { get { - throw new NotImplementedException(); + return this.vertexColorEnabled; } set { - throw new NotImplementedException(); + this.vertexColorEnabled = value; + SetTechnique(); } } @@ -312,5 +321,18 @@ namespace ANX.Framework.Graphics { return new BasicEffect(this); } + + private void SetTechnique() + { + //TODO: implement completly + + if (vertexColorEnabled) + { + this.CurrentTechnique = Techniques["VertexColor"]; + return; + } + + throw new InvalidOperationException("Currently ANX's BasicEffect only supports VertexColor technique"); + } } } diff --git a/ANX.Framework/Graphics/EffectTechniqueCollection.cs b/ANX.Framework/Graphics/EffectTechniqueCollection.cs index 271fae3d..ed4a9d2d 100644 --- a/ANX.Framework/Graphics/EffectTechniqueCollection.cs +++ b/ANX.Framework/Graphics/EffectTechniqueCollection.cs @@ -95,24 +95,32 @@ namespace ANX.Framework.Graphics { get { - throw new NotImplementedException(); + foreach (EffectTechnique teq in techniques) + { + if (teq.Name.Equals(name)) + { + return teq; + } + } + + throw new ArgumentException("No technique with name '" + name + "' found."); } - } + } - 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 { diff --git a/ANX.Framework/Graphics/GraphicsDevice.cs b/ANX.Framework/Graphics/GraphicsDevice.cs index c54826a8..85030956 100644 --- a/ANX.Framework/Graphics/GraphicsDevice.cs +++ b/ANX.Framework/Graphics/GraphicsDevice.cs @@ -244,7 +244,7 @@ namespace ANX.Framework.Graphics this.nativeDevice.SetVertexBuffers(bindings); } - public void SetVertexBuffers(Graphics.VertexBufferBinding[] vertexBuffers) + public void SetVertexBuffers(params Graphics.VertexBufferBinding[] vertexBuffers) { this.currentVertexBufferBindings = vertexBuffers; nativeDevice.SetVertexBuffers(vertexBuffers); @@ -397,7 +397,7 @@ namespace ANX.Framework.Graphics } set { - this.Viewport = value; + this.viewport = value; } } diff --git a/ANX.Framework/Graphics/VertexDeclaration.cs b/ANX.Framework/Graphics/VertexDeclaration.cs index f8ff2d17..4534a1eb 100644 --- a/ANX.Framework/Graphics/VertexDeclaration.cs +++ b/ANX.Framework/Graphics/VertexDeclaration.cs @@ -57,14 +57,18 @@ namespace ANX.Framework.Graphics private int vertexStride; private VertexElement[] elements; - public VertexDeclaration(VertexElement[] elements) + public VertexDeclaration(params VertexElement[] elements) { this.elements = elements; - throw new NotImplementedException("calculation of VertexStride not implemented"); + + for (int i = 0; i < this.elements.Length; i++) + { + this.vertexStride += GetElementStride(this.elements[i].VertexElementFormat); + } } - public VertexDeclaration(int vertexStride, VertexElement[] elements) + public VertexDeclaration(int vertexStride, params VertexElement[] elements) { this.elements = elements; this.vertexStride = vertexStride; @@ -99,6 +103,30 @@ namespace ANX.Framework.Graphics { throw new NotImplementedException(); } - + + private int GetElementStride(VertexElementFormat format) + { + switch (format) + { + case VertexElementFormat.NormalizedShort2: + case VertexElementFormat.Byte4: + case VertexElementFormat.Color: + case VertexElementFormat.HalfVector2: + case VertexElementFormat.Short2: + case VertexElementFormat.Single: + return 4; + case VertexElementFormat.HalfVector4: + case VertexElementFormat.NormalizedShort4: + case VertexElementFormat.Short4: + case VertexElementFormat.Vector2: + return 8; + case VertexElementFormat.Vector3: + return 12; + case VertexElementFormat.Vector4: + return 16; + default: + throw new ArgumentException("unknown VertexElementFormat size '" + format.ToString() + "'"); + } + } } } diff --git a/ANX.Framework/Properties/AssemblyInfo.cs b/ANX.Framework/Properties/AssemblyInfo.cs index 74e3885a..9f6f8c67 100644 --- a/ANX.Framework/Properties/AssemblyInfo.cs +++ b/ANX.Framework/Properties/AssemblyInfo.cs @@ -31,8 +31,8 @@ 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.37.*")] -[assembly: AssemblyFileVersion("0.4.37.0")] +[assembly: AssemblyVersion("0.4.38.*")] +[assembly: AssemblyFileVersion("0.4.38.0")] [assembly:InternalsVisibleTo("ANX.Framework.Windows.DX10")] [assembly:InternalsVisibleTo("ANX.RenderSystem.Windows.DX11")] diff --git a/RenderSystems/ANX.Framework.Windows.DX10/ShaderByteCode.cs b/RenderSystems/ANX.Framework.Windows.DX10/ShaderByteCode.cs index db0e54a2..bea0ee39 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/ShaderByteCode.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/ShaderByteCode.cs @@ -279,111 +279,112 @@ namespace ANX.Framework.Windows.DX10 internal static byte[] BasicEffectByteCode = new byte[] { 068, - 088, 066, 067, 126, 162, 104, 105, 242, 144, 056, 167, 070, 154, 085, 120, 072, 154, 242, 236, 001, - 000, 000, 000, 036, 008, 000, 000, 001, 000, 000, 000, 036, 000, 000, 000, 070, 088, 049, 048, 248, - 007, 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, 004, 007, 000, 000, 000, - 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 001, + 088, 066, 067, 087, 234, 165, 246, 132, 191, 055, 252, 102, 233, 185, 175, 016, 173, 200, 052, 001, + 000, 000, 000, 068, 008, 000, 000, 001, 000, 000, 000, 036, 000, 000, 000, 070, 088, 049, 048, 024, + 008, 000, 000, 001, 016, 255, 254, 001, 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, 024, 007, 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, 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, 065, 108, 112, 104, 097, 084, 101, 115, 116, 000, 065, 108, 112, - 104, 097, 084, 101, 115, 116, 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, + 000, 064, 000, 000, 000, 011, 100, 000, 000, 087, 111, 114, 108, 100, 000, 086, 105, 101, 119, 000, + 080, 114, 111, 106, 101, 099, 116, 105, 111, 110, 000, 086, 101, 114, 116, 101, 120, 067, 111, 108, + 111, 114, 000, 086, 101, 114, 116, 101, 120, 067, 111, 108, 111, 114, 080, 097, 115, 115, 000, 001, + 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 160, 004, 000, 000, 068, 088, 066, 067, 157, + 019, 102, 008, 252, 045, 161, 241, 230, 057, 246, 156, 028, 156, 219, 001, 001, 000, 000, 000, 160, + 004, 000, 000, 005, 000, 000, 000, 052, 000, 000, 000, 064, 001, 000, 000, 144, 001, 000, 000, 004, + 002, 000, 000, 036, 004, 000, 000, 082, 068, 069, 070, 004, 001, 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, 208, + 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, 003, 000, 000, 000, 096, 000, 000, 000, 192, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 168, 000, 000, 000, 000, 000, 000, 000, 064, + 000, 000, 000, 002, 000, 000, 000, 176, 000, 000, 000, 000, 000, 000, 000, 192, 000, 000, 000, 064, + 000, 000, 000, 064, 000, 000, 000, 002, 000, 000, 000, 176, 000, 000, 000, 000, 000, 000, 000, 197, + 000, 000, 000, 128, 000, 000, 000, 064, 000, 000, 000, 002, 000, 000, 000, 176, 000, 000, 000, 000, + 000, 000, 000, 087, 111, 114, 108, 100, 000, 171, 171, 003, 000, 003, 000, 004, 000, 004, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 086, 105, 101, 119, 000, 080, 114, 111, 106, 101, 099, 116, 105, + 111, 110, 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, 072, + 000, 000, 000, 002, 000, 000, 000, 008, 000, 000, 000, 056, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 015, 015, 000, 000, 065, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 003, 000, 000, 000, 001, 000, 000, 000, 015, 015, 000, 000, 080, + 079, 083, 073, 084, 073, 079, 078, 000, 067, 079, 076, 079, 082, 000, 171, 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, 024, 002, 000, 000, 064, + 000, 001, 000, 134, 000, 000, 000, 089, 000, 000, 004, 070, 142, 032, 000, 000, 000, 000, 000, 012, + 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, 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, 104, 000, 000, 002, 002, 000, 000, 000, 017, 000, 000, 008, 018, + 000, 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, 000, 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, 000, 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, 000, 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, 017, 000, 000, 008, 018, 000, 016, 000, 001, 000, 000, 000, 070, 014, 016, 000, 000, + 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 004, 000, 000, 000, 017, 000, 000, 008, 034, + 000, 016, 000, 001, 000, 000, 000, 070, 014, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, + 000, 000, 000, 005, 000, 000, 000, 017, 000, 000, 008, 066, 000, 016, 000, 001, 000, 000, 000, 070, + 014, 016, 000, 000, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 006, 000, 000, 000, 017, + 000, 000, 008, 130, 000, 016, 000, 001, 000, 000, 000, 070, 014, 016, 000, 000, 000, 000, 000, 070, + 142, 032, 000, 000, 000, 000, 000, 007, 000, 000, 000, 017, 000, 000, 008, 018, 032, 016, 000, 000, + 000, 000, 000, 070, 014, 016, 000, 001, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 008, + 000, 000, 000, 017, 000, 000, 008, 034, 032, 016, 000, 000, 000, 000, 000, 070, 014, 016, 000, 001, + 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 009, 000, 000, 000, 017, 000, 000, 008, 066, + 032, 016, 000, 000, 000, 000, 000, 070, 014, 016, 000, 001, 000, 000, 000, 070, 142, 032, 000, 000, + 000, 000, 000, 010, 000, 000, 000, 017, 000, 000, 008, 130, 032, 016, 000, 000, 000, 000, 000, 070, + 014, 016, 000, 001, 000, 000, 000, 070, 142, 032, 000, 000, 000, 000, 000, 011, 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, 008, 050, 032, 016, 000, 002, 000, 000, 000, 002, 064, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 062, 000, 000, 001, 083, 084, 065, 084, 116, + 000, 000, 000, 015, 000, 000, 000, 002, 000, 000, 000, 000, 000, 000, 000, 005, 000, 000, 000, 012, + 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, 112, + 000, 000, 000, 000, 000, 000, 000, 240, 001, 000, 000, 068, 088, 066, 067, 233, 091, 059, 059, 103, + 223, 159, 063, 038, 069, 104, 124, 232, 218, 083, 009, 001, 000, 000, 000, 240, 001, 000, 000, 005, + 000, 000, 000, 052, 000, 000, 000, 140, 000, 000, 000, 000, 001, 000, 000, 052, 001, 000, 000, 116, + 001, 000, 000, 082, 068, 069, 070, 080, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 028, 000, 000, 000, 000, 004, 255, 255, 000, 001, 000, 000, 028, 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, + 053, 050, 046, 051, 049, 049, 049, 000, 171, 171, 171, 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, 000, 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, 056, 000, 000, 000, 064, 000, 000, 000, 014, 000, 000, 000, 098, 016, 000, 003, 242, + 016, 016, 000, 001, 000, 000, 000, 101, 000, 000, 003, 242, 032, 016, 000, 000, 000, 000, 000, 054, + 000, 000, 005, 242, 032, 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, 002, 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, 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, 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, 204, 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, 088, 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, 000, 000, 000, 000, 028, 005, 000, 000, 000, 000, 000, 000, 004, 000, 000, 000, 192, + 000, 000, 000, 000, 000, 000, 000, 003, 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, 178, 000, 000, 000, 003, 000, 000, 000, 000, 000, 000, 000, 008, 000, 000, 000, 000, - 000, 000, 000, 001, 000, 000, 000, 192, 000, 000, 000, 006, 000, 000, 000, 000, 000, 000, 000, 007, - 000, 000, 000, 080, 004, 000, 000, 007, 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 252, - 006, 000, 000 + 000, 000, 000, 000, 000, 000, 000, 056, 000, 000, 000, 022, 000, 000, 000, 000, 000, 000, 000, 064, + 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 061, 000, 000, 000, 022, + 000, 000, 000, 000, 000, 000, 000, 128, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, 000, + 000, 000, 000, 072, 000, 000, 000, 001, 000, 000, 000, 000, 000, 000, 000, 084, 000, 000, 000, 003, + 000, 000, 000, 000, 000, 000, 000, 008, 000, 000, 000, 000, 000, 000, 000, 001, 000, 000, 000, 100, + 000, 000, 000, 006, 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 020, 005, 000, 000, 007, + 000, 000, 000, 000, 000, 000, 000, 007, 000, 000, 000, 016, 007, 000, 000 }; #endregion //BasicEffectShader diff --git a/Samples/Primitives/Game1.cs b/Samples/Primitives/Game1.cs index e71a3a11..f4436ef6 100644 --- a/Samples/Primitives/Game1.cs +++ b/Samples/Primitives/Game1.cs @@ -2,19 +2,18 @@ using System; using System.Collections.Generic; using System.Linq; -using Microsoft.Xna.Framework; -using Microsoft.Xna.Framework.Audio; -using Microsoft.Xna.Framework.Content; -using Microsoft.Xna.Framework.GamerServices; -using Microsoft.Xna.Framework.Graphics; -using Microsoft.Xna.Framework.Input; -using Microsoft.Xna.Framework.Media; +using ANX.Framework; +using ANX.Framework.Content; +using ANX.Framework.GamerServices; +using ANX.Framework.Graphics; +using ANX.Framework.Input; +using ANX.Framework.Media; #endregion // Using Statements namespace Primitives { - public class Game1 : Microsoft.Xna.Framework.Game + public class Game1 : ANX.Framework.Game { GraphicsDeviceManager graphics; SpriteBatch spriteBatch; @@ -26,6 +25,7 @@ namespace Primitives Effect hardwareInstanceEffect; Matrix viewMatrix; + Matrix instancedViewMatrix; Matrix projectionMatrix; Matrix instancedProjectionMatrix; Matrix worldMatrix; @@ -167,6 +167,7 @@ namespace Primitives this.projectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 300f/200f, 0.1f, 50.0f); this.instancedProjectionMatrix = Matrix.CreatePerspectiveFieldOfView(MathHelper.PiOver4, 600f / 200f, 0.1f, 50.0f); this.viewMatrix = Matrix.CreateLookAt(new Vector3(5, 5, 5), new Vector3(0, 0, 0), Vector3.Up); + this.instancedViewMatrix = Matrix.CreateLookAt(new Vector3(0.0f, 5.0f, 10.0f), new Vector3(0, 0, 0), Vector3.Up); this.font = Content.Load(@"Fonts/Debug"); @@ -277,7 +278,7 @@ namespace Primitives #region DrawInstancedPrimitives GraphicsDevice.Viewport = new Viewport(0, 0, 600, 200); - this.hardwareInstanceEffect.Parameters["View"].SetValue(Matrix.CreateLookAt(new Vector3(0.0f, 5.0f, -10.0f), Vector3.Zero, Vector3.Up)); + this.hardwareInstanceEffect.Parameters["View"].SetValue(this.instancedViewMatrix); this.hardwareInstanceEffect.Parameters["Projection"].SetValue(this.instancedProjectionMatrix); this.hardwareInstanceEffect.Parameters["World"].SetValue(this.worldMatrix); this.hardwareInstanceEffect.CurrentTechnique.Passes[0].Apply(); diff --git a/Samples/Primitives/Primitives.csproj b/Samples/Primitives/Primitives.csproj index eb7197a2..20ff2ba0 100644 --- a/Samples/Primitives/Primitives.csproj +++ b/Samples/Primitives/Primitives.csproj @@ -60,10 +60,6 @@ true - - - - @@ -83,6 +79,26 @@ + + {6899F0C9-70B9-4EB0-9DD3-E598D4BE3E35} + ANX.Framework + + + {60D08399-244F-46A3-91F1-4CFD26D961A3} + ANX.InputDevices.Windows.XInput + + + {49066074-3B7B-4A55-B122-6BD33AB73558} + ANX.InputSystem.Standard + + + {5BE49183-2F6F-4527-AC90-D816911FCF90} + ANX.Framework.Windows.DX10 + + + {6A582788-C4D2-410C-96CD-177F75712D65} + ANX.SoundSystem.Windows.XAudio + {FA6E229D-4504-47B1-8A23-2D3FCC13F778} SampleContent diff --git a/Samples/SampleContent/Effects/HardwareInstancing.fx b/Samples/SampleContent/Effects/HardwareInstancing.fx index f1f0bbf5..f6162ad2 100644 --- a/Samples/SampleContent/Effects/HardwareInstancing.fx +++ b/Samples/SampleContent/Effects/HardwareInstancing.fx @@ -33,7 +33,6 @@ float4 PixelShaderFunction(VertexShaderOutput input) : SV_Target return input.Color; } -/* technique10 HardwareInstancing { pass Pass1 @@ -42,8 +41,8 @@ technique10 HardwareInstancing PixelShader = compile ps_4_0 PixelShaderFunction(); } } -*/ +/* technique HardwareInstancing { pass Pass1 @@ -51,4 +50,5 @@ technique HardwareInstancing VertexShader = compile vs_2_0 HardwareInstancingVertexShader(); PixelShader = compile ps_2_0 PixelShaderFunction(); } -} \ No newline at end of file +} +*/ \ No newline at end of file diff --git a/Samples/SampleContent/SampleContent.contentproj b/Samples/SampleContent/SampleContent.contentproj index c5464156..e9bf8556 100644 --- a/Samples/SampleContent/SampleContent.contentproj +++ b/Samples/SampleContent/SampleContent.contentproj @@ -100,7 +100,8 @@ HardwareInstancing EffectImporter - EffectProcessor + AnxEffectProcessor + DX10_HLSL diff --git a/shader/DX10/BasicEffect.fx b/shader/DX10/BasicEffect.fx index f039a391..ac5c8338 100644 --- a/shader/DX10/BasicEffect.fx +++ b/shader/DX10/BasicEffect.fx @@ -43,47 +43,53 @@ //TODO: dummy implementation / placeholder -uniform extern float4x4 MatrixTransform; +uniform extern float4x4 World; +uniform extern float4x4 View; +uniform extern float4x4 Projection; +/* Texture2D Texture : register(t0); sampler TextureSampler : register(s0); +*/ -struct VertexShaderInput +struct VertexColorVertexShaderInput { - float4 pos : POSITION; - float4 col : COLOR; - float2 tex : TEXCOORD0; + float4 Position : POSITION; + float4 Color : COLOR; }; struct PixelShaderInput { - float4 pos : SV_POSITION; - float4 col : COLOR; - float2 tex : TEXCOORD0; + float4 Position : SV_POSITION; + float4 Color : COLOR; + float2 TexCoord0 : TEXCOORD0; }; -PixelShaderInput AlphaTestVertexShader( VertexShaderInput input ) +PixelShaderInput VertexColorVertexShader( VertexColorVertexShaderInput input ) { PixelShaderInput output = (PixelShaderInput)0; - output.pos = mul(input.pos, MatrixTransform); - output.col = input.col; - output.tex = input.tex; + float4 worldPosition = mul(input.Position, World); + float4 viewPosition = mul(worldPosition, View); + output.Position = mul(viewPosition, Projection); + + output.Color = input.Color; + output.TexCoord0 = (float2)0; return output; } -float4 AlphaTestPixelShader( PixelShaderInput input ) : SV_Target +float4 VertexColorPixelShader( PixelShaderInput input ) : SV_Target { - return Texture.Sample(TextureSampler, input.tex) * input.col; + return input.Color; } -technique10 AlphaTest +technique10 VertexColor { - pass AlphaTestPass + pass VertexColorPass { SetGeometryShader( 0 ); - SetVertexShader( CompileShader( vs_4_0, AlphaTestVertexShader() ) ); - SetPixelShader( CompileShader( ps_4_0, AlphaTestPixelShader() ) ); + SetVertexShader( CompileShader( vs_4_0, VertexColorVertexShader() ) ); + SetPixelShader( CompileShader( ps_4_0, VertexColorPixelShader() ) ); } } diff --git a/shader/DX11/BasicEffect.fx b/shader/DX11/BasicEffect.fx index f039a391..ac5c8338 100644 --- a/shader/DX11/BasicEffect.fx +++ b/shader/DX11/BasicEffect.fx @@ -43,47 +43,53 @@ //TODO: dummy implementation / placeholder -uniform extern float4x4 MatrixTransform; +uniform extern float4x4 World; +uniform extern float4x4 View; +uniform extern float4x4 Projection; +/* Texture2D Texture : register(t0); sampler TextureSampler : register(s0); +*/ -struct VertexShaderInput +struct VertexColorVertexShaderInput { - float4 pos : POSITION; - float4 col : COLOR; - float2 tex : TEXCOORD0; + float4 Position : POSITION; + float4 Color : COLOR; }; struct PixelShaderInput { - float4 pos : SV_POSITION; - float4 col : COLOR; - float2 tex : TEXCOORD0; + float4 Position : SV_POSITION; + float4 Color : COLOR; + float2 TexCoord0 : TEXCOORD0; }; -PixelShaderInput AlphaTestVertexShader( VertexShaderInput input ) +PixelShaderInput VertexColorVertexShader( VertexColorVertexShaderInput input ) { PixelShaderInput output = (PixelShaderInput)0; - output.pos = mul(input.pos, MatrixTransform); - output.col = input.col; - output.tex = input.tex; + float4 worldPosition = mul(input.Position, World); + float4 viewPosition = mul(worldPosition, View); + output.Position = mul(viewPosition, Projection); + + output.Color = input.Color; + output.TexCoord0 = (float2)0; return output; } -float4 AlphaTestPixelShader( PixelShaderInput input ) : SV_Target +float4 VertexColorPixelShader( PixelShaderInput input ) : SV_Target { - return Texture.Sample(TextureSampler, input.tex) * input.col; + return input.Color; } -technique10 AlphaTest +technique10 VertexColor { - pass AlphaTestPass + pass VertexColorPass { SetGeometryShader( 0 ); - SetVertexShader( CompileShader( vs_4_0, AlphaTestVertexShader() ) ); - SetPixelShader( CompileShader( ps_4_0, AlphaTestPixelShader() ) ); + SetVertexShader( CompileShader( vs_4_0, VertexColorVertexShader() ) ); + SetPixelShader( CompileShader( ps_4_0, VertexColorPixelShader() ) ); } }