From 016b7627d1bd2afc542693d2a85144d82d7a485e Mon Sep 17 00:00:00 2001 From: Flamefire Date: Mon, 22 Sep 2014 15:55:48 +0200 Subject: [PATCH] Fix for possible error with mirrored texture drawing --- Vocaluxe/Lib/Draw/COpenGL.cs | 64 +++++++++--------------------------- 1 file changed, 15 insertions(+), 49 deletions(-) diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index a6c2ff4e..39730246 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -457,7 +457,7 @@ namespace Vocaluxe.Lib.Draw const float x1 = 0; float x2 = texture.WidthRatio; - const float y1 = 0; + float y1 = 0; float y2 = texture.HeightRatio; float rx1 = rect.X; @@ -480,9 +480,9 @@ namespace Vocaluxe.Lib.Draw if (mirrored) { - float tmp = ry2; - ry2 = ry1; - ry1 = tmp; + float tmp = y2; + y2 = y1; + y1 = tmp; } GL.Begin(BeginMode.Quads); @@ -575,9 +575,9 @@ namespace Vocaluxe.Lib.Draw if (mirrored) { - float tmp = ry2; - ry2 = ry1; - ry1 = tmp; + float tmp = y2; + y2 = y1; + y1 = tmp; } GL.Begin(BeginMode.Quads); @@ -630,48 +630,28 @@ namespace Vocaluxe.Lib.Draw GL.End(); - GL.Disable(EnableCap.Blend); 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; if (!_GetTexture(textureRef, out texture)) 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 || - Math.Abs(color.A) < float.Epsilon || height <= float.Epsilon) + if (Math.Abs(rect.W) < float.Epsilon || Math.Abs(rect.H) < float.Epsilon || Math.Abs(color.A) < float.Epsilon || height <= float.Epsilon) return; - if (bounds.X > rect.X + rect.W || bounds.X + bounds.W < rect.X) - return; - - if (bounds.Y > rect.Y + rect.H || bounds.Y + bounds.H < rect.Y) - return; - - if (height > bounds.H) - height = bounds.H; + if (height > rect.H) + height = rect.H; GL.BindTexture(TextureTarget.Texture2D, texture.Name); - float x1 = (bounds.X - rect.X) / rect.W * texture.WidthRatio; - float x2 = (bounds.X + bounds.W - rect.X) / rect.W * texture.WidthRatio; - float y1 = (bounds.Y - rect.Y + rect.H - height) / rect.H * texture.HeightRatio; - float y2 = (bounds.Y + bounds.H - rect.Y) / rect.H * 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; + const float x1 = 0; + float x2 = texture.WidthRatio; + float y1 = (rect.H - height) / rect.H * texture.HeightRatio; + float y2 = texture.HeightRatio; float rx1 = rect.X; @@ -679,18 +659,6 @@ namespace Vocaluxe.Lib.Draw float ry1 = rect.Y + rect.H + space; 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.MatrixMode(MatrixMode.Texture); @@ -703,7 +671,6 @@ namespace Vocaluxe.Lib.Draw GL.Translate(-0.5f, -0.5f, 0); } - GL.Begin(BeginMode.Quads); GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); @@ -724,7 +691,6 @@ namespace Vocaluxe.Lib.Draw GL.End(); - GL.PopMatrix(); GL.Disable(EnableCap.Blend);