public void Render2D() { if (_rect.IsEmpty) { var te = _printer.Measure(_text, SystemFonts.MessageBoxFont, new RectangleF(0, 0, Viewport.Width, Viewport.Height)); _rect = te.BoundingBox; _rect.X += 5; _rect.Y += 2; _rect.Width += 5; _rect.Height += 2; } GL.Disable(EnableCap.CullFace); _printer.Begin(); if (_showing) { GL.Begin(PrimitiveType.Quads); GL.Color3(Viewport is Viewport3D ? View.ViewportBackground : Grid.Background); GL.Vertex2(0, 0); GL.Vertex2(_rect.Right, 0); GL.Vertex2(_rect.Right, _rect.Bottom); GL.Vertex2(0, _rect.Bottom); GL.End(); } _printer.Print(_text, SystemFonts.MessageBoxFont, _showing ? Color.White : Grid.GridLines, _rect); _printer.End(); GL.Enable(EnableCap.CullFace); }
public void FillTriangle(RectangleF dstRect) { DrawBegin(dstRect); GL.Begin(PrimitiveType.Triangles); GL.Vertex2(0.0f, dstRect.Height); GL.Vertex2(dstRect.Width * 0.5f, 0); GL.Vertex2(dstRect.Width, dstRect.Height); GL.End(); DrawEnd(); }
public void DrawTriangle(RectangleF dstRect) { GL.LineWidth(1.0f); DrawBegin(dstRect); GL.Begin(PrimitiveType.LineLoop); GL.Vertex2(0.0f, dstRect.Height); GL.Vertex2(dstRect.Width * 0.5f, 0); GL.Vertex2(dstRect.Width, dstRect.Height); GL.End(); DrawEnd(); }
public void FillRect(RectangleF dstRect) { DrawBegin(dstRect); GL.Begin(PrimitiveType.Quads); GL.Vertex2(0, 0); GL.Vertex2(dstRect.Width, 0); GL.Vertex2(dstRect.Width, dstRect.Height); GL.Vertex2(0, dstRect.Height); GL.End(); DrawEnd(); }
public void DrawLine(Vector2 from, Vector2 to) { GL.LineWidth(1.0f); var minX = Math.Min(from.X, to.X); var minY = Math.Min(from.Y, to.Y); var minV = new Vector2(minX, minY); var sx = Math.Abs(from.X - to.X); var sy = Math.Abs(from.Y - to.Y); DrawBegin(new RectangleF(minX, minY, sx, sy)); GL.Begin(PrimitiveType.Lines); GL.Vertex2(from - minV); GL.Vertex2(to - minV); GL.End(); DrawEnd(); }
public void FillEllipse(RectangleF dstRect) { var w = dstRect.Width / 2.0; var h = dstRect.Height / 2.0; DrawBegin(dstRect); GL.Begin(PrimitiveType.TriangleFan); GL.Vertex2(w, h); for (var i = 0.0; i <= 60.0; i++) { var rad = MathHelper.DegreesToRadians(i * 6.0); var s = Math.Sin(rad); var c = Math.Cos(rad); GL.Vertex2(w + c * w, h + s * h); } GL.End(); DrawEnd(); }
public static void Vertex2(Vector2d v) { GL.Vertex2(v.X, v.Y); }