Hello,
I am developing an application which hosts both a 3D scene rendered via JOGL and a HUD rendered via Java2D. I am using the Overlay class to render the HUD when the 3D scene has finished rendering. This works quite fine and fast, but as soon as I try to have a text label in the HUD with transparent background which’s text changes during execution of the application, the contents of the text label are not set back correctly resulting in each new text is written on top of the old text, resulting in an unreadable mess.
I use the following code for drawing the overlay:
// if no overlay has been created
if(myOverlay == null)
{
// create overlay
myOverlay = new Overlay(aDrawable);
}
// if an overlay has been created
else
{
// make it redraw completely
myOverlay.markDirty(0, 0, 640, 480);
}
// create graphics
Graphics2D graphics = myOverlay.createGraphics();
// paint gui
myGuiListener.paintGui(graphics);
// draw overlay
myOverlay.drawAll();
Transparency works if I create a new overlay every frame instead of storing the old one, but unfortunately that drops the frame rate by 50% and I need every fps I can get, since the 3D application is going to be quite “hungry”.
Is there any way I can reset the overlay to the state it was in after it was created, i.e. a completely empty, transparent overlay which I can use for drawing a new HUD every frame?
Regards,
Pia