b2dSetDepth

Sets the depth (0 = near .. 1 = far) for subsequent 2D draws, enabling per-pixel occlusion.

2D Overlay

Parameters & Returns

Parameters

z Double

Returns

Void

Quick Summary

Sets the depth (0 = near .. 1 = far) for subsequent 2D draws, enabling per-pixel occlusion.

Technical Exegesis...

Writes into a real 2D depth buffer so later draws with a larger z sit BEHIND earlier ones, resolved per pixel by the GPU (LESS_EQUAL test). The default depth is 0 and the buffer is cleared to 1.0 each frame, so code that never calls this behaves exactly as before (painter's order). This is what lets you render true 3D-in-2D - transform and project a mesh, give each face a depth, and draw in any order without sorting. Images and text stay depth-off (UI/overlay).

Example

Example.bam
b2dSetDepth(0.5)
b2dDrawQuad(x1,y1,x2,y2,x3,y3,x4,y4,1)  ; occluded per-pixel by nearer faces