0
\$\begingroup\$

So, I load a TrueTypeFont like this:

   private TrueTypeFont trueTypeFont;
   try {
        InputStream inputStream = ResourceLoader.getResourceAsStream("assets/fonts/main.ttf");

        Font awtFont2 = Font.createFont(Font.TRUETYPE_FONT, inputStream);
        awtFont2 = awtFont2.deriveFont(24f); // set font size
        trueTypeFont = new TrueTypeFont(awtFont2, true);

    } catch (Exception e) {
        e.printStackTrace();
    }

After that, I draw a textured quad, as one usualyy would and then, draw trueTypeFont.drawString(this.x, this.y, this.text, Color.white); . What this gives, however is far from text, this is what it does, the black is supposed to be text...

enter image description here

How to fix?

\$\endgroup\$
1
\$\begingroup\$

You get the black boxes because you have to enable blending in OpenGL:

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

This because the textures drawn by Slick have transparency.

\$\endgroup\$
  • \$\begingroup\$ K, that causes puu.sh/aA554/09203ae10e.png ... the small black thingy I recognize as a part of the sprite sheet, I texturized the quad with... do I need to un-bind the texture somehow? \$\endgroup\$ – Rando Hinn Aug 1 '14 at 11:06
  • \$\begingroup\$ Or what should I do? \$\endgroup\$ – Rando Hinn Aug 1 '14 at 19:36
  • \$\begingroup\$ Hmm weird. You might have forgotten to enable something / loaded a texture. Check this page, it has everything you need: goo.gl/GuD35y \$\endgroup\$ – Basaa Aug 2 '14 at 16:08
  • \$\begingroup\$ Got it fixed, part of the fix included this. Approved \$\endgroup\$ – Rando Hinn Aug 3 '14 at 8:13
  • \$\begingroup\$ @RandoHinn So what was the fix of the problem where you've got pieces of other texture? \$\endgroup\$ – polkovnikov.ph Aug 6 '17 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.