From: Javier S. Pedro Date: Mon, 29 Mar 2010 19:08:49 +0000 (+0200) Subject: new haa tests X-Git-Tag: sdlhaa_1_1_0~4 X-Git-Url: http://vcs.maemo.org/git/?p=sdlhildon;a=commitdiff_plain;h=6b9cd7a899d7e42f10f0dc20fc103baee7ccb409 new haa tests --- diff --git a/sdlhaa/test/Makefile b/sdlhaa/test/Makefile index 964a4c0..8d6139b 100644 --- a/sdlhaa/test/Makefile +++ b/sdlhaa/test/Makefile @@ -3,7 +3,7 @@ CFLAGS:=-g -O0 -Wall TEST_LDLIBS:=$(shell sdl-config --libs) -lSDL_haa TEST_CFLAGS:=$(shell sdl-config --cflags) -TESTS:=basic multi alpha fullscreen +TESTS:=basic multi alpha fullscreen switch all: $(TESTS) diff --git a/sdlhaa/test/fullscreen.c b/sdlhaa/test/fullscreen.c index 4511096..8fc660b 100644 --- a/sdlhaa/test/fullscreen.c +++ b/sdlhaa/test/fullscreen.c @@ -13,8 +13,6 @@ #include #include -static bool fullscreen = false; - static SDL_Surface *screen; static HAA_Actor *actor; @@ -32,15 +30,6 @@ static Uint32 tick(Uint32 interval, void* param) return interval; } -static void setup_video_mode() -{ - unsigned flags = SDL_SWSURFACE | (fullscreen ? SDL_FULLSCREEN : 0); - printf("video mode ...\n"); - screen = SDL_SetVideoMode(0, 0, 16, flags); - assert(screen); - printf("video mode set\n"); -} - int main() { int res; @@ -50,7 +39,8 @@ int main() res = HAA_Init(0); assert(res == 0); - setup_video_mode(); + screen = SDL_SetVideoMode(0, 0, 16, SDL_SWSURFACE | SDL_FULLSCREEN); + assert(screen); SDL_TimerID timer = SDL_AddTimer(10, tick, NULL); assert(timer != NULL); @@ -71,15 +61,10 @@ int main() case SDL_QUIT: goto quit; case SDL_VIDEOEXPOSE: - //HAA_SetRotation(actor, HAA_Y_AXIS, degrees, 0, 0, 0); + HAA_SetRotation(actor, HAA_Y_AXIS, degrees, 0, 0, 0); res = HAA_Flip(actor); assert(res == 0); break; - case SDL_MOUSEBUTTONUP: - printf("Switching fullscreen\n"); - fullscreen = !fullscreen; - setup_video_mode(); - break; } } @@ -91,3 +76,4 @@ quit: return 0; } + diff --git a/sdlhaa/test/switch.c b/sdlhaa/test/switch.c new file mode 100644 index 0000000..cd2414e --- /dev/null +++ b/sdlhaa/test/switch.c @@ -0,0 +1,97 @@ +/* fullscreen - a SDL_haa sample able to enter fullscreen mode + * + * This file is in the public domain, furnished "as is", without technical + * support, and with no warranty, express or implied, as to its usefulness for + * any purpose. + */ + +#include +#include +#include +#include + +#include +#include + +static bool fullscreen = false; + +static SDL_Surface *screen; + +static HAA_Actor *actor; + +static int degrees = 0; + +static Uint32 tick(Uint32 interval, void* param) +{ + SDL_Event e; + e.type = SDL_VIDEOEXPOSE; + + degrees = (degrees+2) % 360; + SDL_PushEvent(&e); + + return interval; +} + +static void setup_video_mode() +{ + unsigned flags = SDL_SWSURFACE | (fullscreen ? SDL_FULLSCREEN : 0); + printf("video mode ...\n"); + screen = SDL_SetVideoMode(0, 0, 16, flags); + assert(screen); + printf("updating haa ...\n"); + int res = HAA_SetVideoMode(); + assert(res == 0); + printf("video mode set\n"); +} + +int main() +{ + int res; + res = SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER); + assert(res == 0); + + res = HAA_Init(0); + assert(res == 0); + + setup_video_mode(); + + SDL_TimerID timer = SDL_AddTimer(10, tick, NULL); + assert(timer != NULL); + + actor = HAA_CreateActor(SDL_SWSURFACE, 200, 200, 16); + assert(actor); + + SDL_FillRect(actor->surface, NULL, + SDL_MapRGB(actor->surface->format, 255, 255, 0)); + + HAA_SetPosition(actor, 600, 120); + HAA_Show(actor); + + SDL_Event event; + while (SDL_WaitEvent(&event)) { + if (HAA_FilterEvent(&event) == 0) continue; + switch (event.type) { + case SDL_QUIT: + goto quit; + case SDL_VIDEOEXPOSE: + //HAA_SetRotation(actor, HAA_Y_AXIS, degrees, 0, 0, 0); + res = HAA_Flip(actor); + assert(res == 0); + break; + case SDL_MOUSEBUTTONUP: + printf("Switching fullscreen\n"); + fullscreen = !fullscreen; + setup_video_mode(); + break; + } + } + +quit: + HAA_FreeActor(actor); + + HAA_Quit(); + SDL_Quit(); + + return 0; +} +