Tutorial
FM4, S6E2DH/S6E2DF/S6E2D5/S6E2D3 Series, 32-Bit Microcontroller, Graphic Driver User Manual, Doc. No. 002-04387 Rev. *A
66
6.12.2 Code documentation
6.12.2.1 Preparation
Once again, we start with a collection of several driver and display initializations.
/* Initialization of driver and display */
/* Initialize the driver */
UTIL_SUCCESS(ret, mmlGdcSysInitializeDriver(0));
UTIL_SUCCESS(ret, utMmanReset() );
/* Allocate some of VRAM for Instruction buffer for the command sequencer. Note, that mmlGdcVideoAlloc is an
application defined routine to manage the VRAM space. The 2D core driver does not include any management of
the VRAM. */
vInstrBuffer = mmlGdcVideoAlloc(fifo_size, 0, NULL);
UTIL_SUCCESS(ret, mmlGdcSysSetInstructionBuffer(vInstrBuffer, fifo_size));
We need target surface in VRAM to render strings in it.
/* 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));
We want to print some information on the screen. We can set up a font by using the utility functions of this tutorial
with the code:
/* 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);
Then we create a point 50 pixels in diameter (actually a bitmap) again using utility functions.
/* Initialize the driver */
UTIL_SUCCESS(ret, mmlGdcSysInitializeDriver(0));
UTIL_SUCCESS(ret, utMmanReset() );
/* Allocate some of VRAM for Instruction buffer for the command sequencer. Note, that mmlGdcVideoAlloc is an
application defined routine to manage the VRAM space. The 2D core driver does not include any management of
the VRAM. */
vInstrBuffer = mmlGdcVideoAlloc(fifo_size, 0, NULL);
UTIL_SUCCESS(ret, mmlGdcSysSetInstructionBuffer(vInstrBuffer, fifo_size));
/* Setup and enable the display */
UTIL_SUCCESS(ret, mmlGdcDispOpenDisplay(&dispParams, &display));
windowProp.topLeftX = (dispParams.xResolution - BGR_WIDTH) / 2;
windowProp.topLeftY = (dispParams.yResolution - BGR_HEIGHT) / 2;
windowProp.width = BGR_WIDTH;