Faces rendering on top of each other

Hi, I am having difficulty with rendering two simple cuboids which share a common face. This face, when rendered causes glitches, the top one is semi-transparent and the bottom is solid colour and it renders as if the solid portion below overlays on top of the semi-transparent face.

I have cured the issue with the edges overlapping by using the glPolygonOffset.

Is there anyway I can cure this problem?


you have to render your scene twice:

  1. render all opaque primitives
  2. render all transparent primitives

but for the 2. pass you have to sort all primitives so that you start rendering the nearest once