mshsrfc's picture

QuickFont

Hi

I have just started using quikfont and it does not seem to respond to color and is always white text

QFont font = new QFont("Fonts/times.ttf", 12);

if (!font.fontLoaded)
return;

GL.PushAttrib(AttribMask.ColorBufferBit);
GL.Color3(tcolor);

QFont.Begin();
GL.Translate(x, y, 0);
font.Print(str);
QFont.End();

I have tried multiple tcolors but always white text

Any ideas

Mike Haville


Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

Try something like this:

font.Options.Colour = new Color4(tcolor);
pconesa's picture

Hi mshsrfc!

I know that it is outdated, but I have the same problem that you described here. Did you solve it?

I'm trying to add a label to each point I have, so this is my code:

QFont.Begin();
QFont _pointLabel = new QFont(new Font("Tahoma", 1f * _zoom * _pointSize));
_pointLabel.Options.Colour = _labelColor;
QFont.End();
 
 foreach (CanvasPoint p in _points)
{
     if (p.Visible)
    {
        // Draw labels only for visible points
        _pointLabel.Print(p.ToString(), new Vector2(p.Center.X + esp, p.Center.Y + esp));
    }
}

I want that label change their color according to "_labelColor", that it is a Color type.

Any idea?

Thanks. Sorry for my English.

pconesa's picture

I've solve my problem, so now I can change the color of my Labels easily.

The problem was that I was doing wrong the load of the textures, son now my code for this is the following:

private int LoadTexture(Image img)
{
        Bitmap bmp = new Bitmap(img);
        int id_textura = GL.GenTexture();
        GL.BindTexture(TextureTarget.Texture2D, id_textura);
 
        BitmapData bmp_data = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
 
        GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, bmp_data.Width, bmp_data.Height, 0, OpenTK.Graphics.OpenGL.PixelFormat.Bgra, PixelType.UnsignedByte, bmp_data.Scan0);
 
        bmp.UnlockBits(bmp_data);
 
        // We haven't uploaded mipmaps, so disable mipmapping (otherwise the texture will not appear).
        // On newer video cards, we can use GL.GenerateMipmaps() or GL.Ext.GenerateMipmaps() to create
        // mipmaps automatically. In that case, use TextureMinFilter.LinearMipmapLinear to enable them.
        GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMinFilter, (int)TextureMinFilter.Linear);
        GL.TexParameter(TextureTarget.Texture2D, TextureParameterName.TextureMagFilter, (int)TextureMagFilter.Linear);
 
        return id_textura;
}

Hope it helps to anyone.

Sorry for my English.