[Help request][Solved] AngelCodeFont with transparent "background".

Started by vincentm, September 07, 2011, 18:51:34

Previous topic - Next topic

vincentm

I'm quite new to all this fancy stuff. I'm writing a program which would benefit a lot from being able to render text in front of a colored quad.
At the moment I'm initializing the AngelCodeFont and all the OpenGL things. The render() looks something like this. (Screen is cleared before)
public void render(AngelCodeFont font) {
		GL11.glBegin(GL11.GL_QUADS);
			GL11.glVertex2f(x - size+5, y - size+5);
			GL11.glVertex2f(x + size-5, y - size+5);
			GL11.glVertex2f(x + size-5, y + size-5);
			GL11.glVertex2f(x - size+5, y + size-5);
		GL11.glEnd();
		// Draw the value!
		GL11.glEnable(GL11.GL_TEXTURE_2D);
			font.drawString(x-20, y-20, "" + value);
		GL11.glDisable(GL11.GL_TEXTURE_2D);
}

And together with the rest of the code it renders like this:

Now, is there anyway to make the black background on each glyph to "be rendered transparent" (not really sure what the correct term/approach is here)?
Thanks for your time :).

CodeBunny

Of course. Basically, you determine that setting before exporting the font image.

I believe (don't have the program with me) in "Export options" you need to set it to export a 32-bit image instead of 8-bit, and set the exported image to "white text with alpha."

vincentm

Thanks, got the blending to work now :)
Had to turn on alpha-blending. Only problem now is that the glyphs aren't correctly "cut-out", they look like random signs.