Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
64
6.10.2.3 z-order sorting
The hardware is not able to detect any z-order. The bitmaps will be drawn in the order as specified in the command
list. Later drawn bitmaps are on top of previously drawn bitmaps. For this reason we calculate a z-value of the
center of each bitmap manually by using the 4
∗
4 matrix.
utMat4x4GetXYZ(mat44[0], COVER_SIZE/2, COVER_SIZE/2, 0, &fX, &fY, &fZ);
To sort the draw order we just sort a list of all bitmaps:
qsort(&positions[0], (
size_t
)positions.size(),
sizeof
(positions[0]), CompareFnc);
The compare function is:
int
Coverflow::CompareFnc(
const
void
*arg1,
const
void
*arg2 )
{
Coverflow::COVERPOS *p1 = (Coverflow::COVERPOS *)arg1;
Coverflow::COVERPOS *p2 = (Coverflow::COVERPOS *)arg2;
if
(p1->z < p2->z)
return
-1;
if
(p1->z > p2->z)
return
+1;
return
0;
}