Module Documentation
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
167
MML_GDC_2D_MATRIX_API void utMat4x4LoadIdentity (Mat4x4 m)
MML_GDC_2D_MATRIX_API void utMat4x4Translate (Mat4x4 m, MM_FLOAT x, MM_FLOAT y, MM_FLOAT z)
MML_GDC_2D_MATRIX_API void utMat4x4Scale (Mat4x4 m, MM_FLOAT x, MM_FLOAT y, MM_FLOAT z)
MML_GDC_2D_MATRIX_API void utMat4x4RotX (Mat4x4 m, MM_FLOAT f)
MML_GDC_2D_MATRIX_API void utMat4x4RotY (Mat4x4 m, MM_FLOAT f)
MML_GDC_2D_MATRIX_API void utMat4x4RotZ (Mat4x4 m, MM_FLOAT f)
MML_GDC_2D_MATRIX_API void utMat4x4Perspective (Mat4x4 m, MM_FLOAT fovy, MM_FLOAT aspect,
MM_FLOAT zNear, MM_FLOAT zFar)
MML_GDC_2D_MATRIX_API void utMat4x4GetXYZ (Mat4x4 m, float x, float y, float z, float
∗
xout, float
∗
yout,
float
∗
zout)
Matrix functions for the conversion of matrices
MML_GDC_2D_MATRIX_API void utMat3x2ToMat4x4 (Mat3x2 src, Mat4x4 dst)
MML_GDC_2D_MATRIX_API void utMat3x3ToMat4x4 (Mat3x3 src, Mat4x4 dst)
MML_GDC_2D_MATRIX_API void utMat4x4ToMat3x3 (Mat4x4 src, Mat3x3 dst)
MML_GDC_2D_MATRIX_API void utMat4x4ToMat3x2 (Mat4x4 src, Mat3x2 dst)
Matrix functions for color operations
MML_GDC_2D_MATRIX_API void utMat4x3Copy (Mat4x3 dst, const Mat4x3 src)
MML_GDC_2D_MATRIX_API void utMat4x3Multiply (Mat4x3 dst, const Mat4x3 src1, const Mat4x3 src2)
MML_GDC_2D_MATRIX_API void utMat4x3LoadIdentity (Mat4x3 m)
MML_GDC_2D_MATRIX_API void utMat5x4LoadIdentity (Mat5x4 m)
MML_GDC_2D_MATRIX_API void utMat4x3CalcColMatrix (Mat4x3 dst, MM_FLOAT fContrast, MM_FLOAT
fBrightness, MM_FLOAT fSaturation, MM_FLOAT fHue)
11.17.1 Detailed Description
The functions in this block are used by some tutorial examples for matrix operations. Different matrix formats and
related functions are defined to support different use cases:
Mat3x2: This matrix format is sufficient for a fine operations like translation, rotation, scaling and sharing.
Mat3x3: A 3x3 matrix is required for perspective operations.
Mat4x4: A 4x4 matrix is required for perspective operations including z (depth) calculation. The 2D core HW
does not calculate z-coordinates and the driver API does not support this type of matrix. However, in the
computer 3D world (e.g. OpenGL) 4x4 matrices are often used and for compatibility reasons in some tutorial
examples the 4x4 matrix type is used. To use such a matrix type with the 2D core HW it is required to convert
this matrix to a 3x3 matrix type and in some cases to make the z-order calculation in software.
Mat4x3: This matrix type is useful for color operations, modifying the R, G, B or Y, U, V color channels.
Mat5x4: This matrix type is useful for color operations, modifying the R, G, B, A or Y, U, V, A color channels.
The following code shows a matrix calculation using typical 3D operations with a 4x4 matrix. The result will be
converted into a 3x3 matrix and assigned to a blit context.
Mat4x4 m44;
Mat3x3 m33;
utMat4x4LoadIdentity(m44); utMat4x4Translate(m44, w / 2.0f, h / 2.0f, 0);
utMat4x4Scale(m44, w / 4.0f, h / 4.0f, 1); utMat4x4Perspective(m44, 60.0f, (float)w / h, (float)0.1, 100.0);
utMat4x4Translate(m44, 0, 0, -2);