Conversation
|
Probably want to add the line to (Might have some comments on stuff tomorrow... yawn) |
|
Threw this together to get most of the builds passing: Daft-Freak@ecdab8e You'll have to wait for @Gadgetoid to merge this, but here's some comments anyway: If you add an assets.hpp:
badger.gif:
type: raw/binary
name: badgeradd the line I had a bit of an attempt at using some of the blit apis: diff --git a/examples/animated_gif/animated_gif.cpp b/examples/animated_gif/animated_gif.cpp
index 16610858..abe6d9d4 100644
--- a/examples/animated_gif/animated_gif.cpp
+++ b/examples/animated_gif/animated_gif.cpp
@@ -12,7 +12,8 @@ AnimatedGIF gif; // static class instance
#define DISPLAY_WIDTH 320
#define DISPLAY_HEIGHT 240
static uint8_t image[DISPLAY_WIDTH * DISPLAY_HEIGHT]; // holds the 8-bit GIF image
-static uint8_t palTemp[256*3];
+static Pen pal[256];
+Surface gif_surface(image, PixelFormat::P, Size(DISPLAY_WIDTH, DISPLAY_HEIGHT));
// Draw a line of image into memory and send the whole line to the display
void GIFDraw(GIFDRAW *pDraw)
@@ -24,13 +25,15 @@ void GIFDraw(GIFDRAW *pDraw)
if (pDraw->y == 0) // first line, get palette as 24-bpp
{
pus = pDraw->pPalette;
- d = palTemp;
+ Pen *p = pal;
for (x=0; x<256; x++)
{
us = *pus++; // get RGB565 palette entry
- *d++ = ((us >> 8) & 0xf8) | (us >> 13); // R
- *d++ = ((us >> 3) & 0xfc) | ((us >> 9) & 0x3); // G
- *d++ = ((us & 0x1f) << 3) | ((us >> 2) & 0x7); // B
+ p->r = ((us >> 8) & 0xf8) | (us >> 13); // R
+ p->g = ((us >> 3) & 0xfc) | ((us >> 9) & 0x3); // G
+ p->b = ((us & 0x1f) << 3) | ((us >> 2) & 0x7); // B
+ p->a = 255;
+ p++;
}
}
y = pDraw->iY + pDraw->y; // current line
@@ -53,19 +56,6 @@ void GIFDraw(GIFDRAW *pDraw)
{
memcpy(d, s, pDraw->iWidth); // copy all of the pixels
}
- s = &image[(DISPLAY_WIDTH * y) + pDraw->iX];
- // Translate the 8-bit pixels through the palette
- d = (uint8_t *)screen.data;
- d += (y * DISPLAY_WIDTH * 3) + (pDraw->iX * 3);
- for (x=0; x<pDraw->iWidth; x++)
- {
- uint8_t *ppal = &palTemp[s[0] * 3];
- s++;
- d[0] = *ppal++;
- d[1] = *ppal++;
- d[2] = *ppal++;
- d += 3;
- }
} /* GIFDraw() */
/* setup */
@@ -75,9 +65,11 @@ void init() {
gif.begin(LITTLE_ENDIAN_PIXELS);
gif.open((uint8_t *)badger, sizeof(badger), GIFDraw);
+ gif_surface.palette = pal;
}
void render(uint32_t time) {
+ screen.blit(&gif_surface, Rect(Point(0, 0), gif_surface.bounds), Point(0, 0));
}
void update(uint32_t time) {A bit less efficient, but more "correct". A bit nitpick-y, but the other examples use '-' in the name instead of '_'... |
|
Awesome! Will try this out as soon as I can. In the interim- it fails to build for EMScripten, Linux, MinGW (Windows) with various verisons of a missing You can see the build tasks and output here - https://github.com/pimoroni/32blit-beta/pull/398/checks?check_run_id=1238409623 Plus todo for me post merge- add to VSCode Solution. |
|
Our Great Travis CI Exodus has left this in a state of continuous integration purgatory. If you get a time to bump it and kick off the tests (I don't seem to be able to do that from the GitHub UI) it'd be appreciated, thank you! |
|
This is probably a good example of an example which could be its own repository. There's value in demonstrating how to work with an external lib, but possibly not in the main SDK examples. |
|
Feels like it would be a valuable exercise to hold a 'master list' of examples and sample games that should exist as distinct (boilerplate-based?) repos; that way anyone who wants to contribute can pick something off the list - could act as a handy 'prompt' for folk who want to contribute but appreciate inspiration (looks at self). |
Please add my Animated GIF library to the examples