From 926dda735003513629c4279e7768a6c5e1135b22 Mon Sep 17 00:00:00 2001 From: Flamefire Date: Wed, 24 Sep 2014 18:54:23 +0200 Subject: [PATCH] Remove DrawLines (was not working in D3D and can actually be replaced by narrow DrawRects) --- Vocaluxe/Base/CDraw.cs | 34 ------------------------ Vocaluxe/Base/CMain.cs | 5 ---- Vocaluxe/Lib/Draw/CDirect3D.cs | 22 --------------- Vocaluxe/Lib/Draw/CDrawWinForm.cs | 5 ---- Vocaluxe/Lib/Draw/COpenGL.cs | 15 +---------- Vocaluxe/Lib/Draw/IDraw.cs | 1 - VocaluxeLib/IBasic.cs | 1 - VocaluxeLib/Menu/SingNotes/CSingNotes.cs | 11 ++++---- 8 files changed, 6 insertions(+), 88 deletions(-) diff --git a/Vocaluxe/Base/CDraw.cs b/Vocaluxe/Base/CDraw.cs index 5b10b7a0..2640084a 100644 --- a/Vocaluxe/Base/CDraw.cs +++ b/Vocaluxe/Base/CDraw.cs @@ -279,40 +279,6 @@ namespace Vocaluxe.Base return _Draw.GetTextureCount(); } - /// - /// Draws a simple line - /// - /// - /// Width of the line - /// - /// - /// - /// - public static void DrawLine(SColorF color, float w, int x1, int y1, int x2, int y2) - { - _Draw.DrawLine(color, w, x1, y1, x2, y2); - } - - /// - /// Draws the outline of a rectangle - /// - /// - /// - /// Width of the lines - public static void DrawRectOutline(SColorF color, SRectF rect, float thickness) - { - if (thickness <= 0f) - return; - int x1 = (int)rect.X; - int x2 = (int)(rect.X + rect.W); - int y1 = (int)rect.Y; - int y2 = (int)(rect.Y + rect.H); - _Draw.DrawLine(color, thickness, x1, y1, x2, y1); - _Draw.DrawLine(color, thickness, x2, y1, x2, y2); - _Draw.DrawLine(color, thickness, x2, y2, x1, y2); - _Draw.DrawLine(color, thickness, x1, y2, x1, y1); - } - /// /// Draws a simple (filled) rectangle with the given color /// diff --git a/Vocaluxe/Base/CMain.cs b/Vocaluxe/Base/CMain.cs index 536d0a23..ea80aec5 100644 --- a/Vocaluxe/Base/CMain.cs +++ b/Vocaluxe/Base/CMain.cs @@ -448,11 +448,6 @@ namespace Vocaluxe.Base CDraw.RemoveTexture(ref texture); } - public void DrawLine(SColorF color, float w, int x1, int y1, int x2, int y2) - { - CDraw.DrawLine(color, w, x1, y1, x2, y2); - } - public void DrawRect(SColorF color, SRectF rect) { CDraw.DrawRect(color, rect); diff --git a/Vocaluxe/Lib/Draw/CDirect3D.cs b/Vocaluxe/Lib/Draw/CDirect3D.cs index 430e4a54..682905bc 100644 --- a/Vocaluxe/Lib/Draw/CDirect3D.cs +++ b/Vocaluxe/Lib/Draw/CDirect3D.cs @@ -533,28 +533,6 @@ namespace Vocaluxe.Lib.Draw } } - /// - /// Draws a line - /// - /// - /// The width of the line - /// The start x-value - /// The start y-value - /// The end x-value - /// The end y-value - public void DrawLine(SColorF color, float w, int x1, int y1, int x2, int y2) - { - var lineVector = new Vector2[] {new Vector2(x1, y1), new Vector2(x2, y2)}; - using (var line = new Line(_Device)) - { - line.Antialias = true; - line.Width = w; - line.Begin(); - line.Draw(lineVector, new Color4(color.AsColor())); - line.End(); - } - } - /// /// Draws a colored rectangle /// diff --git a/Vocaluxe/Lib/Draw/CDrawWinForm.cs b/Vocaluxe/Lib/Draw/CDrawWinForm.cs index efec130f..0c9cb5c4 100644 --- a/Vocaluxe/Lib/Draw/CDrawWinForm.cs +++ b/Vocaluxe/Lib/Draw/CDrawWinForm.cs @@ -308,11 +308,6 @@ namespace Vocaluxe.Lib.Draw _Backbuffer.Save(file, ImageFormat.Png); } - public void DrawLine(SColorF color, float w, int x1, int y1, int x2, int y2) - { - _G.DrawLine(new Pen(color.AsColor(), w), new Point(x1, y1), new Point(x2, y2)); - } - public void DrawRect(SColorF color, SRectF rect) {} public void DrawRectReflection(SColorF color, SRectF rect, float space, float height) {} diff --git a/Vocaluxe/Lib/Draw/COpenGL.cs b/Vocaluxe/Lib/Draw/COpenGL.cs index c66e442a..94f0b63d 100644 --- a/Vocaluxe/Lib/Draw/COpenGL.cs +++ b/Vocaluxe/Lib/Draw/COpenGL.cs @@ -330,26 +330,13 @@ namespace Vocaluxe.Lib.Draw } } - public void DrawLine(SColorF color, float w, int x1, int y1, int x2, int y2) - { - GL.Enable(EnableCap.Blend); - GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); - GL.LineWidth(w); - GL.Begin(BeginMode.Lines); - GL.Vertex3(x1, y1, CGraphics.ZOffset); - GL.Vertex3(x2, y2, CGraphics.ZOffset); - GL.End(); - - GL.Disable(EnableCap.Blend); - } - public void DrawRect(SColorF color, SRectF rect) { GL.Enable(EnableCap.Blend); GL.Color4(color.R, color.G, color.B, color.A * CGraphics.GlobalAlpha); GL.Begin(BeginMode.Quads); - GL.MatrixMode(MatrixMode.Texture); + GL.MatrixMode(MatrixMode.Color); GL.PushMatrix(); if (Math.Abs(rect.Rotation) > 0.001) { diff --git a/Vocaluxe/Lib/Draw/IDraw.cs b/Vocaluxe/Lib/Draw/IDraw.cs index 7b4b37ad..0b2421ff 100644 --- a/Vocaluxe/Lib/Draw/IDraw.cs +++ b/Vocaluxe/Lib/Draw/IDraw.cs @@ -49,7 +49,6 @@ namespace Vocaluxe.Lib.Draw void RemoveTexture(ref CTextureRef texture); // Basic Draw Methods - void DrawLine(SColorF color, float w, int x1, int y1, int x2, int y2); void DrawRect(SColorF color, SRectF rect); void DrawRectReflection(SColorF color, SRectF rect, float space, float height); diff --git a/VocaluxeLib/IBasic.cs b/VocaluxeLib/IBasic.cs index 204a9b96..2c2d285a 100644 --- a/VocaluxeLib/IBasic.cs +++ b/VocaluxeLib/IBasic.cs @@ -152,7 +152,6 @@ namespace VocaluxeLib void DrawRect(SColorF color, SRectF rect); void DrawRectReflection(SColorF color, SRectF rect, float space, float height); - void DrawLine(SColorF color, float w, int x1, int y1, int x2, int y2); } public interface IGraphics diff --git a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs index a619af79..64b9c4ac 100644 --- a/VocaluxeLib/Menu/SingNotes/CSingNotes.cs +++ b/VocaluxeLib/Menu/SingNotes/CSingNotes.cs @@ -539,14 +539,13 @@ namespace VocaluxeLib.Menu.SingNotes CBase.Drawing.DrawTexture(noteBackgroundEnd, new SRectF(r.X + r.W - dx, r.Y, dx, r.H, r.Z), col); } - protected void _DrawNoteLines(SRectF rect, SColorF color) + private static void _DrawNoteLines(SRectF rect, SColorF color) { - int x1 = (int)rect.X; - int x2 = (int)(rect.X + rect.W); - for (int i = 0; i < CBase.Settings.GetNumNoteLines() - 1; i++) + SRectF lineRect = new SRectF(rect) {H = 1.5f}; + for (int i = 0; i < CBase.Settings.GetNumNoteLines(); i++) { - int y = (int)(rect.Y + rect.H / CBase.Settings.GetNumNoteLines() * (i + 1)); - CBase.Drawing.DrawLine(color, 1, x1, y, x2, y); + lineRect.Y = rect.Y + rect.H / CBase.Settings.GetNumNoteLines() * (i + 1); + CBase.Drawing.DrawRect(color, lineRect); } }