I have a camera with the coordinates 0,0,-5, a red triangle (v0 = 0,1,0; v1=-1,-1,0; v2=1,-1,0) and a green one (v0= 0,1,2; v1=-1,-1,2; v2=1,-1,2). I have the EnableAutoDepthStencil set to true, and the backbuffer format d16 . What do I need to do to draw the green triangle in fron of the red one (without changing the camera and the triangle coordinates, and stencil

Re: Game Technologies: DirectX 101 Draw a back object in front


There are a few ways you can do this....

If you wanna draw the green triangle in front of everything else, you could call Device.Clear() with the ZBuffer and StencilBuffer flags, before drawing the green triangle, or you could disable the ZWrite render state before rendering the red triangle.