Search code examples
openglopengl-es3ddirect3d

Triangle drawing order in DirectX/OpenGL


Is the order of drawing triangles in a 3D API guaranteed to be the same as their order in the index buffer?

For example if I have two overlapping triangles in a single draw call, and depth testing is disabled, will the first or second triangle be visible in the end?

Or do I need to issue separate draw calls to be sure that the 2nd triangle appears on top of the 1st?


Solution

  • In OpenGL the order is indeed preserveed, so that painters algorithm can be used, for example when rendering semitransparent geometry.

    Direct3D I don't know for sure, but I'd say the same applies there.