I have an OpenGL project in Java that draws a series of circles on the screen, and I want a tooltip to appear whenever the mouse is over one of the circles. It works perfectly if the tooltip is nothing more than a rectangle, but once I add the text rendering code everything stops working. All of the circles disappear once the mouse moves over one of them, and the rectangle behind the text does likewise. They do not reappear no matter where I move the mouse following afterwards. The line of code causing my problems is
GraphicsUtil.DEFAULT_FONT.drawString(x, y, info);
Where info is the String, x and y are the coordinates, and GraphicsUtil.DEFAULT_FONT is declared as follows:
@SuppressWarnings("unchecked")
public class GraphicsUtil
{
private GraphicsUtil()
{
}
public static final UnicodeFont DEFAULT_FONT = new UnicodeFont(new Font("",Font.PLAIN,12));
static
{
DEFAULT_FONT.addAsciiGlyphs();
DEFAULT_FONT.addGlyphs(400, 600);
DEFAULT_FONT.getEffects().add(new ColorEffect(java.awt.Color.white));
try
{
DEFAULT_FONT.loadGlyphs();
}
catch (SlickException e)
{
e.printStackTrace();
}
}
}
MISC:
This code is called by the circle that is currently rendering at the end of its render function. Info is a multi-line string. LWJGL version 2.8.3.
UPDATE: This appears to a problem with the alpha. depending on what text I output, the rest of the drawing shows up very faintly.
I needed to add
glDisableafter the text rendering. The following code works perfectly: