diff --git a/RenderSystems/ANX.Framework.Windows.GL3/BlendStateGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/BlendStateGL3.cs
index 9a094b69..504d7881 100644
--- a/RenderSystems/ANX.Framework.Windows.GL3/BlendStateGL3.cs
+++ b/RenderSystems/ANX.Framework.Windows.GL3/BlendStateGL3.cs
@@ -190,32 +190,32 @@ namespace ANX.Framework.Windows.GL3
{
IsBound = true;
- GL.Enable(EnableCap.Blend);
+ GL.Enable(EnableCap.Blend);
- GL.BlendEquationSeparate(
- TranslateBlendFunction(ColorBlendFunction),
- TranslateBlendFunction(AlphaBlendFunction));
- ErrorHelper.Check("BlendEquationSeparate");
+ GL.BlendEquationSeparate(
+ TranslateBlendFunction(ColorBlendFunction),
+ TranslateBlendFunction(AlphaBlendFunction));
+ ErrorHelper.Check("BlendEquationSeparate");
- GL.BlendFuncSeparate(
- TranslateBlendSrc(ColorSourceBlend),
- TranslateBlendDest(ColorDestinationBlend),
- TranslateBlendSrc(AlphaSourceBlend),
- TranslateBlendDest(AlphaDestinationBlend));
- ErrorHelper.Check("BlendFuncSeparate");
+ GL.BlendFuncSeparate(
+ TranslateBlendSrc(ColorSourceBlend),
+ TranslateBlendDest(ColorDestinationBlend),
+ TranslateBlendSrc(AlphaSourceBlend),
+ TranslateBlendDest(AlphaDestinationBlend));
+ ErrorHelper.Check("BlendFuncSeparate");
- SetColorWriteChannel(0, ColorWriteChannels);
- SetColorWriteChannel(1, ColorWriteChannels1);
- SetColorWriteChannel(2, ColorWriteChannels2);
- SetColorWriteChannel(3, ColorWriteChannels3);
+ SetColorWriteChannel(0, ColorWriteChannels);
+ SetColorWriteChannel(1, ColorWriteChannels1);
+ SetColorWriteChannel(2, ColorWriteChannels2);
+ SetColorWriteChannel(3, ColorWriteChannels3);
- GL.BlendColor(BlendFactor.R * DatatypesMapping.ColorMultiplier,
- BlendFactor.G * DatatypesMapping.ColorMultiplier,
- BlendFactor.B * DatatypesMapping.ColorMultiplier,
- BlendFactor.A * DatatypesMapping.ColorMultiplier);
- ErrorHelper.Check("BlendColor");
+ GL.BlendColor(BlendFactor.R * DatatypesMapping.ColorMultiplier,
+ BlendFactor.G * DatatypesMapping.ColorMultiplier,
+ BlendFactor.B * DatatypesMapping.ColorMultiplier,
+ BlendFactor.A * DatatypesMapping.ColorMultiplier);
+ ErrorHelper.Check("BlendColor");
-// TODO: multi sample mask
+ // TODO: multi sample mask
}
#endregion
@@ -356,25 +356,25 @@ namespace ANX.Framework.Windows.GL3
/// OpenGL Blend Equation Mode.
private BlendEquationMode TranslateBlendFunction(BlendFunction func)
{
- switch (func)
- {
- case BlendFunction.Add:
- return BlendEquationMode.FuncAdd;
+ switch (func)
+ {
+ case BlendFunction.Add:
+ return BlendEquationMode.FuncAdd;
- case BlendFunction.Subtract:
- return BlendEquationMode.FuncSubtract;
+ case BlendFunction.Subtract:
+ return BlendEquationMode.FuncSubtract;
- case BlendFunction.ReverseSubtract:
- return BlendEquationMode.FuncReverseSubtract;
+ case BlendFunction.ReverseSubtract:
+ return BlendEquationMode.FuncReverseSubtract;
- case BlendFunction.Min:
- return BlendEquationMode.Min;
+ case BlendFunction.Min:
+ return BlendEquationMode.Min;
- case BlendFunction.Max:
- return BlendEquationMode.Max;
- }
+ case BlendFunction.Max:
+ return BlendEquationMode.Max;
+ }
- throw new ArgumentException("don't know how to translate BlendFunction '" + func.ToString() + "' to BlendEquationMode");
+ throw new ArgumentException("don't know how to translate BlendFunction '" + func.ToString() + "' to BlendEquationMode");
}
#endregion
}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs
index 152d025e..707076a3 100644
--- a/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs
+++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectGL3.cs
@@ -108,7 +108,7 @@ namespace ANX.Framework.Windows.GL3
}
#endregion
- #region Parameters (TODO)
+ #region Parameters
public IEnumerable Parameters
{
get
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectParameterGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectParameterGL3.cs
index ef200176..c8856eac 100644
--- a/RenderSystems/ANX.Framework.Windows.GL3/EffectParameterGL3.cs
+++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectParameterGL3.cs
@@ -80,7 +80,7 @@ namespace ANX.Framework.Windows.GL3
private set;
}
#endregion
-
+
#region Constructor
///
/// Create a ne effect parameter object.
@@ -115,6 +115,62 @@ namespace ANX.Framework.Windows.GL3
}
#endregion
+ #region SetValue (Matrix[])
+ ///
+ /// Set a Matrix array value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Matrix[] value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ float[] array = new float[value.Length * 16];
+ for (int index = 0; index < value.Length; index++)
+ {
+ array[(index * 16)] = value[index].M11;
+ array[(index * 16) + 1] = value[index].M12;
+ array[(index * 16) + 2] = value[index].M13;
+ array[(index * 16) + 3] = value[index].M14;
+ array[(index * 16) + 4] = value[index].M21;
+ array[(index * 16) + 5] = value[index].M22;
+ array[(index * 16) + 6] = value[index].M23;
+ array[(index * 16) + 7] = value[index].M24;
+ array[(index * 16) + 8] = value[index].M31;
+ array[(index * 16) + 9] = value[index].M32;
+ array[(index * 16) + 10] = value[index].M33;
+ array[(index * 16) + 11] = value[index].M34;
+ array[(index * 16) + 12] = value[index].M41;
+ array[(index * 16) + 13] = value[index].M42;
+ array[(index * 16) + 14] = value[index].M43;
+ array[(index * 16) + 15] = value[index].M44;
+ }
+ GL.UniformMatrix4(UniformIndex, array.Length, false, array);
+ ErrorHelper.Check("UniformMatrix4v");
+ }
+ #endregion
+
+ #region SetValue (Quaternion) (TODO)
+ ///
+ /// Set a Quaternion value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Quaternion value)
+ {
+ throw new NotImplementedException();
+ }
+ #endregion
+
+ #region SetValue (Quaternion[]) (TODO)
+ ///
+ /// Set a Quaternion array value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Quaternion[] value)
+ {
+ throw new NotImplementedException();
+ }
+ #endregion
+
#region SetValue (Texture)
private Texture textureCache = null;
///
@@ -130,8 +186,6 @@ namespace ANX.Framework.Windows.GL3
{
// TODO: multiple texture units
TextureUnit textureUnit = TextureUnit.Texture0;
- GL.Enable(EnableCap.Texture2D);
- ErrorHelper.Check("Enable");
GL.ActiveTexture(textureUnit);
ErrorHelper.Check("ActiveTexture");
int handle = (value.NativeTexture as Texture2DGL3).NativeHandle;
@@ -144,80 +198,187 @@ namespace ANX.Framework.Windows.GL3
}
#endregion
+ #region SetValue (bool) (TODO)
+ ///
+ /// Set a bool value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(bool value)
+ {
+ throw new NotImplementedException();
+ }
+ #endregion
- public void SetValue(bool value)
- {
- throw new NotImplementedException();
- }
+ #region SetValue (bool[]) (TODO)
+ ///
+ /// Set a bool array value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(bool[] value)
+ {
+ throw new NotImplementedException();
+ }
+ #endregion
- public void SetValue(bool[] value)
- {
- throw new NotImplementedException();
- }
+ #region SetValue (int)
+ ///
+ /// Set an int value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(int value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ GL.Uniform1(UniformIndex, value);
+ ErrorHelper.Check("Uniform1i");
+ }
+ #endregion
- public void SetValue(int value)
- {
- throw new NotImplementedException();
- }
+ #region SetValue (int[])
+ ///
+ /// Set an int array value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(int[] value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ GL.Uniform1(UniformIndex, value.Length, value);
+ ErrorHelper.Check("Uniform1iv");
+ }
+ #endregion
+
+ #region SetValue (float)
+ ///
+ /// Set a float value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(float value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ GL.Uniform1(UniformIndex, value);
+ ErrorHelper.Check("Uniform1f");
+ }
+ #endregion
- public void SetValue(int[] value)
- {
- throw new NotImplementedException();
- }
+ #region SetValue (float[])
+ ///
+ /// Set a float array value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(float[] value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ GL.Uniform1(UniformIndex, value.Length, value);
+ ErrorHelper.Check("Uniform1fv");
+ }
+ #endregion
- public void SetValue(Matrix[] value)
- {
- throw new NotImplementedException();
- }
+ #region SetValue (Vector2)
+ ///
+ /// Set a Vector2 value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Vector2 value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ GL.Uniform2(UniformIndex, value.X, value.Y);
+ ErrorHelper.Check("Uniform2f");
+ }
+ #endregion
- public void SetValue(Quaternion value)
- {
- throw new NotImplementedException();
- }
+ #region SetValue (Vector2[])
+ ///
+ /// Set a Vector2 array value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Vector2[] value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ float[] array = new float[value.Length * 2];
+ for(int index = 0; index < value.Length; index++)
+ {
+ array[(index * 2)] = value[index].X;
+ array[(index * 2) + 1] = value[index].Y;
+ }
+ GL.Uniform2(UniformIndex, array.Length, array);
+ ErrorHelper.Check("Uniform2fv");
+ }
+ #endregion
- public void SetValue(Quaternion[] value)
- {
- throw new NotImplementedException();
- }
+ #region SetValue (Vector3)
+ ///
+ /// Set a Vector3 value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Vector3 value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ GL.Uniform3(UniformIndex, value.X, value.Y, value.Z);
+ ErrorHelper.Check("Uniform3f");
+ }
+ #endregion
- public void SetValue(float value)
- {
- throw new NotImplementedException();
- }
+ #region SetValue (Vector3[])
+ ///
+ /// Set a Vector3 array value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Vector3[] value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ float[] array = new float[value.Length * 3];
+ for (int index = 0; index < value.Length; index++)
+ {
+ array[(index * 3)] = value[index].X;
+ array[(index * 3) + 1] = value[index].Y;
+ array[(index * 3) + 2] = value[index].Z;
+ }
+ GL.Uniform3(UniformIndex, array.Length, array);
+ ErrorHelper.Check("Uniform3fv");
+ }
+ #endregion
- public void SetValue(float[] value)
- {
- throw new NotImplementedException();
- }
+ #region SetValue (Vector4)
+ ///
+ /// Set a Vector4 value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Vector4 value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ GL.Uniform4(UniformIndex, value.X, value.Y, value.Z, value.W);
+ ErrorHelper.Check("Uniform4f");
+ }
+ #endregion
- public void SetValue(Vector2 value)
- {
- throw new NotImplementedException();
- }
-
- public void SetValue(Vector2[] value)
- {
- throw new NotImplementedException();
- }
-
- public void SetValue(Vector3 value)
- {
- throw new NotImplementedException();
- }
-
- public void SetValue(Vector3[] value)
- {
- throw new NotImplementedException();
- }
-
- public void SetValue(Vector4 value)
- {
- throw new NotImplementedException();
- }
-
- public void SetValue(Vector4[] value)
- {
- throw new NotImplementedException();
- }
- }
+ #region SetValue (Vector4[])
+ ///
+ /// Set a Vector4 array value to the effect parameter.
+ ///
+ /// Value for the parameter
+ public void SetValue(Vector4[] value)
+ {
+ GL.UseProgram(parentEffect.programHandle);
+ ErrorHelper.Check("UseProgram");
+ float[] array = new float[value.Length * 4];
+ for (int index = 0; index < value.Length; index++)
+ {
+ array[(index * 4)] = value[index].X;
+ array[(index * 4) + 1] = value[index].Y;
+ array[(index * 4) + 2] = value[index].Z;
+ array[(index * 4) + 3] = value[index].W;
+ }
+ GL.Uniform4(UniformIndex, array.Length, array);
+ ErrorHelper.Check("Uniform4fv");
+ }
+ #endregion
+ }
}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs
index 5875ed9e..77d126d5 100644
--- a/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs
+++ b/RenderSystems/ANX.Framework.Windows.GL3/EffectTechniqueGL3.cs
@@ -1,5 +1,7 @@
using System;
using ANX.Framework.NonXNA;
+using System.Collections.Generic;
+using ANX.Framework.Graphics;
#region License
@@ -64,8 +66,20 @@ namespace ANX.Framework.Windows.GL3
get;
private set;
}
+
+ ///
+ /// The passes of the technique.
+ ///
+ public IEnumerable Passes
+ {
+ get
+ {
+ //TODO: implement
+ yield return null;
+ }
+ }
#endregion
-
+
#region Constructor
///
/// Create a ne effect technique object.
@@ -74,15 +88,5 @@ namespace ANX.Framework.Windows.GL3
{
}
#endregion
-
-
- public System.Collections.Generic.IEnumerable Passes
- {
- get
- {
- //TODO: implement
- yield return null;
- }
- }
- }
+ }
}
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs
index 8f7e179d..5c7fceb3 100644
--- a/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs
+++ b/RenderSystems/ANX.Framework.Windows.GL3/IndexBufferGL3.cs
@@ -90,13 +90,12 @@ namespace ANX.Framework.Windows.GL3
elementSize = setElementSize;
usage = setUsage;
- // TODO: evaluate whats best
- // StaticDraw: set once, use often
- // DynamicDraw: set frequently, use repeatadly
- // StreamDraw: set every tick, use once
+ // TODO: check if dynamic buffer
+ bool isDynamicBuffer = false;
- // comment from glatzemann: I think static draw should be right HERE. DynamicDraw should be used for DynamicIndexbuffer. StreamDraw shouldn't be used I think.
- usageHint = BufferUsageHint.DynamicDraw;
+ usageHint = isDynamicBuffer ?
+ BufferUsageHint.DynamicDraw :
+ BufferUsageHint.StaticDraw;
GL.GenBuffers(1, out bufferHandle);
ErrorHelper.Check("GenBuffers");
diff --git a/RenderSystems/ANX.Framework.Windows.GL3/VertexBufferGL3.cs b/RenderSystems/ANX.Framework.Windows.GL3/VertexBufferGL3.cs
index 60c50917..6c070891 100644
--- a/RenderSystems/ANX.Framework.Windows.GL3/VertexBufferGL3.cs
+++ b/RenderSystems/ANX.Framework.Windows.GL3/VertexBufferGL3.cs
@@ -93,11 +93,12 @@ namespace ANX.Framework.Windows.GL3
usage = setUsage;
vertexCount = setVertexCount;
- // TODO: evaluate whats best
- // StaticDraw: set once, use often
- // DynamicDraw: set frequently, use repeatadly
- // StreamDraw: set every tick, use once
- usageHint = BufferUsageHint.DynamicDraw;
+ // TODO: check if dynamic buffer
+ bool isDynamicBuffer = false;
+
+ usageHint = isDynamicBuffer ?
+ BufferUsageHint.DynamicDraw :
+ BufferUsageHint.StaticDraw;
GL.GenBuffers(1, out bufferHandle);
ErrorHelper.Check("GenBuffers");
@@ -114,7 +115,7 @@ namespace ANX.Framework.Windows.GL3
if (setSize != size)
{
throw new Exception("Failed to set the vertexBuffer data. DataSize=" +
- size + " SetSize=" + setSize);
+ size + " SetSize=" + setSize);
}
}
#endregion
diff --git a/shader/GL3/SpriteBatch_GLSL.fx b/shader/GL3/SpriteBatch_GLSL.fx
index f18d79ec..00272590 100644
--- a/shader/GL3/SpriteBatch_GLSL.fx
+++ b/shader/GL3/SpriteBatch_GLSL.fx
@@ -66,8 +66,6 @@ void main( )
// Fragment Shader
//
-precission mediump float;
-
uniform sampler2D Texture;
varying vec4 diffuseColor;