private void RenderCorner(DoubleRect box, bool top, bool left) { var corner = GetCorner(box, top, left); var rect = new DoubleRect( GameDrawingMatrix.ScreenCoordD(corner.Vector), new Vector2d(corner.Width * game.Track.Zoom, corner.Height * game.Track.Zoom)); GameRenderer.RenderRoundedRectangle(rect, Color.CornflowerBlue, 2, false); }
public void Render(Track track, bool colors, int knobstate, bool gwells) { using (new GLEnableCap(EnableCap.Texture2D)) { GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GameDrawingMatrix.Enter(); try { bool r_knobs = knobstate == 1; bool r_knobs_red = knobstate == 2; bool r_coloredline = colors; bool r_blackline = !colors; if (RequiresUpdate || _prepped_knobs != r_knobs || _prepped_knobs_red != r_knobs_red || r_coloredline != _prepped_coloredline || r_blackline != _prepped_blackline || (game.HitTest && game.Track.Animating && !track.AllCollidedLines.SetEquals(collisions))) { lock (SyncRoot) { RequiresUpdate = false; lock (track.AllCollidedLines) { if (game.HitTest) { collisions = new HashSet <int>(track.AllCollidedLines); } } _vao.ClearIndices(); _prepped_blackline = r_blackline; _prepped_coloredline = r_coloredline; _prepped_knobs = r_knobs; _prepped_knobs_red = r_knobs_red; _prepped_gwells = gwells; foreach (var line in lines) { AddLineIndices(line); } } } _vao.Draw(PrimitiveType.Triangles); } finally { GameDrawingMatrix.Exit(); } } }
public void Render(bool colors) { using (new GLEnableCap(EnableCap.Texture2D)) { GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GameDrawingMatrix.Enter(); try { if (colors) { _editorvbo.Draw(); } else { _playbackbvo.Draw(); } RequiresUpdate = false; } finally { GameDrawingMatrix.Exit(); } } }
public static void DrawTrackLine(StandardLine l, Color color, bool drawwell, bool drawcolor, bool drawknobs, bool redknobs = false) { color = Color.FromArgb(255, color); var thickness = 2; Color color2; var type = l.GetLineType(); switch (type) { case LineType.Blue: color2 = Color.FromArgb(0, 0x66, 0xFF); break; case LineType.Red: color2 = Color.FromArgb(0xCC, 0, 0); break; default: throw new Exception("Rendering Invalid Line"); } if (drawcolor) { var loc3 = l.Perpendicular.X > 0 ? (Math.Ceiling(l.Perpendicular.X)) : (Math.Floor(l.Perpendicular.X)); var loc4 = l.Perpendicular.Y > 0 ? (Math.Ceiling(l.Perpendicular.Y)) : (Math.Floor(l.Perpendicular.Y)); if (type == LineType.Red) { var redline = l as RedLine; GameDrawingMatrix.Enter(); GL.Color3(color2); GL.Begin(PrimitiveType.Triangles); var basepos = l.Position2; for (int ix = 0; ix < redline.Multiplier; ix++) { var angle = MathHelper.RadiansToDegrees(Math.Atan2(l.diff.Y, l.diff.X)); Turtle t = new Turtle(l.Position2); var basex = 8 + (ix * 2); t.Move(angle, -basex); GL.Vertex2(new Vector2((float)t.X, (float)t.Y)); t.Move(90, l.inv ? -8 : 8); GL.Vertex2(new Vector2((float)t.X, (float)t.Y)); t.Point = l.Position2; t.Move(angle, -(ix * 2)); GL.Vertex2(new Vector2((float)t.X, (float)t.Y)); } GL.End(); GameDrawingMatrix.Exit(); } RenderRoundedLine(new Vector2d(l.Position.X + loc3, l.Position.Y + loc4), new Vector2d(l.Position2.X + loc3, l.Position2.Y + loc4), color2, thickness); } RenderRoundedLine(l.Position, l.Position2, color, thickness, drawknobs, redknobs); if (drawwell) { using (new GLEnableCap(EnableCap.Blend)) { GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); GameDrawingMatrix.Enter(); GL.Begin(PrimitiveType.Quads); GL.Color4(new Color4(150, 150, 150, 150)); var rect = StaticRenderer.GenerateThickLine((Vector2)l.Position, (Vector2)l.Position2, (float)(StandardLine.Zone * 2)); GL.Vertex2(l.Position); GL.Vertex2(l.Position2); GL.Vertex2(rect[l.inv ? 2 : 1]); GL.Vertex2(rect[l.inv ? 3 : 0]); GL.End(); GL.PopMatrix(); } } }
public static void DrawScarf(DynamicLine[] lines, float opacity) { GLEnableCap blend = null; if (opacity < 1) { blend = new GLEnableCap(EnableCap.Blend); GL.BlendFunc(BlendingFactorSrc.SrcAlpha, BlendingFactorDest.OneMinusSrcAlpha); } GameDrawingMatrix.Enter(); VAO scarf = new VAO(false, true);//VAO does not need disposing, it does not allocate a buffer bool t = false; for (int i = 0; i < lines.Length; i++) { Color c = Color.FromArgb((byte)(255 * opacity), 209, 1, 1); var alt = Color.FromArgb((byte)(255 * opacity), 255, 100, 100); var diff = lines[i].Position2 - lines[i].Position; var dangle = MathHelper.RadiansToDegrees(Math.Atan2(diff.Y, diff.X)) + 90; Vector2d q1; Vector2d q2; Vector2d q3; Vector2d q4; float size = 2; if (i == 0) { var diff2 = lines[i + 1].Position2 - lines[i + 1].Position; var dangle2 = MathHelper.RadiansToDegrees(Math.Atan2(diff2.Y, diff2.X)) + 90; Turtle turtle = new Turtle(lines[i].Position); turtle.Move(dangle2, -(size / 2)); q1 = turtle.Point; turtle.Move(0, size); q2 = turtle.Point; turtle.Point = lines[i].Position2; turtle.Move(dangle, size / 2); q3 = turtle.Point; turtle.Move(0, -size); q4 = turtle.Point; } else { var diff2 = lines[i - 1].Position2 - lines[i - 1].Position; var dangle2 = MathHelper.RadiansToDegrees(Math.Atan2(diff2.Y, diff2.X)) + 90; Turtle turtle = new Turtle(lines[i].Position); turtle.Move(dangle2, -(size / 2)); q1 = turtle.Point; turtle.Move(0, size); q2 = turtle.Point; turtle.Point = lines[i].Position2; turtle.Move(dangle, size / 2); q3 = turtle.Point; turtle.Move(0, -size); q4 = turtle.Point; } scarf.AddVertex(new Vertex((Vector2)q1, t ? c : alt)); scarf.AddVertex(new Vertex((Vector2)q2, t ? c : alt)); scarf.AddVertex(new Vertex((Vector2)q3, t ? c : alt)); scarf.AddVertex(new Vertex((Vector2)q4, t ? c : alt)); t = !t; } scarf.Draw(PrimitiveType.Quads); GameDrawingMatrix.Exit(); if (blend != null) { blend.Dispose(); } }