From 65b76df0f7517e52000908055cc98c0ad5bd9c67 Mon Sep 17 00:00:00 2001 From: Florian Kuepper Date: Fri, 27 Jul 2012 12:17:00 +0200 Subject: [PATCH] Added DrawColorReflection-Method. Buggy with OpenGL - Need some help! --- Vocaluxe/Base/CDraw.cs | 5 ++++ Vocaluxe/Lib/Draw/CDirect3D.cs | 13 +++++++++ Vocaluxe/Lib/Draw/CDrawWinForm.cs | 5 ++++ Vocaluxe/Lib/Draw/COpenGL.cs | 48 +++++++++++++++++++++++++++++++ Vocaluxe/Lib/Draw/IDraw.cs | 1 + 5 files changed, 72 insertions(+) diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index d1743b0a..e468162e 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -117,6 +117,11 @@ namespace Vocaluxe.Base _Draw.DrawColor(color, rect); } + public static void DrawColorReflection(SColorF color, SRectF rect, float space, float height) + { + _Draw.DrawColorReflection(color, rect, space, height); + } + public static void ClearScreen() { _Draw.ClearScreen(); diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 3141d237..492834c9 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -836,6 +836,19 @@ namespace Vocaluxe.Lib.Draw { DrawTexture(_BlankTexture, rect, color); } + + /// + /// Draws reflection of a colored rectangle + /// + /// The color in which the rectangle will be drawn in + /// The coordinates in a SRectF struct + /// The space between the texture and the reflection + /// The height of the reflection + public void DrawColorReflection(SColorF color, SRectF rect, float space, float height) + { + DrawTextureReflection(_BlankTexture, rect, color, rect, space, height); + } + #endregion Basic Draw Methods #region Textures #region adding diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index c94f0073..51cc0c4f 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -352,6 +352,11 @@ namespace Vocaluxe.Lib.Draw } + public void DrawColorReflection(SColorF color, SRectF rect, float space, float height) + { + + } + public STexture AddTexture(Bitmap bmp) { Bitmap bmp2 = new Bitmap(bmp); diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index 54ee1fcf..0ae4ad0f 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -661,6 +661,54 @@ namespace Vocaluxe.Lib.Draw GL.Disable(EnableCap.Blend); } + public void DrawColorReflection(SColorF color, SRectF rect, float space, float height) + { + float rx1 = rect.X; + float rx2 = rect.X + rect.W; + float ry1 = rect.Y + rect.H + space; + float ry2 = rect.Y + rect.H + space + height; + + if (rx1 < rect.X) + rx1 = rect.X; + + if (rx2 > rect.X + rect.W) + rx2 = rect.X + rect.W; + + if (ry1 < rect.Y + space) + ry1 = rect.Y + space; + + if (ry2 > rect.Y + rect.H + space + height) + ry2 = rect.Y + rect.H + space + height; + + GL.Enable(EnableCap.Blend); + + if (rect.Rotation != 0f) + { + GL.Translate(0.5f, 0.5f, 0); + GL.Rotate(-rect.Rotation, 0f, 0f, 1f); + GL.Translate(-0.5f, -0.5f, 0); + } + + GL.Begin(BeginMode.Quads); + + GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); + GL.Vertex3(rx2, ry1, rect.Z + CGraphics.ZOffset); + + GL.Color4(color.R, color.G, color.B, 0f); + GL.Vertex3(rx2, ry2, rect.Z + CGraphics.ZOffset); + + GL.Color4(color.R, color.G, color.B, 0f); + GL.Vertex3(rx1, ry2, rect.Z + CGraphics.ZOffset); + + GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); + GL.Vertex3(rx1, ry1, rect.Z + CGraphics.ZOffset); + + GL.End(); + + GL.Disable(EnableCap.Blend); + + } + #endregion Basic Draw Methods #region Textures diff --git a/Vocaluxe/Lib/Draw/IDraw.cs b/Vocaluxe/Lib/Draw/IDraw.cs index 2f8bbc82..9a7bf1d6 100644 --- a/Vocaluxe/Lib/Draw/IDraw.cs +++ b/Vocaluxe/Lib/Draw/IDraw.cs @@ -125,6 +125,7 @@ namespace Vocaluxe.Lib.Draw // Basic Draw Methods void DrawLine(int a, int r, int g, int b, int w, int x1, int y1, int x2, int y2); void DrawColor(SColorF color, SRectF rect); + void DrawColorReflection(SColorF color, SRectF rect, float space, float height); void ClearScreen(); STexture CopyScreen();