Exemple #1
0
 public override void DrawImage(Image img, RectangleF rect)
 {
     if (img.GLTextureID == 0)
     {
         img.LoadGL();
     }
     Opengl32.glBindTexture(GLConsts.GL_TEXTURE_2D, img.GLTextureID);
     Opengl32.glEnable(GLConsts.GL_TEXTURE_2D);
     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);
 }
Exemple #2
0
        public override void DrawRenderBitmap(RenderBitmap bmp)
        {
            float x1 = 0, y1 = 0, x2 = Width, y2 = Height;

            if (bmp == null || !(bmp is RenderBitmap3))
            {
                return;
            }

            Opengl32.glEnable(GLConsts.GL_TEXTURE_2D);
            Opengl32.glBindTexture(GLConsts.GL_TEXTURE_2D, ((RenderBitmap3)bmp).FBO.Texture);

            GL.Color(1, 1, 1, 1);
            GL.Begin(PrimitiveType.QUADS);
            GL.TexCoord(0, 1); GL.Vertex2(x1, y1);
            GL.TexCoord(1, 1); GL.Vertex2(x2, y1);
            GL.TexCoord(1, 0); GL.Vertex2(x2, y2);
            GL.TexCoord(0, 0); GL.Vertex2(x1, y2);
            GL.End();
            Opengl32.glDisable(GLConsts.GL_TEXTURE_2D);
        }
Exemple #3
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();
        }