1 /* alpha - a simple SDL_haa sample with a RGBA transparent actor
3 * This file is in the public domain, furnished "as is", without technical
4 * support, and with no warranty, express or implied, as to its usefulness for
16 static SDL_Surface *screen;
18 static HAA_Actor *actor;
20 static int degrees = 0;
22 static Uint32 tick(Uint32 interval, void* param)
25 e.type = SDL_USEREVENT;
27 degrees = (degrees+2) % 360;
28 SDL_PushEvent((SDL_Event*)&e);
36 res = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER);
42 screen = SDL_SetVideoMode(0, 0, 16, SDL_SWSURFACE);
45 SDL_FillRect(screen, NULL,
46 SDL_MapRGBA(screen->format, 150, 0, 0, 255));
48 SDL_Rect dark = {350, 180, 160, 50};
49 SDL_FillRect(screen, &dark,
50 SDL_MapRGBA(screen->format, 255, 0, 0, 255));
52 actor = HAA_CreateActor(SDL_SWSURFACE, 200, 200, 32);
55 SDL_FillRect(actor->surface, NULL,
56 SDL_MapRGBA(actor->surface->format, 0, 255, 0, 250));
58 SDL_Rect hole = {63, 63, 74, 74};
59 SDL_FillRect(actor->surface, &hole,
60 SDL_MapRGBA(actor->surface->format, 0, 0, 255, 80));
62 HAA_SetPosition(actor, 400, 160);
65 SDL_TimerID timer = SDL_AddTimer(10, tick, NULL);
66 assert(timer != NULL);
69 while (SDL_WaitEvent(&event)) {
70 if (HAA_FilterEvent(&event) == 0) continue;
75 res = HAA_Flip(actor);
77 res = SDL_Flip(screen);
81 HAA_SetRotation(actor, HAA_Y_AXIS, degrees, 0, 0, 0);
82 res = HAA_Commit(actor);