From 25d2c8dce422b8ff13648a9f016970cc51c132a1 Mon Sep 17 00:00:00 2001 From: Glatzemann Date: Thu, 10 Nov 2011 07:12:04 +0000 Subject: [PATCH] fixed a merge issue in GL-RenderSystem --- .../GraphicsDeviceWindowsGL3.cs | 442 +++++++++--------- ANX.Framework/Properties/AssemblyInfo.cs | 7 +- Samples/WindowsGame/Game1.cs | 2 +- 3 files changed, 222 insertions(+), 229 deletions(-) diff --git a/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs b/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs index d59748b9..41591ad0 100644 --- a/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs +++ b/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs @@ -57,260 +57,248 @@ 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 + public class GraphicsDeviceWindowsGL3 : INativeGraphicsDevice + { + #region Constants + private const float ColorMultiplier = 1f / 255f; + #endregion - #region Private - /// - /// Native graphics context. - /// - private GraphicsContext nativeContext; + #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 + /// + /// 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 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; - } + #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 + 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; + // 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.Depth16: + depth = 16; + break; - case DepthFormat.Depth24: - depth = 24; - break; + case DepthFormat.Depth24: + depth = 24; + break; - case DepthFormat.Depth24Stencil8: - depth = 24; - stencil = 8; - break; - } + case DepthFormat.Depth24Stencil8: + depth = 24; + stencil = 8; + break; + } - nativeWindowInfo = Utilities.CreateWindowsWindowInfo( - presentationParameters.DeviceWindowHandle); + nativeWindowInfo = Utilities.CreateWindowsWindowInfo( + presentationParameters.DeviceWindowHandle); - GraphicsMode graphicsMode = new GraphicsMode( - DatatypesMapping.SurfaceToColorFormat( - presentationParameters.BackBufferFormat), - depth, stencil, - // AntiAlias Samples: 2/4/8/16/32 - presentationParameters.MultiSampleCount); + 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 + nativeContext = new GraphicsContext(graphicsMode, nativeWindowInfo); + nativeContext.MakeCurrent(nativeWindowInfo); + nativeContext.LoadAll(); + } + #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); - } - #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 - /// - /// 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); - } + #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); + } - 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; - } + /// + /// 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); + } - GL.ClearDepth(depth); - GL.ClearStencil(stencil); - GL.Clear(mask); - } - #endregion + 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; + } - #region Present - /// - /// Swap the graphics buffers. - /// - public void Present() - { - nativeContext.SwapBuffers(); - } - #endregion + GL.ClearDepth(depth); + GL.ClearStencil(stencil); + GL.Clear(mask); + } + #endregion - public void DrawIndexedPrimitives(PrimitiveType primitiveType, - int baseVertex, int minVertexIndex, int numVertices, int startIndex, - int primitiveCount) - { - throw new NotImplementedException(); - } + #region Present + /// + /// Swap the graphics buffers. + /// + public void Present() + { + nativeContext.SwapBuffers(); + } + #endregion - 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(); - } - -<<<<<<< .mine - public void DrawUserPrimitives(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType + 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 void GetBackBufferData(T[] data, int startIndex, - int elementCount) where T : struct - { - throw new NotImplementedException(); - } - } ->>>>>>> .r12199 } diff --git a/ANX.Framework/Properties/AssemblyInfo.cs b/ANX.Framework/Properties/AssemblyInfo.cs index b0d5cb63..b6ecdc3c 100644 --- a/ANX.Framework/Properties/AssemblyInfo.cs +++ b/ANX.Framework/Properties/AssemblyInfo.cs @@ -35,4 +35,9 @@ using System.Runtime.InteropServices; [assembly: AssemblyVersion("0.4.1.*")] [assembly: AssemblyFileVersion("0.4.1.0")] -[assembly:InternalsVisibleTo("ANX.Framework.Windows.GL3")] \ No newline at end of file +[assembly:InternalsVisibleTo("ANX.Framework.Windows.DX10")] +[assembly:InternalsVisibleTo("ANX.Framework.Windows.DX11.1")] +[assembly:InternalsVisibleTo("ANX.Framework.Windows.GL3")] +[assembly:InternalsVisibleTo("ANX.Framework.Windows.Kinect")] +[assembly:InternalsVisibleTo("ANX.Framework.Windows.XInput")] +[assembly:InternalsVisibleTo("ANX.Framework.Windows.XAudio")] diff --git a/Samples/WindowsGame/Game1.cs b/Samples/WindowsGame/Game1.cs index 37a51f1b..161af515 100644 --- a/Samples/WindowsGame/Game1.cs +++ b/Samples/WindowsGame/Game1.cs @@ -89,7 +89,7 @@ namespace WindowsGame1 protected override void LoadContent() { // Create a new SpriteBatch, which can be used to draw textures. - spriteBatch = new SpriteBatch(GraphicsDevice); + //TODO: spriteBatch = new SpriteBatch(GraphicsDevice); } ///