JOGL + Overlay + Performance Hit

Hi,

I’m trying to use the Overlay class to draw some 2D grahpics over my 3D scene. Unfortunately I’m getting a CPU hit of about 30! percent, even if I only draw some simple rectangles. If I remove the “drawAll()” call everything is fine. Please see the test code below. Can someone give me a hint how to optimize it?


gl.glMatrixMode(GL.GL_MODELVIEW);
    gl.glLoadIdentity();
    
    	
	
	Overlay ol = new Overlay(gld);
	Graphics2D g = ol.createGraphics();

	g.setPaint(new Color(255,255,0));  
	g.fillRect(0,0,10,10);
	
	g.setPaint(new Color(0,255,0));  
	g.fillRect(10,10,40,40);


	
    glu.gluLookAt(posx,posy,posz,  posx+dirx,posy+diry,posz+dirz,  0.0,1.0,0.0);
	gl.glDrawArrays (GL.GL_TRIANGLES,0,numQuads);
	
	
	ol.markDirty(0, 0, 100, 100);
 	ol.drawAll();
 
 

    gl.glFlush();


Hi,

I figured it out myself. The bottleneck was not “drawAll()” but the constructor of Overlay. ::slight_smile: ::slight_smile:

Bye