There’s no real need of an overlay, as you want a single rectangular shape to draw. OpenGL can render a quad (a GL_polygon) with no texture, you choose to fill it or the outline you want. GL_fill or GL_line
There’s no particular difficulty to doing this…
protected static void _GLdoPolygon(AWTGLCanvas gld, boolean fill, float lineWidth, Point.Float[] vertexes, float[][] vertexesColors, double z) {
GL11.glMatrixMode(GL11.GL_MODELVIEW);
if (fill) {
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
} else {
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_LINE);
}
GL11.glPushAttrib(GL11.GL_LINE_BIT);
GL11.glLineWidth(lineWidth);
GL11.glEnable(GL11.GL_LINE_SMOOTH);
float[] color = GLHandler._GLgetCurrentColor(gld);
GL11.glBegin(GL11.GL_POLYGON);
int i = 0;
for (Point.Float pf : vertexes) {
float[] c = vertexesColors[i++];
GL11.glColor4f(c[0], c[1], c[2], c[3]);
GL11.glVertex3f(pf.x, pf.y, (float) z);
}
GL11.glEnd();
GL11.glColor3f(color[0], color[1], color[2]);
GL11.glPopAttrib();
GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
}
This sample is part of the GLGeom class of JigaXtended API. I’m running LWJGL 2.1 but this could be easily ported to JOGL.