b2dDrawQuadDepth

Draws a quad where each corner has its own depth (0..1), interpolated per-pixel.

2D Overlay

Parameters & Returns

Parameters

x1 Int
y1 Int
z1 Double
x2 Int
y2 Int
z2 Double
x3 Int
y3 Int
z3 Double
x4 Int
y4 Int
z4 Double
fill Int

Returns

Void

Quick Summary

Draws a quad where each corner has its own depth (0..1), interpolated per-pixel.

Technical Exegesis...

Like b2dDrawQuad, but every corner carries its own depth value (z1..z4, each 0 = near .. 1 = far) instead of the single depth set by b2dSetDepth. The GPU interpolates the depth across the face per pixel, so faces that INTERPENETRATE or are steeply tilted resolve correctly against each other - the case a single flat per-quad depth cannot handle. fill = 1 fills it, 0 draws the outline. Honours the current colour and alpha.

Example

Example.bam
; each projected corner gets its own perspective-correct depth
Local d1:Double = (FAR * (vz1 - NEAR)) / (vz1 * (FAR - NEAR))
Local d2:Double = (FAR * (vz2 - NEAR)) / (vz2 * (FAR - NEAR))
Local d3:Double = (FAR * (vz3 - NEAR)) / (vz3 * (FAR - NEAR))
Local d4:Double = (FAR * (vz4 - NEAR)) / (vz4 * (FAR - NEAR))
b2dSetColor(200, 180, 60)
b2dDrawQuadDepth(sx1,sy1,d1, sx2,sy2,d2, sx3,sy3,d3, sx4,sy4,d4, 1)