Ejemplo n.º 1
0
 public Text(GBXMLContainer initData, RenderNode parent)
     : base(initData, parent)
 {
     text = InitData["Text"].Text;
     font = ProcessManager.ActiveProcess.rManager.GetOrCreateFont(InitData["Font"].Text);
     autoText = bool.Parse(InitData["AutoText","true"].Text);
 }
Ejemplo n.º 2
0
 public Texture GetOrCreateTexture(string Name2Search, GBFont font, string text, SizeF size, bool autoText)
 {
     Texture text2Return = GetTexture(Name2Search, "");
     if (text2Return == null)
     {
         text2Return = new Texture(Name2Search, font, text, size, autoText);
         createdTextures.Add(text2Return);
     }
     return text2Return;
 }
Ejemplo n.º 3
0
 public GBFont GetOrCreateFont(string Name2Search, string fileName = "")
 {
     GBFont font2Return = GetFont(Name2Search, fileName);
     if (font2Return == null)
     {
         font2Return = new GBFont(Name2Search, fileName);
         createdFonts.Add(font2Return);
     }
     return font2Return;
 }
Ejemplo n.º 4
0
        internal Texture(string name_, GBFont font, string text, SizeF orSize, bool autoText)
            : base(name_,string.Empty)
        {
            GBDebug.Assert(orSize.Width > 0 || autoText, "Trying to create texture with width 0");
            GBDebug.Assert(orSize.Height > 0 || autoText, "Trying to create texture with height 0");

            SizeF sz = autoText ? MeasureString(text, font.FontData) : orSize;
            bmp = new Bitmap((int)sz.Width, (int)sz.Height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
            gfx = System.Drawing.Graphics.FromImage(bmp);
            gfx.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;

            texture = GL.GenTexture();
            GL.BindTexture(TextureTarget.Texture2D, texture);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
            GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
            GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, (int)sz.Width, (int)sz.Height, 0,
                OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, IntPtr.Zero);

            loaded = true;

            DrawString(text, font);
        }
Ejemplo n.º 5
0
        internal void DrawString(string text, GBFont font, PointF point = new PointF(), Brush brush = null)
        {
            if (brush == null)
                brush = Brushes.White;
            Color tr = Color.Transparent;
            //            tr = Color.FromArgb(128, 0, 0, 0);
            gfx.Clear(tr);
            gfx.DrawString(text, font.FontData, brush, point);

            SizeF size = gfx.MeasureString(text, font.FontData);

            Rectangle dirty_region = new Rectangle(new Point(), bmp.Size);
            System.Drawing.Imaging.BitmapData data = bmp.LockBits(dirty_region,
            System.Drawing.Imaging.ImageLockMode.ReadOnly,
            System.Drawing.Imaging.PixelFormat.Format32bppArgb);

            GL.BindTexture(TextureTarget.Texture2D, texture);
            GL.TexSubImage2D(TextureTarget.Texture2D, 0,
                dirty_region.X, dirty_region.Y, dirty_region.Width, dirty_region.Height,
                OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, data.Scan0);

            bmp.UnlockBits(data);
        }