fixed issue #475 (OpenGL3 RenderSystem SpriteBatch wrong colors)

This commit is contained in:
Glatzemann 2011-12-05 09:39:07 +00:00
parent 57314d888a
commit 72f8e735fb
6 changed files with 58 additions and 52 deletions

View File

@ -190,6 +190,8 @@ namespace ANX.Framework.Windows.GL3
{
IsBound = true;
GL.Enable(EnableCap.Blend);
GL.BlendEquationSeparate(
TranslateBlendFunction(ColorBlendFunction),
TranslateBlendFunction(AlphaBlendFunction));
@ -245,14 +247,10 @@ namespace ANX.Framework.Windows.GL3
/// <param name="channels">Mask channels to enable.</param>
private void SetColorWriteChannel(int index, ColorWriteChannels channels)
{
bool r = (channels == Graphics.ColorWriteChannels.All ||
channels == Graphics.ColorWriteChannels.Red);
bool g = (channels == Graphics.ColorWriteChannels.All ||
channels == Graphics.ColorWriteChannels.Green);
bool b = (channels == Graphics.ColorWriteChannels.All ||
channels == Graphics.ColorWriteChannels.Blue);
bool a = (channels == Graphics.ColorWriteChannels.All ||
channels == Graphics.ColorWriteChannels.Alpha);
bool r = (channels & Graphics.ColorWriteChannels.Red) == Graphics.ColorWriteChannels.Red;
bool g = (channels & Graphics.ColorWriteChannels.Green) == Graphics.ColorWriteChannels.Green;
bool b = (channels & Graphics.ColorWriteChannels.Blue) == Graphics.ColorWriteChannels.Blue;
bool a = (channels & Graphics.ColorWriteChannels.Alpha) == Graphics.ColorWriteChannels.Alpha;
GL.ColorMask(index, r, g, b, a);
ErrorHelper.Check("ColorMask");
@ -360,7 +358,6 @@ namespace ANX.Framework.Windows.GL3
{
switch (func)
{
default:
case BlendFunction.Add:
return BlendEquationMode.FuncAdd;
@ -376,6 +373,8 @@ namespace ANX.Framework.Windows.GL3
case BlendFunction.Max:
return BlendEquationMode.Max;
}
throw new ArgumentException("don't know how to translate BlendFunction '" + func.ToString() + "' to BlendEquationMode");
}
#endregion
}

View File

@ -32,7 +32,7 @@ using System.Runtime.InteropServices;
// Sie können alle Werte angeben oder die standardmäßigen Build- und Revisionsnummern
// übernehmen, indem Sie "*" eingeben:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("0.5.5.0")]
[assembly: AssemblyFileVersion("0.5.5.0")]
[assembly: AssemblyVersion("0.5.6.0")]
[assembly: AssemblyFileVersion("0.5.6.0")]
[assembly: InternalsVisibleTo("ANX.Framework.ContentPipeline")]

View File

@ -147,7 +147,7 @@ namespace ANX.Framework.Windows.GL3
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data)
where T : struct
{
SetData<T>(graphicsDevice, data, 0, data.Length);
SetData<T>(graphicsDevice, 0, data, 0, data.Length);
}
public void SetData<T>(GraphicsDevice graphicsDevice, T[] data,

View File

@ -215,7 +215,7 @@ namespace ANX.Framework.Windows.GL3
GL.EnableVertexAttribArray(col);
ErrorHelper.Check("EnableVertexAttribArray col");
GL.VertexAttribPointer(col, 4, VertexAttribPointerType.UnsignedByte,
false, vertexDeclaration.VertexStride, element.Offset);
true, vertexDeclaration.VertexStride, element.Offset);
ErrorHelper.Check("VertexAttribPointer col");
break;

View File

@ -108,10 +108,17 @@ namespace WindowsGame1
// Create a new SpriteBatch, which can be used to draw textures.
spriteBatch = new SpriteBatch(GraphicsDevice);
//this.texture = Content.Load<Texture2D>(@"Textures/DotColor4x4");
//this.alternateTexture = Content.Load<Texture2D>(@"Textures/DotColor4x4");
this.alternateTexture = Content.Load<Texture2D>(@"Textures/DotWhiteTopLeft5x5");
this.texture = Content.Load<Texture2D>(@"Textures/ANX.logo");
//this.texture = new Texture2D(GraphicsDevice, 64, 64);
//this.alternateTexture = new Texture2D(GraphicsDevice, 64, 64);
//Color[] color = new Color[this.alternateTexture.Width * this.alternateTexture.Height];
//for (int i = 0; i < color.Length; i++)
//{
// color[i] = new Color(1.0f, 1.0f, 0, 0.5f);
//}
//this.alternateTexture.SetData<Color>(color);
}
/// <summary>