0
\$\begingroup\$

I have the following texture: lwjgl texture width 128, height 32

The black pixels are characters, the background is transparent. How do I change the black pixels of the characters to another color? I use this texture as a bitmap for text rendering in lwjgl. For example, is there a way to change the black pixels to red? I looked to shaders, but I don't know how to use shaders and what they does. I would appreciate an example. I also looked at this page.

But I don't really understand how to do it. I will really vote up your answer.

\$\endgroup\$
0
0
\$\begingroup\$

What you're asking is probably possible, but I think the easiest thing to do would be to just make another texture with the desired effects. Then, when the time comes to modify the text, just switch the texture. This can be modeled with:

void update()
{
    // do updating stuff above
    if (condition)
    {
        textTexture = // Get texture here
    }
}

void draw()
{
    textTexture.bind()
    gl.Begin(Quads)
    {
        // Do drawing stuff here
    }
}
\$\endgroup\$
2
  • \$\begingroup\$ Thank you for your answer. So I must make another texture for each text color I want? \$\endgroup\$ Mar 10 '14 at 16:43
  • \$\begingroup\$ @user2190492 Yes. Go into your paint editor and modify the texture colors to fit your needs. \$\endgroup\$
    – hasherr
    Mar 11 '14 at 1:22

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