Hi emzic,
Here is my quick test-routine which I call every frame (Imagine I’d like to create animated 2D graphics).
I guess it does the same as the Overlay class (I took a look into the Overlay and TextureRenderer source to see how it works)
As I noted, when I call my “render2D” 10 times in a loop the CPU usage rises to over 60%.
TextureRenderer renderer = null;
int render2D(GL gl, GLDrawable gld)
{
if (renderer == null)
{
renderer = new TextureRenderer(100,100,true);
renderer.setSmoothing(false);
}
Graphics2D g2 = renderer.createGraphics();
g2.setBackground(new Color(0,0,0,0)); //transparent background
g2.clearRect(0,0,100,100); //clear all
g2.fillRect(0,0,10,10);
g2.setPaint(new Color(99,0,255));
g2.drawRect(0,0,22,22);
g2.dispose();
renderer.markDirty(0,0,500,500);
Texture tex = renderer.getTexture();
tex.bind();
//draw orthogonal quad.
int x = 45;
int y = 45;
int w = 100;
int h = 100;
y = gld.getHeight()-y;
gl.glBegin(GL.GL_QUADS);
gl.glTexCoord2i(0,1);
gl.glVertex3d(x,y-h,0f);
gl.glTexCoord2i(1,1);
gl.glVertex3d(x+w,y-h,0f);
gl.glTexCoord2i(1,0);
gl.glVertex3d(x+w,y,0f);
gl.glTexCoord2i(0,0);
gl.glVertex3d(x,y,0f);
gl.glEnd();
return 0;
}