Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Currently in my project I am using LWJGL and the Slick2D library to render text onto the screen. Here is a more specific example:

    Font f = new Font("Times New Roman",Font.BOLD,18);
    font = new UnicodeFont(f);
    font.getEffects().add(new ColorEffect(Color.white));
    try {
    } catch (SlickException e) {

then i use font.drawString to write onto the screen. This is a quick easy way but it has a lot of disadvantages. for example font.loadGlyphs take a very long time 1-3 seconds. so when i want to change a color or font type then i have to wait 1-3 seconds which means I cannot do it while rendering (ie. cant have different color text on the same screen).

My question is what is a better way of drawing multicolored text onto the screen? I use slick2d only for the text rendering so maybe i can fully get rid of the library and draw text some other way...

If you have an answer please leave a quick short example.


share|improve this question
up vote 1 down vote accepted

I can't give you a short example using LWJGL alone, but what I can do is give you an way to solve your problem.

As I understand, you want to load one font at rendering time, and display it right away with multiple colours. My suggestion is to use Bitmap Fonts for this. Just use a tool (Example) to generate the bitmap font texture file and the textual file with the glyphs information, and load it to your engine.

The change of colours than becomes very easy, because all you have to do is generate white bitmap fonts (with transparent background), and draw the font texture using OpenGL to change its colours (like glColor3f) :)

*Edit: No need for OpenGL shaders for this. Also, transparent background for the font is needed.

share|improve this answer
One example of this using libGDX can be found in this link: link. libGDX uses LWJGL for its desktop version, you can check it out if this solutions interests you. – AranHase Nov 1 '12 at 23:06
I implemented the above solution (AranHase) Can you just give me a link to a shader example of shading the texture using opengl? – Trixmix Nov 2 '12 at 7:01
@Trixmix if you use the fixed rendering pipeline, you may read this link. All you have to do is set your vertices color with glColor3f() and draw your glyphs as usual. – AranHase Nov 2 '12 at 13:36
@Trixmix I edited my answer, add two main things. Shaders are not actually needed, sorry for that. And, a small touch: font texture background must be transparent. – AranHase Nov 2 '12 at 14:10
Thanks works great! – Trixmix Nov 2 '12 at 19:36

Remember to switch depth buffer off when drawing your font. Had same problem and this helped.

// font drawing code here
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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