Hi, I have a list of polygons stored in a HashSet.
I start with int depth = 0;
I add the polygons in one at a time. Each time I add a polygon i increase the depth.
Set<Polygon> polygons = new HashSet<Polygon(); //NOT an awt polygon! my own implementation.
int depth = 0;
...
public void AddPolygon(Polygon p)
{
p.setDepth(depth++);
polygons.add(p);
}
Because I am using a hashset, the polygons are obviously unordered. I want it this way. I only want rendering to be ordered. (Smallest depth rendered first)
in my render method I:
- Enable depth testing
- Loop through and draw all polygons
- Disable depth testing
The problem is, some polygons are rendered out of order even though their depths are right.
Is there some setting I have missed, or something I am doing wrong?
Thanks,
roland