The SDL forums have moved to discourse.libsdl.org.
This is just a read-only archive of the previous forums, to keep old links working.
SDL
Simple Directmedia Layer Forums
SDLActivity, showimage.c and SDL_RenderCopy
Jacob Ole Juul Kolding
Guest
Posted: Fri Mar 23, 2012 7:38 pm
Hello List
while trying to understand the basics about SDL2.0 on Android
I have combined the SDLActivity example and the showimage.c example from SDL_image.
It is successful in that it does start and creates a window on the Android (both emu and real device)
but so far I can't get it to show the image in the SDL window.
the draw_background function however works fine.
I don't know what the problem is or if SDL_RenderCopy should actually show the image?
/* Draw a Gimpish bacqkground pattern to show transparency in the image */
static void draw_background(SDL_Renderer *renderer, int w, int h)
{
SDL_Color col[2] = {
{ 0x66, 0x66, 0x66, 0xff },
{ 0x99, 0x99, 0x99, 0xff },
};
int i, x, y;
SDL_Rect rect;
rect.w = 8;
rect.h = 8;
for (y = 0; y < h; y += rect.h) {
for (x = 0; x < w; x += rect.w) {
/* use an 8x8 checkerboard pattern */
i = (((x ^ y) >> 3) & 1);
SDL_SetRenderDrawColor(renderer, col[i].r, col[i].g, col[i].b, col[i].unused);