Fix for possible error with mirrored texture drawing
This commit is contained in:
1 parent
f5f1a91481
commit
016b7627d1
1 file changed
+15
-49
@@ -457,7 +457,7 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
const float x1 = 0;
|
const float x1 = 0;
|
||||||
float x2 = texture.WidthRatio;
|
float x2 = texture.WidthRatio;
|
||||||
const float y1 = 0;
|
float y1 = 0;
|
||||||
float y2 = texture.HeightRatio;
|
float y2 = texture.HeightRatio;
|
||||||
|
|
||||||
float rx1 = rect.X;
|
float rx1 = rect.X;
|
||||||
@@ -480,9 +480,9 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
if (mirrored)
|
if (mirrored)
|
||||||
{
|
{
|
||||||
float tmp = ry2;
|
float tmp = y2;
|
||||||
ry2 = ry1;
|
y2 = y1;
|
||||||
ry1 = tmp;
|
y1 = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
GL.Begin(BeginMode.Quads);
|
GL.Begin(BeginMode.Quads);
|
||||||
@@ -575,9 +575,9 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
if (mirrored)
|
if (mirrored)
|
||||||
{
|
{
|
||||||
float tmp = ry2;
|
float tmp = y2;
|
||||||
ry2 = ry1;
|
y2 = y1;
|
||||||
ry1 = tmp;
|
y1 = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
GL.Begin(BeginMode.Quads);
|
GL.Begin(BeginMode.Quads);
|
||||||
@@ -630,48 +630,28 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
GL.End();
|
GL.End();
|
||||||
|
|
||||||
|
|
||||||
GL.Disable(EnableCap.Blend);
|
GL.Disable(EnableCap.Blend);
|
||||||
GL.BindTexture(TextureTarget.Texture2D, 0);
|
GL.BindTexture(TextureTarget.Texture2D, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, SRectF bounds, float space, float height)
|
public void DrawTextureReflection(CTextureRef textureRef, SRectF rect, SColorF color, float space, float height)
|
||||||
{
|
{
|
||||||
COGLTexture texture;
|
COGLTexture texture;
|
||||||
if (!_GetTexture(textureRef, out texture))
|
if (!_GetTexture(textureRef, out texture))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(bounds.H) < float.Epsilon || Math.Abs(bounds.W) < float.Epsilon ||
|
if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(color.A) < float.Epsilon || height <= float.Epsilon)
|
||||||
Math.Abs(color.A) < float.Epsilon || height <= float.Epsilon)
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X)
|
if (height > rect.H)
|
||||||
return;
|
height = rect.H;
|
||||||
|
|
||||||
if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (height > bounds.H)
|
|
||||||
height = bounds.H;
|
|
||||||
|
|
||||||
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
GL.BindTexture(TextureTarget.Texture2D, texture.Name);
|
||||||
|
|
||||||
float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio;
|
const float x1 = 0;
|
||||||
float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio;
|
float x2 = texture.WidthRatio;
|
||||||
float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio;
|
float y1 = (rect.H - height) / rect.H * texture.HeightRatio;
|
||||||
float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * texture.HeightRatio;
|
float y2 = texture.HeightRatio;
|
||||||
|
|
||||||
if (x1 < 0)
|
|
||||||
x1 = 0f;
|
|
||||||
|
|
||||||
if (x2 > texture.WidthRatio)
|
|
||||||
x2 = texture.WidthRatio;
|
|
||||||
|
|
||||||
if (y1 < 0)
|
|
||||||
y1 = 0f;
|
|
||||||
|
|
||||||
if (y2 > texture.HeightRatio)
|
|
||||||
y2 = texture.HeightRatio;
|
|
||||||
|
|
||||||
|
|
||||||
float rx1 = rect.X;
|
float rx1 = rect.X;
|
||||||
@@ -679,18 +659,6 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
float ry1 = rect.Y + rect.H + space;
|
float ry1 = rect.Y + rect.H + space;
|
||||||
float ry2 = rect.Y + rect.H + space + height;
|
float ry2 = rect.Y + rect.H + space + height;
|
||||||
|
|
||||||
if (rx1 < bounds.X)
|
|
||||||
rx1 = bounds.X;
|
|
||||||
|
|
||||||
if (rx2 > bounds.X + bounds.W)
|
|
||||||
rx2 = bounds.X + bounds.W;
|
|
||||||
|
|
||||||
if (ry1 < bounds.Y + space)
|
|
||||||
ry1 = bounds.Y + space;
|
|
||||||
|
|
||||||
if (ry2 > bounds.Y + bounds.H + space + height)
|
|
||||||
ry2 = bounds.Y + bounds.H + space + height;
|
|
||||||
|
|
||||||
GL.Enable(EnableCap.Blend);
|
GL.Enable(EnableCap.Blend);
|
||||||
|
|
||||||
GL.MatrixMode(MatrixMode.Texture);
|
GL.MatrixMode(MatrixMode.Texture);
|
||||||
@@ -703,7 +671,6 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
GL.Translate(-0.5f, -0.5f, 0);
|
GL.Translate(-0.5f, -0.5f, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
GL.Begin(BeginMode.Quads);
|
GL.Begin(BeginMode.Quads);
|
||||||
|
|
||||||
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
|
GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha);
|
||||||
@@ -724,7 +691,6 @@ namespace Vocaluxe.Lib.Draw
|
|||||||
|
|
||||||
GL.End();
|
GL.End();
|
||||||
|
|
||||||
|
|
||||||
GL.PopMatrix();
|
GL.PopMatrix();
|
||||||
|
|
||||||
GL.Disable(EnableCap.Blend);
|
GL.Disable(EnableCap.Blend);
|
||||||
|
|||||||
Reference in new issue
Block a user