fixed issue #475 (OpenGL3 RenderSystem SpriteBatch wrong colors)
This commit is contained in:
parent
57314d888a
commit
72f8e735fb
@ -190,28 +190,30 @@ namespace ANX.Framework.Windows.GL3
|
||||
{
|
||||
IsBound = true;
|
||||
|
||||
GL.BlendEquationSeparate(
|
||||
TranslateBlendFunction(ColorBlendFunction),
|
||||
TranslateBlendFunction(AlphaBlendFunction));
|
||||
ErrorHelper.Check("BlendEquationSeparate");
|
||||
GL.Enable(EnableCap.Blend);
|
||||
|
||||
GL.BlendFuncSeparate(
|
||||
TranslateBlendSrc(ColorSourceBlend),
|
||||
TranslateBlendDest(ColorDestinationBlend),
|
||||
TranslateBlendSrc(AlphaSourceBlend),
|
||||
TranslateBlendDest(AlphaDestinationBlend));
|
||||
ErrorHelper.Check("BlendFuncSeparate");
|
||||
GL.BlendEquationSeparate(
|
||||
TranslateBlendFunction(ColorBlendFunction),
|
||||
TranslateBlendFunction(AlphaBlendFunction));
|
||||
ErrorHelper.Check("BlendEquationSeparate");
|
||||
|
||||
SetColorWriteChannel(0, ColorWriteChannels);
|
||||
SetColorWriteChannel(1, ColorWriteChannels1);
|
||||
SetColorWriteChannel(2, ColorWriteChannels2);
|
||||
SetColorWriteChannel(3, ColorWriteChannels3);
|
||||
GL.BlendFuncSeparate(
|
||||
TranslateBlendSrc(ColorSourceBlend),
|
||||
TranslateBlendDest(ColorDestinationBlend),
|
||||
TranslateBlendSrc(AlphaSourceBlend),
|
||||
TranslateBlendDest(AlphaDestinationBlend));
|
||||
ErrorHelper.Check("BlendFuncSeparate");
|
||||
|
||||
GL.BlendColor(BlendFactor.R * DatatypesMapping.ColorMultiplier,
|
||||
BlendFactor.G * DatatypesMapping.ColorMultiplier,
|
||||
BlendFactor.B * DatatypesMapping.ColorMultiplier,
|
||||
BlendFactor.A * DatatypesMapping.ColorMultiplier);
|
||||
ErrorHelper.Check("BlendColor");
|
||||
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");
|
||||
|
||||
// TODO: multi sample mask
|
||||
}
|
||||
@ -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");
|
||||
@ -358,24 +356,25 @@ namespace ANX.Framework.Windows.GL3
|
||||
/// <returns>OpenGL Blend Equation Mode.</returns>
|
||||
private BlendEquationMode TranslateBlendFunction(BlendFunction func)
|
||||
{
|
||||
switch (func)
|
||||
{
|
||||
default:
|
||||
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");
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
|
@ -158,7 +158,7 @@ namespace ANX.Framework.Windows.GL3
|
||||
nativeWindowInfo = Utilities.CreateWindowsWindowInfo(
|
||||
presentationParameters.DeviceWindowHandle);
|
||||
|
||||
GraphicsMode graphicsMode = new GraphicsMode(
|
||||
GraphicsMode graphicsMode = new GraphicsMode(
|
||||
DatatypesMapping.SurfaceToColorFormat(
|
||||
presentationParameters.BackBufferFormat),
|
||||
depth, stencil,
|
||||
|
@ -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")]
|
||||
|
@ -125,7 +125,7 @@ namespace ANX.Framework.Windows.GL3
|
||||
|
||||
int wrapMode = (int)All.ClampToEdge;
|
||||
int filter = (int)(mipCount > 1 ? All.LinearMipmapLinear : All.Linear);
|
||||
|
||||
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
TextureParameterName.TextureWrapS, wrapMode);
|
||||
GL.TexParameter(TextureTarget.Texture2D,
|
||||
@ -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,
|
||||
@ -186,9 +186,9 @@ namespace ANX.Framework.Windows.GL3
|
||||
}
|
||||
else
|
||||
{
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, nativeFormat,
|
||||
width, height, 0, (PixelFormat)nativeFormat,
|
||||
PixelType.UnsignedByte, dataPointer);
|
||||
GL.TexImage2D(TextureTarget.Texture2D, 0, nativeFormat,
|
||||
width, height, 0, (PixelFormat)nativeFormat,
|
||||
PixelType.UnsignedByte, dataPointer);
|
||||
#if DEBUG
|
||||
ErrorHelper.Check("TexImage2D Format=" + nativeFormat);
|
||||
#endif
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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>
|
||||
|
Loading…
x
Reference in New Issue
Block a user