fixed a merge issue in GL-RenderSystem
This commit is contained in:
parent
0a8bdbb9b0
commit
25d2c8dce4
@ -57,260 +57,248 @@ namespace ANX.Framework.Windows.GL3
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Native OpenGL implementation for a graphics device.
|
/// Native OpenGL implementation for a graphics device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class GraphicsDeviceWindowsGL3 : INativeGraphicsDevice
|
public class GraphicsDeviceWindowsGL3 : INativeGraphicsDevice
|
||||||
{
|
{
|
||||||
#region Constants
|
#region Constants
|
||||||
private const float ColorMultiplier = 1f / 255f;
|
private const float ColorMultiplier = 1f / 255f;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Private
|
#region Private
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Native graphics context.
|
/// Native graphics context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private GraphicsContext nativeContext;
|
private GraphicsContext nativeContext;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The OpenTK window info helper class to provide window informations
|
/// The OpenTK window info helper class to provide window informations
|
||||||
/// to the graphics device.
|
/// to the graphics device.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private IWindowInfo nativeWindowInfo;
|
private IWindowInfo nativeWindowInfo;
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region Constructor
|
#region Constructor
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Create a new OpenGL graphics context.
|
/// Create a new OpenGL graphics context.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="presentationParameters">Parameters for the window
|
/// <param name="presentationParameters">Parameters for the window
|
||||||
/// and graphics context.</param>
|
/// and graphics context.</param>
|
||||||
internal GraphicsDeviceWindowsGL3(
|
internal GraphicsDeviceWindowsGL3(
|
||||||
PresentationParameters presentationParameters)
|
PresentationParameters presentationParameters)
|
||||||
{
|
{
|
||||||
ResetDevice(presentationParameters);
|
ResetDevice(presentationParameters);
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ResetDevice
|
#region ResetDevice
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reset the graphics device with the given presentation paramters.
|
/// Reset the graphics device with the given presentation paramters.
|
||||||
/// If a device is currently set, then we dispose the old one.
|
/// If a device is currently set, then we dispose the old one.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="presentationParameters">Parameters for the
|
/// <param name="presentationParameters">Parameters for the
|
||||||
/// graphics device.</param>
|
/// graphics device.</param>
|
||||||
private void ResetDevice(PresentationParameters presentationParameters)
|
private void ResetDevice(PresentationParameters presentationParameters)
|
||||||
{
|
{
|
||||||
#region Validation
|
#region Validation
|
||||||
if (nativeContext != null)
|
if (nativeContext != null)
|
||||||
{
|
{
|
||||||
nativeContext.Dispose();
|
nativeContext.Dispose();
|
||||||
nativeContext = null;
|
nativeContext = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nativeWindowInfo != null)
|
if (nativeWindowInfo != null)
|
||||||
{
|
{
|
||||||
nativeWindowInfo.Dispose();
|
nativeWindowInfo.Dispose();
|
||||||
nativeWindowInfo = null;
|
nativeWindowInfo = null;
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
// OpenGL Depth Buffer Size: 0/16/24/32
|
// OpenGL Depth Buffer Size: 0/16/24/32
|
||||||
int depth = 0;
|
int depth = 0;
|
||||||
int stencil = 0;
|
int stencil = 0;
|
||||||
switch (presentationParameters.DepthStencilFormat)
|
switch (presentationParameters.DepthStencilFormat)
|
||||||
{
|
{
|
||||||
case DepthFormat.None:
|
case DepthFormat.None:
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DepthFormat.Depth16:
|
case DepthFormat.Depth16:
|
||||||
depth = 16;
|
depth = 16;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DepthFormat.Depth24:
|
case DepthFormat.Depth24:
|
||||||
depth = 24;
|
depth = 24;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case DepthFormat.Depth24Stencil8:
|
case DepthFormat.Depth24Stencil8:
|
||||||
depth = 24;
|
depth = 24;
|
||||||
stencil = 8;
|
stencil = 8;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
nativeWindowInfo = Utilities.CreateWindowsWindowInfo(
|
nativeWindowInfo = Utilities.CreateWindowsWindowInfo(
|
||||||
presentationParameters.DeviceWindowHandle);
|
presentationParameters.DeviceWindowHandle);
|
||||||
|
|
||||||
GraphicsMode graphicsMode = new GraphicsMode(
|
GraphicsMode graphicsMode = new GraphicsMode(
|
||||||
DatatypesMapping.SurfaceToColorFormat(
|
DatatypesMapping.SurfaceToColorFormat(
|
||||||
presentationParameters.BackBufferFormat),
|
presentationParameters.BackBufferFormat),
|
||||||
depth, stencil,
|
depth, stencil,
|
||||||
// AntiAlias Samples: 2/4/8/16/32
|
// AntiAlias Samples: 2/4/8/16/32
|
||||||
presentationParameters.MultiSampleCount);
|
presentationParameters.MultiSampleCount);
|
||||||
|
|
||||||
nativeContext = new GraphicsContext(graphicsMode, nativeWindowInfo);
|
nativeContext = new GraphicsContext(graphicsMode, nativeWindowInfo);
|
||||||
nativeContext.MakeCurrent(nativeWindowInfo);
|
nativeContext.MakeCurrent(nativeWindowInfo);
|
||||||
nativeContext.LoadAll();
|
nativeContext.LoadAll();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region SetViewport
|
|
||||||
/// <summary>
|
|
||||||
/// Set the OpenGL viewport.
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="viewport">Viewport data to set natively.</param>
|
|
||||||
public void SetViewport(Viewport viewport)
|
|
||||||
{
|
|
||||||
GL.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Clear
|
#region SetViewport
|
||||||
private uint lastClearColor;
|
/// <summary>
|
||||||
/// <summary>
|
/// Set the OpenGL viewport.
|
||||||
/// Clear the current screen by the specified clear color.
|
/// </summary>
|
||||||
/// </summary>
|
/// <param name="viewport">Viewport data to set natively.</param>
|
||||||
/// <param name="color">Clear color.</param>
|
public void SetViewport(Viewport viewport)
|
||||||
public void Clear(ref Color color)
|
{
|
||||||
{
|
GL.Viewport(viewport.X, viewport.Y, viewport.Width, viewport.Height);
|
||||||
uint newClearColor = color.PackedValue;
|
}
|
||||||
if (lastClearColor != newClearColor)
|
#endregion
|
||||||
{
|
|
||||||
lastClearColor = newClearColor;
|
|
||||||
GL.ClearColor(color.R * ColorMultiplier, color.G * ColorMultiplier,
|
|
||||||
color.B * ColorMultiplier, color.A * ColorMultiplier);
|
|
||||||
}
|
|
||||||
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Clear
|
#region Clear
|
||||||
/// <summary>
|
private uint lastClearColor;
|
||||||
/// Clear the current screen by the specified clear color and options.
|
/// <summary>
|
||||||
/// </summary>
|
/// Clear the current screen by the specified clear color.
|
||||||
/// <param name="options">Clear options defining which components
|
/// </summary>
|
||||||
/// should be cleared.</param>
|
/// <param name="color">Clear color.</param>
|
||||||
/// <param name="color">Clear color.</param>
|
public void Clear(ref Color color)
|
||||||
/// <param name="depth">Depth value.</param>
|
{
|
||||||
/// <param name="stencil">Stencil value.</param>
|
uint newClearColor = color.PackedValue;
|
||||||
public void Clear(ClearOptions options, Vector4 color, float depth,
|
if (lastClearColor != newClearColor)
|
||||||
int stencil)
|
{
|
||||||
{
|
lastClearColor = newClearColor;
|
||||||
Color anxColor;
|
GL.ClearColor(color.R * ColorMultiplier, color.G * ColorMultiplier,
|
||||||
DatatypesMapping.Convert(ref color, out anxColor);
|
color.B * ColorMultiplier, color.A * ColorMultiplier);
|
||||||
uint newClearColor = anxColor.PackedValue;
|
}
|
||||||
if (lastClearColor != newClearColor)
|
GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit);
|
||||||
{
|
}
|
||||||
lastClearColor = newClearColor;
|
|
||||||
GL.ClearColor(anxColor.R * ColorMultiplier, anxColor.G * ColorMultiplier,
|
|
||||||
anxColor.B * ColorMultiplier, anxColor.A * ColorMultiplier);
|
|
||||||
}
|
|
||||||
|
|
||||||
ClearBufferMask mask = (ClearBufferMask)0;
|
/// <summary>
|
||||||
if ((options | ClearOptions.Target) == options)
|
/// Clear the current screen by the specified clear color and options.
|
||||||
{
|
/// </summary>
|
||||||
mask |= ClearBufferMask.ColorBufferBit;
|
/// <param name="options">Clear options defining which components
|
||||||
}
|
/// should be cleared.</param>
|
||||||
if ((options | ClearOptions.Stencil) == options)
|
/// <param name="color">Clear color.</param>
|
||||||
{
|
/// <param name="depth">Depth value.</param>
|
||||||
mask |= ClearBufferMask.StencilBufferBit;
|
/// <param name="stencil">Stencil value.</param>
|
||||||
}
|
public void Clear(ClearOptions options, Vector4 color, float depth,
|
||||||
if ((options | ClearOptions.DepthBuffer) == options)
|
int stencil)
|
||||||
{
|
{
|
||||||
mask |= ClearBufferMask.DepthBufferBit;
|
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);
|
ClearBufferMask mask = (ClearBufferMask)0;
|
||||||
GL.ClearStencil(stencil);
|
if ((options | ClearOptions.Target) == options)
|
||||||
GL.Clear(mask);
|
{
|
||||||
}
|
mask |= ClearBufferMask.ColorBufferBit;
|
||||||
#endregion
|
}
|
||||||
|
if ((options | ClearOptions.Stencil) == options)
|
||||||
|
{
|
||||||
|
mask |= ClearBufferMask.StencilBufferBit;
|
||||||
|
}
|
||||||
|
if ((options | ClearOptions.DepthBuffer) == options)
|
||||||
|
{
|
||||||
|
mask |= ClearBufferMask.DepthBufferBit;
|
||||||
|
}
|
||||||
|
|
||||||
#region Present
|
GL.ClearDepth(depth);
|
||||||
/// <summary>
|
GL.ClearStencil(stencil);
|
||||||
/// Swap the graphics buffers.
|
GL.Clear(mask);
|
||||||
/// </summary>
|
}
|
||||||
public void Present()
|
#endregion
|
||||||
{
|
|
||||||
nativeContext.SwapBuffers();
|
|
||||||
}
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public void DrawIndexedPrimitives(PrimitiveType primitiveType,
|
#region Present
|
||||||
int baseVertex, int minVertexIndex, int numVertices, int startIndex,
|
/// <summary>
|
||||||
int primitiveCount)
|
/// Swap the graphics buffers.
|
||||||
{
|
/// </summary>
|
||||||
throw new NotImplementedException();
|
public void Present()
|
||||||
}
|
{
|
||||||
|
nativeContext.SwapBuffers();
|
||||||
|
}
|
||||||
|
#endregion
|
||||||
|
|
||||||
public void DrawInstancedPrimitives(PrimitiveType primitiveType,
|
public void DrawIndexedPrimitives(PrimitiveType primitiveType,
|
||||||
int baseVertex, int minVertexIndex, int numVertices, int startIndex,
|
int baseVertex, int minVertexIndex, int numVertices, int startIndex,
|
||||||
int primitiveCount, int instanceCount)
|
int primitiveCount)
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DrawUserIndexedPrimitives<T>(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<T>(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<T>(Rectangle? rect, T[] data,
|
|
||||||
int startIndex, int elementCount) where T : struct
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void GetBackBufferData<T>(T[] data) where T : struct
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
|
|
||||||
<<<<<<< .mine
|
|
||||||
public void DrawUserPrimitives<T>(PrimitiveType primitiveType, T[] vertexData, int vertexOffset, int primitiveCount, VertexDeclaration vertexDeclaration) where T : struct, IVertexType
|
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
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<T>(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<T>(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<T>(Rectangle? rect, T[] data,
|
||||||
|
int startIndex, int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetBackBufferData<T>(T[] data) where T : struct
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void GetBackBufferData<T>(T[] data, int startIndex, int elementCount) where T : struct
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
public void ResizeBuffers(PresentationParameters presentationParameters)
|
public void ResizeBuffers(PresentationParameters presentationParameters)
|
||||||
{
|
{
|
||||||
throw new NotImplementedException();
|
throw new NotImplementedException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
public void GetBackBufferData<T>(T[] data, int startIndex,
|
|
||||||
int elementCount) where T : struct
|
|
||||||
{
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
>>>>>>> .r12199
|
|
||||||
}
|
}
|
||||||
|
@ -35,4 +35,9 @@ using System.Runtime.InteropServices;
|
|||||||
[assembly: AssemblyVersion("0.4.1.*")]
|
[assembly: AssemblyVersion("0.4.1.*")]
|
||||||
[assembly: AssemblyFileVersion("0.4.1.0")]
|
[assembly: AssemblyFileVersion("0.4.1.0")]
|
||||||
|
|
||||||
[assembly:InternalsVisibleTo("ANX.Framework.Windows.GL3")]
|
[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")]
|
||||||
|
@ -89,7 +89,7 @@ namespace WindowsGame1
|
|||||||
protected override void LoadContent()
|
protected override void LoadContent()
|
||||||
{
|
{
|
||||||
// Create a new SpriteBatch, which can be used to draw textures.
|
// Create a new SpriteBatch, which can be used to draw textures.
|
||||||
spriteBatch = new SpriteBatch(GraphicsDevice);
|
//TODO: spriteBatch = new SpriteBatch(GraphicsDevice);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user