I am developing a general 3D Simulator in JOGL which can render a wide range of Geographic data. The data can be in the form of points, lines and polygons.
But I am facing annoying problems while blending. If the data contains lines as well as polygons the blending goes for a toss as the depth test does not allow lines behind the polygon to be displayed.
Of course, ideally I should be sorting the primitives according to depth and render them from far to near. But since I am using both GL_TRIANGLE_STRIP and GL_LINE_STRIP primitives, in different functions calls this is not possible. Here is a snippet of my JOGL display() function:
if(polyLen > 0) {
gl.glDrawArrays(GL.GL_TRIANGLE_STRIP, polyStart, polyLen);
}
if(lnLen > 0) {
gl.glMultiDrawArrays(GL.GL_LINE_STRIP, lineFirst, 0, lineCount, 0, lineFirst.length);
}
if(ptLen > 0) {
gl.glDrawArrays(GL.GL_POINTS, ptStart, ptLen);
}
As you can see, each of the primitives are rendered using a separate function call. So any points or lines behind the polygons will be hidden by the depth test. All three primitives can be transparent/translucent. Worse, individual parts (some triangles in TRIANGLE_STRIP, some lines in LINE_STRIP) of each primitive may be transparent/translucent. So I am not sure if I can use the glDepthMask(false) trick.
How can blending between the different primitives be handled?