diff --git a/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj b/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj
index 16ed1a05..e070ce4e 100644
--- a/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj
+++ b/ANX.Framework.Windows.GL3/ANX.Framework.Windows.GL3.csproj
@@ -45,11 +45,15 @@
+
+
+
+
diff --git a/ANX.Framework.Windows.GL3/Creator.cs b/ANX.Framework.Windows.GL3/Creator.cs
index 9b5fdf5f..cd60d7c9 100644
--- a/ANX.Framework.Windows.GL3/Creator.cs
+++ b/ANX.Framework.Windows.GL3/Creator.cs
@@ -1,14 +1,7 @@
-#region Using Statements
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using ANX.Framework;
-using ANX.Framework.NonXNA;
-using ANX.Framework.Graphics;
+using System;
using System.IO;
-
-#endregion // Using Statements
+using ANX.Framework.Graphics;
+using ANX.Framework.NonXNA;
#region License
@@ -59,6 +52,9 @@ using System.IO;
namespace ANX.Framework.Windows.GL3
{
+ ///
+ /// OpenGL graphics creator.
+ ///
public class Creator : IRenderSystemCreator
{
#region Public
@@ -91,13 +87,13 @@ namespace ANX.Framework.Windows.GL3
#region CreateEffect
public INativeEffect CreateEffect(GraphicsDevice graphics, Stream byteCode)
{
- return new EffectGL3(graphics, byteCode);
+ return new EffectGL3(byteCode);
}
public INativeEffect CreateEffect(GraphicsDevice graphics,
Stream vertexShaderByteCode, Stream pixelShaderByteCode)
{
- return new EffectGL3(graphics, vertexShaderByteCode, pixelShaderByteCode);
+ return new EffectGL3(vertexShaderByteCode, pixelShaderByteCode);
}
#endregion
@@ -129,17 +125,40 @@ namespace ANX.Framework.Windows.GL3
}
#endregion
+ #region CreateIndexBuffer
+ ///
+ /// Create a native index buffer.
+ ///
+ /// The current graphics device.
+ /// The size of a single index element.
+ /// The number of indices stored in the buffer.
+ ///
+ /// The usage type of the buffer.
+ /// Native OpenGL index buffer.
public INativeBuffer CreateIndexBuffer(GraphicsDevice graphics,
IndexElementSize size, int indexCount, BufferUsage usage)
{
- throw new NotImplementedException();
+ return new IndexBufferGL3(size, indexCount, usage);
}
+ #endregion
+ #region CreateVertexBuffer
+ ///
+ /// Create a native vertex buffer.
+ ///
+ /// The current graphics device.
+ /// The vertex declaration for the buffer.
+ /// The number of vertices stored in the buffer.
+ ///
+ /// The usage type of the buffer.
+ /// Native OpenGL vertex buffer.
public INativeBuffer CreateVertexBuffer(GraphicsDevice graphics,
- VertexDeclaration vertexDeclaration, int vertexCount, BufferUsage usage)
+ VertexDeclaration vertexDeclaration, int vertexCount,
+ BufferUsage usage)
{
- throw new NotImplementedException();
+ return new VertexBufferGL3(vertexDeclaration, vertexCount, usage);
}
+ #endregion
#region CreateBlendState
///
@@ -185,6 +204,12 @@ namespace ANX.Framework.Windows.GL3
}
#endregion
+ #region GetShaderByteCode (TODO)
+ ///
+ /// Get the byte code of a pre defined shader.
+ ///
+ /// Pre defined shader type.
+ /// Byte code of the shader.
public byte[] GetShaderByteCode(PreDefinedShader type)
{
switch (type)
@@ -197,5 +222,6 @@ namespace ANX.Framework.Windows.GL3
"' isn't supported yet!");
}
}
+ #endregion
}
}
diff --git a/ANX.Framework.Windows.GL3/DatatypesMapping.cs b/ANX.Framework.Windows.GL3/DatatypesMapping.cs
index 1f9a0d31..1e83f7bd 100644
--- a/ANX.Framework.Windows.GL3/DatatypesMapping.cs
+++ b/ANX.Framework.Windows.GL3/DatatypesMapping.cs
@@ -1,5 +1,6 @@
using System;
-using Otk = OpenTK.Graphics;
+using ANX.Framework.Graphics;
+using OpenTK.Graphics;
#region License
@@ -54,15 +55,18 @@ namespace ANX.Framework.Windows.GL3
{
public const float ColorMultiplier = 1f / 255f;
- public static void Convert(ref Color anxColor, out Otk.Color4 otkColor)
+ #region Convert ANX.Color -> OpenTK.Color4
+ public static void Convert(ref Color anxColor, out Color4 otkColor)
{
otkColor.R = anxColor.R * ColorMultiplier;
otkColor.G = anxColor.G * ColorMultiplier;
otkColor.B = anxColor.B * ColorMultiplier;
otkColor.A = anxColor.A * ColorMultiplier;
}
+ #endregion
- public static void Convert(ref Otk.Color4 otkColor, out Color anxColor)
+ #region Convert OpenTK.Color4 -> ANX.Color
+ public static void Convert(ref Color4 otkColor, out Color anxColor)
{
anxColor = new Color(otkColor.R, otkColor.G, otkColor.B, otkColor.A);
@@ -73,5 +77,76 @@ namespace ANX.Framework.Windows.GL3
//byte a = (byte)(otkColor.A * 255);
//anxColor.PackedValue = (uint)(r + (g << 8) + (b << 16) + (a << 24));
}
+ #endregion
+
+ #region SurfaceToColorFormat (TODO)
+ ///
+ /// Translate the XNA surface format to an OpenGL ColorFormat.
+ ///
+ /// XNA surface format.
+ /// Translated color format for OpenGL.
+ public static ColorFormat SurfaceToColorFormat(SurfaceFormat format)
+ {
+ switch (format)
+ {
+ // TODO
+ case SurfaceFormat.Dxt1:
+ case SurfaceFormat.Dxt3:
+ case SurfaceFormat.Dxt5:
+ case SurfaceFormat.HdrBlendable:
+ throw new NotImplementedException("Surface Format '" + format +
+ "' isn't implemented yet!");
+
+ // TODO: CHECK!
+ case SurfaceFormat.NormalizedByte2:
+ return new ColorFormat(8, 8, 0, 0);
+
+ //DONE
+ default:
+ case SurfaceFormat.Color:
+ case SurfaceFormat.NormalizedByte4:
+ return new ColorFormat(8, 8, 8, 8);
+
+ case SurfaceFormat.HalfVector2:
+ return new ColorFormat(16, 16, 0, 0);
+
+ case SurfaceFormat.HalfVector4:
+ return new ColorFormat(16, 16, 16, 16);
+
+ case SurfaceFormat.Bgra4444:
+ return new ColorFormat(4, 4, 4, 4);
+
+ case SurfaceFormat.Bgra5551:
+ return new ColorFormat(5, 5, 5, 1);
+
+ case SurfaceFormat.Alpha8:
+ return new ColorFormat(0, 0, 0, 8);
+
+ case SurfaceFormat.Bgr565:
+ return new ColorFormat(5, 6, 5, 0);
+
+ case SurfaceFormat.Rg32:
+ return new ColorFormat(16, 16, 0, 0);
+
+ case SurfaceFormat.Rgba1010102:
+ return new ColorFormat(10, 10, 10, 2);
+
+ case SurfaceFormat.Rgba64:
+ return new ColorFormat(16, 16, 16, 16);
+
+ case SurfaceFormat.HalfSingle:
+ return new ColorFormat(16, 0, 0, 0);
+
+ case SurfaceFormat.Single:
+ return new ColorFormat(32, 0, 0, 0);
+
+ case SurfaceFormat.Vector2:
+ return new ColorFormat(32, 32, 0, 0);
+
+ case SurfaceFormat.Vector4:
+ return new ColorFormat(32, 32, 32, 32);
+ }
+ }
+ #endregion
}
}
diff --git a/ANX.Framework.Windows.GL3/EffectGL3.cs b/ANX.Framework.Windows.GL3/EffectGL3.cs
index 093410ae..b822145a 100644
--- a/ANX.Framework.Windows.GL3/EffectGL3.cs
+++ b/ANX.Framework.Windows.GL3/EffectGL3.cs
@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.IO;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
+using OpenTK.Graphics.OpenGL;
#region License
@@ -53,16 +54,97 @@ using ANX.Framework.NonXNA;
namespace ANX.Framework.Windows.GL3
{
+ ///
+ /// Native OpenGL Effect implementation.
+ ///
public class EffectGL3 : INativeEffect
{
- public EffectGL3(GraphicsDevice device, Stream vertexShaderByteCode,
+ #region Private
+ ///
+ /// The native shader handle.
+ ///
+ private int programHandle;
+ #endregion
+
+ #region Constructor (TODO)
+ ///
+ /// Create a new effect instance of separate streams.
+ ///
+ /// The vertex shader code.
+ /// The fragment shader code.
+ public EffectGL3(Stream vertexShaderByteCode,
Stream pixelShaderByteCode)
{
+ CreateShader("", "");
}
- public EffectGL3(GraphicsDevice device, Stream byteCode)
+ ///
+ /// Create a new effect instance of one streams.
+ ///
+ /// The byte code of the shader.
+ public EffectGL3(Stream byteCode)
{
+ CreateShader("", "");
}
+ #endregion
+
+ #region CreateShader
+ private void CreateShader(string vertexSource, string fragmentSource)
+ {
+ int vertexShader = GL.CreateShader(ShaderType.VertexShader);
+ string vertexError = CompileShader(vertexShader, vertexSource);
+ if (String.IsNullOrEmpty(vertexError) == false)
+ {
+ throw new InvalidDataException("Failed to compile the vertex " +
+ "shader because of: " + vertexError);
+ }
+
+ int fragmentShader = GL.CreateShader(ShaderType.FragmentShader);
+ string fragmentError = CompileShader(fragmentShader, fragmentSource);
+ if (String.IsNullOrEmpty(fragmentError) == false)
+ {
+ throw new InvalidDataException("Failed to compile the fragment " +
+ "shader because of: " + fragmentError);
+ }
+
+ programHandle = GL.CreateProgram();
+ GL.AttachShader(programHandle, vertexShader);
+ GL.AttachShader(programHandle, fragmentShader);
+ GL.LinkProgram(programHandle);
+
+ int result;
+ GL.GetProgram(programHandle, ProgramParameter.LinkStatus, out result);
+ if (result == 0)
+ {
+ string programError;
+ GL.GetProgramInfoLog(programHandle, out programError);
+ throw new InvalidDataException("Failed to link the shader program " +
+ "because of: " + programError);
+ }
+ }
+ #endregion
+
+ #region CompileShader
+ private string CompileShader(int shader, string source)
+ {
+ GL.ShaderSource(shader, source);
+ GL.CompileShader(shader);
+
+ int result;
+ GL.GetShader(shader, ShaderParameter.CompileStatus, out result);
+ if (result == 0)
+ {
+ string error = "";
+ GL.GetShaderInfoLog(shader, out error);
+
+ GL.DeleteShader(shader);
+
+ return error;
+ }
+
+ return null;
+ }
+ #endregion
#region INativeEffect Member
@@ -99,13 +181,24 @@ namespace ANX.Framework.Windows.GL3
#endregion
- #region IDisposable Member
-
+ #region Dispose
+ ///
+ /// Dispose the native shader data.
+ ///
public void Dispose()
{
- throw new NotImplementedException();
- }
+ GL.DeleteProgram(programHandle);
+ int result;
+ GL.GetProgram(programHandle, ProgramParameter.DeleteStatus, out result);
+ if (result == 0)
+ {
+ string deleteError;
+ GL.GetProgramInfoLog(programHandle, out deleteError);
+ throw new Exception("Failed to delete the shader program because of: " +
+ deleteError);
+ }
+ }
#endregion
}
}
diff --git a/ANX.Framework.Windows.GL3/EffectParameterGL3.cs b/ANX.Framework.Windows.GL3/EffectParameterGL3.cs
new file mode 100644
index 00000000..57292f6a
--- /dev/null
+++ b/ANX.Framework.Windows.GL3/EffectParameterGL3.cs
@@ -0,0 +1,97 @@
+using System;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+
+#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.GL3
+{
+ ///
+ /// Native OpenGL implementation of an effect parameter.
+ ///
+ public class EffectParameterGL3 : INativeEffectParameter
+ {
+ #region Public
+ ///
+ /// The name of the effect parameter.
+ ///
+ public string Name
+ {
+ get;
+ private set;
+ }
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a ne effect parameter object.
+ ///
+ internal EffectParameterGL3()
+ {
+ }
+ #endregion
+
+ #region SetValue (TODO)
+ ///
+ /// Set a matrix value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Matrix value)
+ {
+ }
+
+ ///
+ /// Set a texture value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Texture value)
+ {
+ }
+ #endregion
+ }
+}
diff --git a/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs b/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs
new file mode 100644
index 00000000..12fd7d10
--- /dev/null
+++ b/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs
@@ -0,0 +1,78 @@
+using System;
+using ANX.Framework.NonXNA;
+
+#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.GL3
+{
+ ///
+ /// Native OpenGL implementation of an effect technique.
+ ///
+ public class EffectTechniqueGL3 : INativeEffectTechnique
+ {
+ #region Public
+ ///
+ /// The name of the effect technique.
+ ///
+ public string Name
+ {
+ get;
+ private set;
+ }
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a ne effect technique object.
+ ///
+ internal EffectTechniqueGL3()
+ {
+ }
+ #endregion
+ }
+}
diff --git a/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs b/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs
index edffda55..da9d713f 100644
--- a/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs
+++ b/ANX.Framework.Windows.GL3/GraphicsDeviceWindowsGL3.cs
@@ -138,7 +138,8 @@ namespace ANX.Framework.Windows.GL3
presentationParameters.DeviceWindowHandle);
GraphicsMode graphicsMode = new GraphicsMode(
- SurfaceToColorFormat(presentationParameters.BackBufferFormat),
+ DatatypesMapping.SurfaceToColorFormat(
+ presentationParameters.BackBufferFormat),
depth, stencil,
// AntiAlias Samples: 2/4/8/16/32
presentationParameters.MultiSampleCount);
@@ -149,31 +150,6 @@ namespace ANX.Framework.Windows.GL3
}
#endregion
- #region SurfaceToColorFormat (TODO)
- ///
- /// Translate the XNA surface format to an OpenGL ColorFormat.
- ///
- /// XNA surface format.
- /// Translated color format for OpenGL.
- private static ColorFormat SurfaceToColorFormat(SurfaceFormat format)
- {
- switch(format)
- {
- case SurfaceFormat.Bgra4444:
- return new ColorFormat(4, 4, 4, 4);
-
- case SurfaceFormat.Bgra5551:
- return new ColorFormat(5, 5, 5, 1);
-
- // TODO: rest of the stuff
-
- default:
- case SurfaceFormat.Color:
- return new ColorFormat(8, 8, 8, 8);
- }
- }
- #endregion
-
public void DrawUserPrimitive()
{
throw new NotImplementedException();
diff --git a/ANX.Framework.Windows.GL3/IndexBufferGL3.cs b/ANX.Framework.Windows.GL3/IndexBufferGL3.cs
new file mode 100644
index 00000000..9ed5e572
--- /dev/null
+++ b/ANX.Framework.Windows.GL3/IndexBufferGL3.cs
@@ -0,0 +1,127 @@
+using System;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+using OpenTK.Graphics.OpenGL;
+
+#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.GL3
+{
+ ///
+ /// Native OpenGL implementation of a Index Buffer.
+ ///
+ public class IndexBufferGL3 : INativeBuffer
+ {
+ #region Private
+ ///
+ /// Native index buffer handle.
+ ///
+ private int bufferHandle;
+
+ private int indexCount;
+
+ private IndexElementSize elementSize;
+
+ private BufferUsage usage;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new Index Buffer object.
+ ///
+ internal IndexBufferGL3(IndexElementSize setElementSize,
+ int setIndexCount, BufferUsage setUsage)
+ {
+ indexCount = setIndexCount;
+ elementSize = setElementSize;
+ usage = setUsage;
+
+ GL.GenBuffers(1, out bufferHandle);
+
+ }
+ #endregion
+
+ #region SetData (TODO)
+ public void SetData(GraphicsDevice graphicsDevice, T[] data)
+ where T : struct
+ {
+ // TODO: check
+ IntPtr size = (IntPtr)((elementSize == IndexElementSize.SixteenBits ?
+ 16 : 32) * data.Length);
+
+ // TODO: check
+ BufferUsageHint usageHint = usage == BufferUsage.WriteOnly ?
+ BufferUsageHint.StaticDraw :
+ BufferUsageHint.DynamicDraw;
+
+ GL.BindBuffer(BufferTarget.ElementArrayBuffer, bufferHandle);
+ GL.BufferData(BufferTarget.ElementArrayBuffer, size, data, usageHint);
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data,
+ int startIndex, int elementCount) where T : struct
+ {
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes,
+ T[] data, int startIndex, int elementCount) where T : struct
+ {
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose the native index buffer data.
+ ///
+ public void Dispose()
+ {
+ GL.DeleteBuffers(1, ref bufferHandle);
+ }
+ #endregion
+ }
+}
diff --git a/ANX.Framework.Windows.GL3/SamplerStateGL3.cs b/ANX.Framework.Windows.GL3/SamplerStateGL3.cs
index 893da8cc..a425d0c5 100644
--- a/ANX.Framework.Windows.GL3/SamplerStateGL3.cs
+++ b/ANX.Framework.Windows.GL3/SamplerStateGL3.cs
@@ -1,6 +1,7 @@
using System;
using ANX.Framework.Graphics;
using ANX.Framework.NonXNA;
+using OpenTK.Graphics.OpenGL;
#region License
@@ -56,10 +57,17 @@ namespace ANX.Framework.Windows.GL3
///
/// Basically this is a wrapper class for setting the different values all
/// at once, because OpenGL has no State objects like DirectX.
+ ///
+ /// Info for OpenGL filter states:
+ /// http://gregs-blog.com/2008/01/17/opengl-texture-filter-parameters-explained/
+ ///
+ /// Info for OGL 3.3 sampler objects (sadly not implemented in OpenTK yet):
+ /// http://www.sinanc.org/blog/?p=215
///
public class SamplerStateGL3 : INativeSamplerState
{
#region Public
+ #region IsBound
///
/// Flag if the state object is bound to the device.
///
@@ -68,49 +76,64 @@ namespace ANX.Framework.Windows.GL3
get;
private set;
}
+ #endregion
+ #region AddressU
public TextureAddressMode AddressU
{
set;
private get;
}
-
+ #endregion
+
+ #region AddressV
public TextureAddressMode AddressV
{
set;
private get;
}
-
+ #endregion
+
+ #region AddressW
public TextureAddressMode AddressW
{
set;
private get;
}
-
+ #endregion
+
+ #region Filter
public TextureFilter Filter
{
set;
private get;
}
-
+ #endregion
+
+ #region MaxAnisotropy
public int MaxAnisotropy
{
set;
private get;
}
-
+ #endregion
+
+ #region MaxMipLevel
public int MaxMipLevel
{
set;
private get;
}
-
+ #endregion
+
+ #region MipMapLevelOfDetailBias
public float MipMapLevelOfDetailBias
{
set;
private get;
}
#endregion
+ #endregion
#region Constructor
///
diff --git a/ANX.Framework.Windows.GL3/VertexBufferGL3.cs b/ANX.Framework.Windows.GL3/VertexBufferGL3.cs
new file mode 100644
index 00000000..f03fc171
--- /dev/null
+++ b/ANX.Framework.Windows.GL3/VertexBufferGL3.cs
@@ -0,0 +1,108 @@
+using System;
+using ANX.Framework.NonXNA;
+using ANX.Framework.Graphics;
+using OpenTK.Graphics.OpenGL;
+
+#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.GL3
+{
+ ///
+ /// Native OpenGL implementation of a Vertex Buffer.
+ ///
+ /// Information about vbo/ibo: http://playcontrol.net/ewing/jibberjabber/opengl_vertex_buffer_object.html
+ ///
+ public class VertexBufferGL3 : INativeBuffer
+ {
+ #region Private
+ ///
+ /// Native vertex buffer handle.
+ ///
+ private int bufferHandle;
+ #endregion
+
+ #region Constructor
+ ///
+ /// Create a new Vertex Buffer object.
+ ///
+ internal VertexBufferGL3(VertexDeclaration vertexDeclaration,
+ int vertexCount, BufferUsage usage)
+ {
+ GL.GenBuffers(1, out bufferHandle);
+ }
+ #endregion
+
+ #region SetData (TODO)
+ public void SetData(GraphicsDevice graphicsDevice, T[] data)
+ where T : struct
+ {
+ GL.BindBuffer(BufferTarget.ArrayBuffer, bufferHandle);
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, T[] data,
+ int startIndex, int elementCount) where T : struct
+ {
+ }
+
+ public void SetData(GraphicsDevice graphicsDevice, int offsetInBytes,
+ T[] data, int startIndex, int elementCount) where T : struct
+ {
+ }
+ #endregion
+
+ #region Dispose
+ ///
+ /// Dispose the native index buffer data.
+ ///
+ public void Dispose()
+ {
+ GL.DeleteBuffers(1, ref bufferHandle);
+ }
+ #endregion
+ }
+}