C# Font display OpenGL -


i developing 2d cad application using tao framework in windows. use fonts windows libraries display drawing information. in addition rotate scale text. bitmap fonts not this.

i went through opengl font survey [http://www.opengl.org/archives/resources/features/fontsurvey/] of them c++ based apis.

could guide me available solutions in c#?

for 3d have followed examples found relation opentk compatible tao.framework.

screen

    public void addtexture(bitmap texture, bool mipmaped)     {         this.tex_id = world.loadtexture(texture, mipmaped);     }     public void addtext(string text, color color, float x, float y, float scale)     {         const int side = 256;         bitmap texture = new bitmap(side, side, system.drawing.imaging.pixelformat.format32bppargb);         graphics g = graphics.fromimage(texture);         using (brush brush = new solidbrush(color))         {             g.fillrectangle(brush, new rectangle(point.empty, texture.size));         }         using (font font = new font(systemfonts.dialogfont.fontfamily,  12f))         {             sizef sz = g.measurestring(text, font);             float f = 256 / math.max(sz.width, sz.height) * scale;             g.translatetransform(256 / 2 + f * sz.width / 2, 256 / 2 - f * sz.height / 2);             g.scaletransform(-f, f);             using (brush brush = new solidbrush(color))             {                 g.drawstring(text, font, brush, 0, 0);             }         }         addtexture(texture, true);     }      public static int loadtexture(bitmap texture, bool mipmaped)     {         int id = gl.gentexture();         gl.bindtexture(texturetarget.texture2d, id);         int wt = texture.width;         int ht = texture.height;          gl.texparameter(texturetarget.texture2d,             textureparametername.texturewraps, (int)texturewrapmode.repeat);         gl.texparameter(texturetarget.texture2d,             textureparametername.texturewrapt, (int)texturewrapmode.repeat);          system.drawing.imaging.bitmapdata data = texture.lockbits(             new rectangle(0, 0, wt, ht),             system.drawing.imaging.imagelockmode.readonly,             system.drawing.imaging.pixelformat.format32bppargb);          gl.teximage2d(texturetarget.texture2d, 0,             pixelinternalformat.rgba, wt, ht, 0,             pixelformat.bgra, pixeltype.unsignedbyte, data.scan0);          texture.unlockbits(data);          if (mipmaped)         {              gl.generatemipmap(generatemipmaptarget.texture2d);             gl.texparameter(texturetarget.texture2d,                 textureparametername.textureminfilter, (int)textureminfilter.linearmipmaplinear);         }         else         {             gl.texparameter(texturetarget.texture2d,                 textureparametername.textureminfilter, (int)textureminfilter.nearest);         }         gl.texparameter(texturetarget.texture2d,             textureparametername.texturemagfilter, (int)texturemagfilter.nearest);          return id;     } 

Comments

Popular posts from this blog

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -

node.js - Bad Request - node js ajax post -