diff --git a/ANX.Framework.sln b/ANX.Framework.sln index fada5579..74f11d9a 100644 --- a/ANX.Framework.sln +++ b/ANX.Framework.sln @@ -105,6 +105,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "RenderTarget", "Samples\Ren EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "StencilBuffer", "Samples\StencilBuffer\StencilBuffer.csproj", "{41E6C2CF-51EA-4D8E-96AE-739CA3951766}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Primitives", "Samples\Primitives\Primitives.csproj", "{57097B7A-A283-4409-8AAC-35BF0F458657}" +EndProject Global GlobalSection(SubversionScc) = preSolution Svn-Managed = True @@ -337,6 +339,16 @@ Global {41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|Mixed Platforms.Build.0 = Release|x86 {41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|x86.ActiveCfg = Release|x86 {41E6C2CF-51EA-4D8E-96AE-739CA3951766}.Release|x86.Build.0 = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Any CPU.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|Mixed Platforms.Build.0 = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|x86.ActiveCfg = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Debug|x86.Build.0 = Debug|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Any CPU.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Mixed Platforms.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|Mixed Platforms.Build.0 = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|x86.ActiveCfg = Release|x86 + {57097B7A-A283-4409-8AAC-35BF0F458657}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -358,6 +370,7 @@ Global {05233BB1-444F-43F6-A3DF-B82AA924E094} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9} {71378D2F-0DCD-4413-8DE0-3FEC0BA04E27} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9} {41E6C2CF-51EA-4D8E-96AE-739CA3951766} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9} + {57097B7A-A283-4409-8AAC-35BF0F458657} = {9B0DD48B-3912-4F33-AF3F-691AF02B73F9} {E5D69E75-D77C-493F-BBDA-6F9E73B82549} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64} {60D08399-244F-46A3-91F1-4CFD26D961A3} = {7AD65E6B-2A48-437F-81D9-4CA9C9A85C64} {6A582788-C4D2-410C-96CD-177F75712D65} = {5725DA44-4F5C-4E93-A957-AC5C85603EE9} diff --git a/ANX.Framework/Graphics/GraphicsDevice.cs b/ANX.Framework/Graphics/GraphicsDevice.cs index b015ffd8..fb7f43ce 100644 --- a/ANX.Framework/Graphics/GraphicsDevice.cs +++ b/ANX.Framework/Graphics/GraphicsDevice.cs @@ -115,23 +115,6 @@ namespace ANX.Framework.Graphics #endregion // Constructor & Destructor - internal void Recreate(PresentationParameters presentationParameters) - { - if (nativeDevice != null) - { - nativeDevice.Dispose(); - nativeDevice = null; - } - - if (nativeDevice == null) - { - this.currentPresentationParameters = presentationParameters; - nativeDevice = AddInSystemFactory.Instance.GetDefaultCreator().CreateGraphicsDevice(presentationParameters); - this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight); - } - - } - #region Clear public void Clear(Color color) { @@ -368,14 +351,6 @@ namespace ANX.Framework.Graphics //TODO: implement } - internal INativeGraphicsDevice NativeDevice - { - get - { - return this.nativeDevice; - } - } - #region Public Properties public IndexBuffer Indices { @@ -610,6 +585,31 @@ namespace ANX.Framework.Graphics } } + internal INativeGraphicsDevice NativeDevice + { + get + { + return this.nativeDevice; + } + } + + internal void Recreate(PresentationParameters presentationParameters) + { + if (nativeDevice != null) + { + nativeDevice.Dispose(); + nativeDevice = null; + } + + if (nativeDevice == null) + { + this.currentPresentationParameters = presentationParameters; + nativeDevice = AddInSystemFactory.Instance.GetDefaultCreator().CreateGraphicsDevice(presentationParameters); + this.viewport = new Viewport(0, 0, presentationParameters.BackBufferWidth, presentationParameters.BackBufferHeight); + } + + } + protected void raise_Disposing(object sender, EventArgs args) { if (Disposing != null) diff --git a/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs index 2e99f7d2..613f72cb 100644 --- a/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs +++ b/RenderSystems/ANX.Framework.Windows.DX10/GraphicsDeviceWindowsDX10.cs @@ -230,11 +230,80 @@ namespace ANX.Framework.Windows.DX10 #endregion - public void Present() + #region Present + public void Present() { swapChain.Present(this.vSyncEnabled ? 1 : 0, PresentFlags.None); } + #endregion // Present + + #region DrawPrimitives & DrawIndexedPrimitives + 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.depthStencilView, 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.depthStencilView, this.renderView); + + for (int i = 0; i < technique.Description.PassCount; ++i) + { + pass.Apply(); + device.Draw(primitiveCount, vertexOffset); + } + } + + #endregion // DrawPrimitives & DrawIndexedPrimitives + + #region DrawInstancedPrimitives + public void DrawInstancedPrimitives(PrimitiveType primitiveType, int baseVertex, int minVertexIndex, int numVertices, int startIndex, int primitiveCount, int instanceCount) + { + throw new NotImplementedException(); + } + + #endregion // DrawInstancedPrimitives + + #region DrawUserIndexedPrimitives + 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(); + } + + #endregion // DrawUserIndexedPrimitives + + #region DrawUserPrimitives + public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType + { + throw new NotImplementedException(); + } + + #endregion // DrawUserPrimitives + internal Device NativeDevice { get @@ -290,45 +359,6 @@ namespace ANX.Framework.Windows.DX10 } } - 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.depthStencilView, 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.depthStencilView, 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) @@ -466,7 +496,6 @@ namespace ANX.Framework.Windows.DX10 } } - public void GetBackBufferData(Rectangle? rect, T[] data, int startIndex, int elementCount) where T : struct { throw new NotImplementedException(); @@ -482,22 +511,6 @@ namespace ANX.Framework.Windows.DX10 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) diff --git a/Samples/Primitives/Game1.cs b/Samples/Primitives/Game1.cs new file mode 100644 index 00000000..0b356a34 --- /dev/null +++ b/Samples/Primitives/Game1.cs @@ -0,0 +1,94 @@ +#region Using Statements +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; + +#endregion // Using Statements + +namespace Primitives +{ + public class Game1 : Microsoft.Xna.Framework.Game + { + GraphicsDeviceManager graphics; + SpriteBatch spriteBatch; + + SpriteFont font; + Texture2D bgTexture; + + public Game1() + { + graphics = new GraphicsDeviceManager(this); + Content.RootDirectory = "SampleContent"; + } + + protected override void Initialize() + { + graphics.PreferredBackBufferWidth = 600; + graphics.PreferredBackBufferHeight = 600; + graphics.ApplyChanges(); + + base.Initialize(); + } + + protected override void LoadContent() + { + spriteBatch = new SpriteBatch(GraphicsDevice); + + this.font = Content.Load(@"Fonts/Debug"); + + this.bgTexture = new Texture2D(GraphicsDevice, 1, 1); + this.bgTexture.SetData(new Color[] { Color.White }); + } + + protected override void UnloadContent() + { + + } + + protected override void Update(GameTime gameTime) + { + if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed || + Keyboard.GetState().IsKeyDown(Keys.Escape)) + this.Exit(); + + + base.Update(gameTime); + } + + protected override void Draw(GameTime gameTime) + { + GraphicsDevice.Clear(Color.CornflowerBlue); + + spriteBatch.Begin(); + + spriteBatch.Draw(bgTexture, new Rectangle(0, 0, 600, 200), Color.Blue); + spriteBatch.Draw(bgTexture, new Rectangle(0, 200, 300, 200), Color.Red); + spriteBatch.Draw(bgTexture, new Rectangle(300, 200, 300, 200), Color.Orange); + spriteBatch.Draw(bgTexture, new Rectangle(0, 400, 300, 200), Color.Green); + spriteBatch.Draw(bgTexture, new Rectangle(300, 400, 300, 200), Color.LightSeaGreen); + + DrawShadowText(spriteBatch, this.font, "DrawInstancedPrimitives", new Vector2(10, 10), Color.White, Color.Black); + DrawShadowText(spriteBatch, this.font, "DrawPrimitives", new Vector2(10, 210), Color.White, Color.Black); + DrawShadowText(spriteBatch, this.font, "DrawIndexedPrimitives", new Vector2(310, 210), Color.White, Color.Black); + DrawShadowText(spriteBatch, this.font, "DrawUserPrimitives", new Vector2(10, 410), Color.White, Color.Black); + DrawShadowText(spriteBatch, this.font, "DrawUserIndexedPrimitives", new Vector2(310, 410), Color.White, Color.Black); + + spriteBatch.End(); + + base.Draw(gameTime); + } + + private void DrawShadowText(SpriteBatch spriteBatch, SpriteFont font, String text, Vector2 position, Color foreground, Color shadow) + { + spriteBatch.DrawString(font, text, position + new Vector2(2, 2), shadow); + spriteBatch.DrawString(font, text, position, foreground); + } + } +} diff --git a/Samples/Primitives/GameThumbnail.png b/Samples/Primitives/GameThumbnail.png new file mode 100644 index 00000000..28fdab29 Binary files /dev/null and b/Samples/Primitives/GameThumbnail.png differ diff --git a/Samples/Primitives/Primitives.csproj b/Samples/Primitives/Primitives.csproj new file mode 100644 index 00000000..eb7197a2 --- /dev/null +++ b/Samples/Primitives/Primitives.csproj @@ -0,0 +1,129 @@ + + + + {57097B7A-A283-4409-8AAC-35BF0F458657} + {6D335F3A-9D43-41b4-9D22-F6F17C4BE596};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Debug + x86 + WinExe + Properties + Primitives + Primitives + v4.0 + Client + v4.0 + Windows + HiDef + 4b5697b8-4699-4c1a-85fd-a80f5d4b2aa3 + Game + anx.ico + GameThumbnail.png + publish\ + true + Disk + false + Foreground + 7 + Days + false + false + true + 0 + 1.0.0.%2a + false + false + true + + + true + full + false + bin\x86\Debug + DEBUG;TRACE;WINDOWS + prompt + 4 + true + false + x86 + false + + + pdbonly + true + bin\x86\Release + TRACE;WINDOWS + prompt + 4 + true + false + x86 + true + + + + + + + + + + + + + + + + + + + + + + true + + + + + {FA6E229D-4504-47B1-8A23-2D3FCC13F778} + SampleContent + Content + + + + + False + Microsoft .NET Framework 4 Client Profile %28x86 und x64%29 + true + + + False + .NET Framework 3.5 SP1 Client Profile + false + + + False + .NET Framework 3.5 SP1 + false + + + False + Windows Installer 3.1 + true + + + False + Microsoft XNA Framework Redistributable 4.0 + true + + + + + + \ No newline at end of file diff --git a/Samples/Primitives/Program.cs b/Samples/Primitives/Program.cs new file mode 100644 index 00000000..e3f37bb2 --- /dev/null +++ b/Samples/Primitives/Program.cs @@ -0,0 +1,21 @@ +using System; + +namespace Primitives +{ +#if WINDOWS || XBOX + static class Program + { + /// + /// Der Haupteinstiegspunkt für die Anwendung. + /// + static void Main(string[] args) + { + using (Game1 game = new Game1()) + { + game.Run(); + } + } + } +#endif +} + diff --git a/Samples/Primitives/Properties/AssemblyInfo.cs b/Samples/Primitives/Properties/AssemblyInfo.cs new file mode 100644 index 00000000..a90b3e3d --- /dev/null +++ b/Samples/Primitives/Properties/AssemblyInfo.cs @@ -0,0 +1,34 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// Allgemeine Informationen über eine Assembly werden über den folgenden +// Satz von Attributen kontrolliert. Ändern Sie diese Attributwerte, um die mit einer Assembly +// verbundenen Informationen zu ändern. +[assembly: AssemblyTitle("Primitives")] +[assembly: AssemblyProduct("Primitives")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyCompany("ANX.Framework Team")] +[assembly: AssemblyCopyright("Copyright © ANX.Framework Team 2011")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Bei Einstellung von ComVisible auf falsch sind die Typen in dieser Assembly für +// COM-Komponenten nicht sichtbar. Wenn Sie von COM aus auf einen Typ in dieser Assembly +// zugreifen müssen, stellen Sie das Attribut ComVisible bei diesem Typ auf wahr ein. Nur Windows- +// Assemblys unterstützen COM. +[assembly: ComVisible(false)] + +// Auf Windows gilt die folgende GUID für die ID von typelib, wenn dieses +// COM ausgesetzt ist. Auf anderen Plattformen identifiziert sie den +// Titelspeichercontainer bei Bereitstellung dieser Assembly auf dem Gerät eindeutig. +[assembly: Guid("a3fa690f-1084-43f1-baad-b2e734650d4e")] + +// Versionsinformationen für eine Assembly bestehen aus den folgenden vier Werten: +// +// Größere Version +// Kleinere Version +// Build-Nummer +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] diff --git a/Samples/Primitives/anx.ico b/Samples/Primitives/anx.ico new file mode 100644 index 00000000..f778e093 Binary files /dev/null and b/Samples/Primitives/anx.ico differ