Going through TODOs in OpenGL render system, and implemented

most of the EffectParameter.SetData overloads.
This commit is contained in:
SND\AstrorEnales_cp 2011-12-27 11:03:03 +00:00
parent 746582483d
commit ad4fc131de
7 changed files with 294 additions and 131 deletions

View File

@ -215,7 +215,7 @@ namespace ANX.Framework.Windows.GL3
BlendFactor.A * DatatypesMapping.ColorMultiplier); BlendFactor.A * DatatypesMapping.ColorMultiplier);
ErrorHelper.Check("BlendColor"); ErrorHelper.Check("BlendColor");
// TODO: multi sample mask // TODO: multi sample mask
} }
#endregion #endregion

View File

@ -108,7 +108,7 @@ namespace ANX.Framework.Windows.GL3
} }
#endregion #endregion
#region Parameters (TODO) #region Parameters
public IEnumerable<EffectParameter> Parameters public IEnumerable<EffectParameter> Parameters
{ {
get get

View File

@ -115,6 +115,62 @@ namespace ANX.Framework.Windows.GL3
} }
#endregion #endregion
#region SetValue (Matrix[])
/// <summary>
/// Set a Matrix array value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
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)
/// <summary>
/// Set a Quaternion value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(Quaternion value)
{
throw new NotImplementedException();
}
#endregion
#region SetValue (Quaternion[]) (TODO)
/// <summary>
/// Set a Quaternion array value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(Quaternion[] value)
{
throw new NotImplementedException();
}
#endregion
#region SetValue (Texture) #region SetValue (Texture)
private Texture textureCache = null; private Texture textureCache = null;
/// <summary> /// <summary>
@ -130,8 +186,6 @@ namespace ANX.Framework.Windows.GL3
{ {
// TODO: multiple texture units // TODO: multiple texture units
TextureUnit textureUnit = TextureUnit.Texture0; TextureUnit textureUnit = TextureUnit.Texture0;
GL.Enable(EnableCap.Texture2D);
ErrorHelper.Check("Enable");
GL.ActiveTexture(textureUnit); GL.ActiveTexture(textureUnit);
ErrorHelper.Check("ActiveTexture"); ErrorHelper.Check("ActiveTexture");
int handle = (value.NativeTexture as Texture2DGL3).NativeHandle; int handle = (value.NativeTexture as Texture2DGL3).NativeHandle;
@ -144,80 +198,187 @@ namespace ANX.Framework.Windows.GL3
} }
#endregion #endregion
#region SetValue (bool) (TODO)
/// <summary>
/// Set a bool value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(bool value) public void SetValue(bool value)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion
#region SetValue (bool[]) (TODO)
/// <summary>
/// Set a bool array value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(bool[] value) public void SetValue(bool[] value)
{ {
throw new NotImplementedException(); throw new NotImplementedException();
} }
#endregion
#region SetValue (int)
/// <summary>
/// Set an int value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(int value) public void SetValue(int value)
{ {
throw new NotImplementedException(); GL.UseProgram(parentEffect.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform1(UniformIndex, value);
ErrorHelper.Check("Uniform1i");
} }
#endregion
#region SetValue (int[])
/// <summary>
/// Set an int array value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(int[] value) public void SetValue(int[] value)
{ {
throw new NotImplementedException(); GL.UseProgram(parentEffect.programHandle);
} ErrorHelper.Check("UseProgram");
GL.Uniform1(UniformIndex, value.Length, value);
public void SetValue(Matrix[] value) ErrorHelper.Check("Uniform1iv");
{
throw new NotImplementedException();
}
public void SetValue(Quaternion value)
{
throw new NotImplementedException();
}
public void SetValue(Quaternion[] value)
{
throw new NotImplementedException();
} }
#endregion
#region SetValue (float)
/// <summary>
/// Set a float value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(float value) public void SetValue(float value)
{ {
throw new NotImplementedException(); GL.UseProgram(parentEffect.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform1(UniformIndex, value);
ErrorHelper.Check("Uniform1f");
} }
#endregion
#region SetValue (float[])
/// <summary>
/// Set a float array value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(float[] value) public void SetValue(float[] value)
{ {
throw new NotImplementedException(); GL.UseProgram(parentEffect.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform1(UniformIndex, value.Length, value);
ErrorHelper.Check("Uniform1fv");
} }
#endregion
#region SetValue (Vector2)
/// <summary>
/// Set a Vector2 value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector2 value) public void SetValue(Vector2 value)
{ {
throw new NotImplementedException(); GL.UseProgram(parentEffect.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform2(UniformIndex, value.X, value.Y);
ErrorHelper.Check("Uniform2f");
} }
#endregion
#region SetValue (Vector2[])
/// <summary>
/// Set a Vector2 array value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector2[] value) public void SetValue(Vector2[] value)
{ {
throw new NotImplementedException(); 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
#region SetValue (Vector3)
/// <summary>
/// Set a Vector3 value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector3 value) public void SetValue(Vector3 value)
{ {
throw new NotImplementedException(); GL.UseProgram(parentEffect.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform3(UniformIndex, value.X, value.Y, value.Z);
ErrorHelper.Check("Uniform3f");
} }
#endregion
#region SetValue (Vector3[])
/// <summary>
/// Set a Vector3 array value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector3[] value) public void SetValue(Vector3[] value)
{ {
throw new NotImplementedException(); 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
#region SetValue (Vector4)
/// <summary>
/// Set a Vector4 value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector4 value) public void SetValue(Vector4 value)
{ {
throw new NotImplementedException(); GL.UseProgram(parentEffect.programHandle);
ErrorHelper.Check("UseProgram");
GL.Uniform4(UniformIndex, value.X, value.Y, value.Z, value.W);
ErrorHelper.Check("Uniform4f");
} }
#endregion
#region SetValue (Vector4[])
/// <summary>
/// Set a Vector4 array value to the effect parameter.
/// </summary>
/// <param name="value">Value for the parameter</param>
public void SetValue(Vector4[] value) public void SetValue(Vector4[] value)
{ {
throw new NotImplementedException(); 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
} }
} }

View File

@ -1,5 +1,7 @@
using System; using System;
using ANX.Framework.NonXNA; using ANX.Framework.NonXNA;
using System.Collections.Generic;
using ANX.Framework.Graphics;
#region License #region License
@ -64,6 +66,18 @@ namespace ANX.Framework.Windows.GL3
get; get;
private set; private set;
} }
/// <summary>
/// The passes of the technique.
/// </summary>
public IEnumerable<EffectPass> Passes
{
get
{
//TODO: implement
yield return null;
}
}
#endregion #endregion
#region Constructor #region Constructor
@ -74,15 +88,5 @@ namespace ANX.Framework.Windows.GL3
{ {
} }
#endregion #endregion
public System.Collections.Generic.IEnumerable<Graphics.EffectPass> Passes
{
get
{
//TODO: implement
yield return null;
}
}
} }
} }

View File

@ -90,13 +90,12 @@ namespace ANX.Framework.Windows.GL3
elementSize = setElementSize; elementSize = setElementSize;
usage = setUsage; usage = setUsage;
// TODO: evaluate whats best // TODO: check if dynamic buffer
// StaticDraw: set once, use often bool isDynamicBuffer = false;
// DynamicDraw: set frequently, use repeatadly
// StreamDraw: set every tick, use once
// 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 = isDynamicBuffer ?
usageHint = BufferUsageHint.DynamicDraw; BufferUsageHint.DynamicDraw :
BufferUsageHint.StaticDraw;
GL.GenBuffers(1, out bufferHandle); GL.GenBuffers(1, out bufferHandle);
ErrorHelper.Check("GenBuffers"); ErrorHelper.Check("GenBuffers");

View File

@ -93,11 +93,12 @@ namespace ANX.Framework.Windows.GL3
usage = setUsage; usage = setUsage;
vertexCount = setVertexCount; vertexCount = setVertexCount;
// TODO: evaluate whats best // TODO: check if dynamic buffer
// StaticDraw: set once, use often bool isDynamicBuffer = false;
// DynamicDraw: set frequently, use repeatadly
// StreamDraw: set every tick, use once usageHint = isDynamicBuffer ?
usageHint = BufferUsageHint.DynamicDraw; BufferUsageHint.DynamicDraw :
BufferUsageHint.StaticDraw;
GL.GenBuffers(1, out bufferHandle); GL.GenBuffers(1, out bufferHandle);
ErrorHelper.Check("GenBuffers"); ErrorHelper.Check("GenBuffers");

View File

@ -66,8 +66,6 @@ void main( )
// Fragment Shader // Fragment Shader
// //
precission mediump float;
uniform sampler2D Texture; uniform sampler2D Texture;
varying vec4 diffuseColor; varying vec4 diffuseColor;