Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
67
windowProp.height = BGR_HEIGHT;
windowProp.layerId = MML_GDC_DISP_LAYER_0;
/* Create a window and assign it as layer 0 */
UTIL_SUCCESS(ret, mmlGdcDispWinCreate(display, &windowProp, &win));
/* Allocate our buffers */
for
(i = 0; i < BUFFER_COUNT; i++) {
UTIL_SUCCESS(ret, mmlGdcSmResetSurfaceObject(&target_c[i]));
target[i] = &target_c[i];
UTIL_SUCCESS(ret, utSurfCreateBuffer(target[i], windowProp.width, windowProp.height,
MML_GDC_SURF_FORMAT_R5G6B5));
}
utResetContext(&utCtx);
/* Load a font bitmap */
mmlGdcSmGenSurfaceObjects(1, &sFont);
UTIL_SUCCESS(ret, utSurfLoadBitmap(sFont, courier_12, MM_FALSE));
/* Set it as font for the util lib */
utSetFont(&utCtx, sFont);
/* Initialize a point bitmap */
UTIL_SUCCESS(ret, utInitPoint(&utCtx, 50));
6.12.2.2 Doing the animation
Now begin with the animation: slightly different scenes 360 times. First clear the screen.
/* Clear the whole frame (You should optimize and only redraw the changed parts) */
UTIL_SUCCESS(ret, utRect(&utCtx, 0, 0, 320, 240));
Then draw a rounded rectangle with a border.
/* Now we draw a RoundRect with border. The simplest way is to draw it twice with different sizes and color */
utColor(&utCtx, 0, 255, 0, 255);
UTIL_SUCCESS(ret, utRoundRect(&utCtx, 163, 83, 154, 154, 10, 10));
And then draw the different parts of the complete scene.
/* The Drawing part is split into 5 sections. The result of DrawSample is used for DrawMix. Don’t change the order!
*/
UTIL_SUCCESS(ret, DrawLines(&utCtx));
UTIL_SUCCESS(ret, utInitPoint(&utCtx, 20));
UTIL_SUCCESS(ret, DrawPoints(&utCtx));
UTIL_SUCCESS(ret, DrawSample(&utCtx, f));
UTIL_SUCCESS(ret, DrawLineEnds(&utCtx, f));
UTIL_SUCCESS(ret, DrawMix(&utCtx, target[nCurBuffer]));