|
|
|
The 4 simple steps necessary to produce an animated graphic screen on the Merlino Board both rapidly and easily.
|
|
|
Thanks to the Classes and Methods library that is supplied with Merlino Board Dev Kit, writing programmes for Merlino Board is both easy and rapid.
Let’s see how to produce an animated graphic screen.
First of all we need to show a background.
|
| |
#include "excalibur.h"
#include "..\class\class.h"
FLASH flash(NUM_ELEMENTS,FLASH_ADDRESS); // FAT Flash loading
VIDEO video(1024,768); // VGA Initialization @ 1024x768 16bpp
void Initialize()
{
video.initBitmaps(&flash); // Load the data structure with the Bitmap images
video.bitmaps[BACKGROUND].LoadBuffer(); // Load the background image in video Memory
}
void main(void)
{
Initialize();
while (1) { // Main Loop
vid->UpdateBackGround(); // Update the Background image on the BackBuffer
vid->redraw(); // Redraws the BackBuffer on the Video memory
}
}
| |
|
After compiling and using the special software tools supplied with Merlino Board Dev Kit, you will be able to upload your images and your user programme onto the Flash Memory. On the monitor attached to the Merlino Board you will see what you can see in the picture here.
|
|
|
|
|
Suppose we want to add some text and another bitmap image to overlay onto our background.
The code lines highlighted show the differences with the preceding step.
|
|
|
#include "excalibur.h"
#include "..\class\class.h"
FLASH flash(NUM_ELEMENTS,FLASH_ADDRESS); // FAT Flash loading
VIDEO video(1024,768); // VGA Initialization @ 1024x768 16bpp
void Initialize()
{
video.initBitmaps(&flash); // Load the data structure with the Bitmap images
video.bitmaps[BACKGROUND].LoadBuffer(); // Load the background image in video Memory
|
|
video.bitmaps[LOGO].LoadBuffer(); // Load Logo Bitmap in Video Memory
video.fonts[COURIER].LoadBuffer(); // Load Font in Video Memory
|
|
}
void main(void)
{
Initialize();
while (1) { // Main Loop
vid->UpdateBackGround(); // Update the Background image on the BackBuffer
|
|
vid->bitmaps[LOGO].DrawSprite(720,500,Frame);
vid->fonts[COURIER].vgaprintf("RESOLUTION @ 1024x768",450,450);
vid->fonts[COURIER].vgaprintf("COLORS @ 65000",450,500);
|
|
vid->redraw(); // Redraws the BackBuffer on the Video memory
}
}
|
|
After compiling the code and uploading onto the Merlino board, we’ll see what is shown in the picture on the left.
|
|
|
Now we continue by inserting a graphic object to animate and overlay on the background.
|
|
|
#include "excalibur.h"
#include "..\class\class.h"
FLASH flash(NUM_ELEMENTS,FLASH_ADDRESS); // FAT Flash loading
VIDEO video(1024,768); // VGA Initialization @ 1024x768 16bpp
void Initialize()
{
video.initBitmaps(&flash); // Load the data structure with the Bitmap images
video.bitmaps[BACKGROUND].LoadBuffer(); // Load the background image in video Memory
video.bitmaps[LOGO].LoadBuffer(); // Load Logo Bitmap in Video Memory
| |
video.bitmaps[ROBOT].LoadBuffer(); // Load Robot in Video Memory
| |
video.fonts[COURIER].LoadBuffer(); // Load font in Video Memory
}
void main(void)
{
Initialize();
while (1) { // Main Loop
vid->UpdateBackGround(); // Update the Background image on the BackBuffer
| |
video.bitmaps[ROBOT].DrawSprite(400,300); // Draw the Robot in the frame
video.bitmaps[ROBOT].stepFrame();
| |
vid->bitmaps[LOGO].DrawSprite(720,500,Frame);
vid->fonts[COURIER].vgaprintf("RESOLUTION @ 1024x768",450,450);
vid->fonts[COURIER].vgaprintf("COLORS @ 65000",450,500);
vid->redraw(); // Redraws the BackBuffer on the Video memory
}
}
| |
|
This time, after having compiled the code and having uploaded the data to the Merlino board, we will see an animated image like the one shown on the right.
|
|
|
|
|
Now let’s exaggerate.
On the rapidly animated object, following a command sent with a button on one of the input lines of the Merlino Board, we will now apply a transparent effect (Alpha Blending).
|
|
|
#include "excalibur.h"
#include "..\class\class.h"
FLASH flash(NUM_ELEMENTS,FLASH_ADDRESS); // FAT Flash loading
VIDEO video(1024,768); // VGA Initialization @ 1024x768 16bpp
|
|
IO io(0);
unsigned int Overlay = 0;
|
|
void Initialize()
{
video.initBitmaps(&flash); // Load the data structure with the Bitmap images
video.bitmaps[BACKGROUND].LoadBuffer(); // Load the background image in video Memory
video.bitmaps[LOGO].LoadBuffer(); // Load Logo Bitmap in Video Memory
video.bitmaps[ROBOT].LoadBuffer(); // Load Robot in Video Memory
video.fonts[COURIER].LoadBuffer(); // Load font in Video Memory
}
|
|
void CheckIO()
{
io.Polling();
if (io.wasPressed(IO_TEST1)) Overlay = -Overlay;
}
|
|
void main(void)
{
Initialize();
while (1) { // Main Loop
}
|
|
CheckIO();
|
|
vid->UpdateBackGround(); // Update the Background image on the BackBuffer
|
|
if (!Overlay) video.bitmaps[ROBOT].DrawSprite(400,300); // Draw the Robot;
else {
// Draw the Robot, with the defined frame, on overlay plan
video.bitmaps[ROBOT].DrawSpriteOv(400,300);
// Changes the alpha channel values, for every color, in linear way
video.bitmaps[ROBOT].stepAlpha();
}
|
|
video.bitmaps[ROBOT].stepFrame();
vid->bitmaps[LOGO].DrawSprite(720,500,Frame);
vid->fonts[COURIER].vgaprintf("RESOLUTION @ 1024x768",450,450);
vid->fonts[COURIER].vgaprintf("COLORS @ 65000",450,500);
vid->redraw(); // Redraws the BackBuffer on the Video memory
}
}
|
|
|