예제 #1
0
        public override void DrawEllipse(PBrush c, float width, RectangleF rect)
        {
            const int DETAIL = 50;

            float x  = (rect.Left + rect.Right) / 2f;
            float y  = (rect.Top + rect.Bottom) / 2f;
            float rx = (rect.Right - rect.Left) / 2f;
            float ry = (rect.Bottom - rect.Top) / 2f;
            float w  = 1 - width * 2f / (rx + ry);

            if (c != null)
            {
                GL.Color(c.GetColor());
            }
            GL.Begin(PrimitiveType.QUADS);
            double lA = 0;

            for (int i = 1; i <= DETAIL; i++)
            {
                double  a    = i * Math.PI * 2.0 / DETAIL;
                float   sin1 = (float)Math.Sin(lA);
                float   cos1 = (float)Math.Cos(lA);
                float   sin2 = (float)Math.Sin(a);
                float   cos2 = (float)Math.Cos(a);
                float[] ptsx = new float[] { cos1, cos1 *w, cos2 *w, cos2 };
                float[] ptsy = new float[] { sin1, sin1 *w, sin2 *w, sin2 };
                NativeGL.nglVertex2fTrans(4, ptsx, ptsy, x, y, rx, ry);
                lA = a;
            }
            GL.End();
        }
예제 #2
0
 public override void BeginCircles(PBrush brush)
 {
     if (brush != null)
     {
         GL.Color(brush.GetColor());
     }
     GL.Begin(PrimitiveType.TRIANGLE_STRIP);
 }
예제 #3
0
 public override void FillEllipse(PBrush c, RectangleF rect)
 {
     using (SolidColorBrush b = new SolidColorBrush(renderTarget, c.GetColor().ToColor4()))
     {
         Ellipse ell = new Ellipse();
         ell.Point   = new RawVector2(rect.X + rect.Width / 2, rect.Y + rect.Height / 2);
         ell.RadiusX = rect.Width / 2;
         ell.RadiusY = rect.Height / 2;
         renderTarget.FillEllipse(ell, b);
     }
 }
예제 #4
0
        public override void FillEllipse(PBrush c, RectangleF rect)
        {
            float x  = (rect.Left + rect.Right) / 2f;
            float y  = (rect.Top + rect.Bottom) / 2f;
            float rx = (rect.Right - rect.Left) / 2f;
            float ry = (rect.Bottom - rect.Top) / 2f;

            if (c != null)
            {
                GL.Color(c.GetColor());
            }
            GL.Begin(PrimitiveType.TRIANGLES);
            NativeGL.nglVertex2fTrans(pEllipseX.Length, pEllipseX, pEllipseY, x, y, rx, ry);
            GL.End();
        }
예제 #5
0
        public override void DrawText(string str, PBrush brush, RectangleF rect, float size)
        {
            float quality = 5;

            size = Util.MmToPoint(size);
            rect = Util.MmToPoint(rect);
            gdi.Graphics dummy = gdi.Graphics.FromHwnd(IntPtr.Zero);
            gdi.Font     ft    = new gdi.Font("Calibri", size / Util.GetScaleFactor() * quality);
            gdi.SizeF    s     = dummy.MeasureString(str, ft);
            s.Height *= 2;
            s.Height *= quality;
            s.Width  *= quality;
            gdi.Bitmap     bmp = new gdi.Bitmap((int)s.Width, (int)s.Height);
            gdi.Color      c1  = brush.GetColor();
            gdi.Color      c2  = gdi.Color.FromArgb(0, c1.R, c1.G, c1.B);
            gdi.SolidBrush b   = new gdi.SolidBrush(c1);
            gdi.Graphics   g   = gdi.Graphics.FromImage(bmp);
            g.Clear(c2);
            g.DrawString(str, ft, b, new PointF(0, 0));

            int tex = GLRenderer.Util.LoadTexture(bmp);

            Opengl32.glEnable(GLConsts.GL_TEXTURE_2D);
            Opengl32.glBindTexture(GLConsts.GL_TEXTURE_2D, tex);
            rect = new RectangleF(rect.X, rect.Y, s.Width / quality, s.Height / quality);
            GL.Color(1, 1, 1, 1);
            GL.Begin(PrimitiveType.QUADS);
            GL.TexCoord(0, 0); GL.Vertex2(rect.Left, rect.Top);
            GL.TexCoord(1, 0); GL.Vertex2(rect.Right, rect.Top);
            GL.TexCoord(1, 1); GL.Vertex2(rect.Right, rect.Bottom);
            GL.TexCoord(0, 1); GL.Vertex2(rect.Left, rect.Bottom);
            GL.End();
            Opengl32.glDisable(GLConsts.GL_TEXTURE_2D);

            Opengl32.glDeleteTextures(1, ref tex);
            b.Dispose();
            bmp.Dispose();
            dummy.Dispose();
        }
예제 #6
0
        public override void DrawRoundedRectangle(PBrush c, float width, RectangleF rect)
        {
            GL.Color(c.GetColor());
            PointF p1 = new PointF(rect.Left, rect.Top);
            PointF p2 = new PointF(rect.Right, rect.Top);
            PointF p3 = new PointF(rect.Right, rect.Bottom);
            PointF p4 = new PointF(rect.Left, rect.Bottom);

            GL.Begin(PrimitiveType.QUADS);
            drawLine(width, p1, p2);
            drawLine(width, p2, p3);
            drawLine(width, p3, p4);
            drawLine(width, p4, p1);
            GL.End();

            BeginCircles(null);
            Circle(p1.X, p1.Y, width / 2);
            Circle(p2.X, p2.Y, width / 2);
            Circle(p3.X, p3.Y, width / 2);
            Circle(p4.X, p4.Y, width / 2);
            EndCircle();
        }
예제 #7
0
 public override void BeginRects(PBrush brush)
 {
     cBrush = new XSolidBrush(brush.GetColor());
 }
예제 #8
0
 public Brush GetBrush(PBrush pBrush)
 {
     return(new SolidColorBrush(renderTarget, pBrush.GetColor().ToColor4()));
 }
예제 #9
0
 public override void BeginCircles(PBrush brush)
 {
     cColor?.Dispose();
     cColor = new SolidBrush(brush.GetColor());
 }
예제 #10
0
 public override void BeginRects(PBrush brush)
 {
     GL.Color(brush.GetColor());
     GL.Begin(PrimitiveType.QUADS);
 }
예제 #11
0
 public override void DrawRoundedLine(PBrush c, float width, PointF p1, PointF p2)
 {
     DrawLine(c.GetColor(), width, p1, p2, true, true);
 }