10 my (%options,$app,$mode);
12 die "usage: $0 [-hw] [-fullscreen] [-width 640] [-height 480] [-bpp 24]\n"
13 if ( SDL::in ($ARGV[0], qw/ -h -? --help/ ));
15 chdir 'test' if -d 'test';
16 die "$0 must be run in the SDL_perl/test/ directory!"
21 $options{$ARGV[$_]} = $ARGV[$_ + 1] || 1;
24 $options{-flags} = SDL_SWSURFACE;
25 $options{-flags} |= SDL_HWPALETTE if ( $options{-hw} );
26 $options{-flags} |= SDL_FULLSCREEN if ( $options{-fullscreen} );
28 $options{-title} = $0;
30 $options{-width} ||= 800;
31 $options{-height} ||= 600;
32 $options{-depth} ||= $options{-bpp} || 24;
34 $app = new SDL::App %options;
38 'electrohar.ttf' => 0,
42 '24P_Arial_NeonYellow.png' => 0,
43 '24P_Copperplate_Blue.png' => 0,
48 for ( reverse keys %ttfonts ) {
49 for $mode ( qw/ -normal -bold -italic -underline / ) {
51 print STDERR "Loading $_\n";
52 $ttfonts{"$_$mode"} = new SDL::Tool::Font
56 -fg => $SDL::Color::black,
57 -bg => $SDL::Color::black;
58 push @fonts, $ttfonts{"$_$mode"};
63 %ttfonts = reverse %ttfonts;
65 for ( reverse keys %sfonts) {
67 print STDERR "Loading $_\n";
68 $sfonts{$_} = new SDL::Tool::Font -sfont => "data/$_";
69 push @fonts, $sfonts{$_};
73 %sfonts = reverse %sfonts;
76 $app->fill(0,$SDL::Color::white);
78 for my $font ( @fonts) {
79 $font->print($app,$x,$y,"SDLperl font test. ",
80 "This is " . ($ttfonts{$font} || $sfonts{$font}));
89 SDL_KEYDOWN() => sub {
91 $app->warp($options{-width}/2,$options{-height}/2) if ($event->key_sym() == SDLK_SPACE);
92 $app->fullscreen() if ($event->key_sym() == SDLK_f);
93 exit(0) if ($event->key_sym() == SDLK_ESCAPE);
95 SDL_QUIT() => sub { exit(0); }