2 # Copyright (C) 2009 kthakore
4 # Spec tests for SDL::Surface
8 unshift @INC, 'blib/lib', 'blib/arch';
18 use Test::More tests => 15;
21 = SDL::Surface->new( SDL::SDL_ANYFORMAT(), 640, 320, 8, 0, 0, 0, 0 );
22 isa_ok( $surface, 'SDL::Surface' );
23 is( $surface->w, 640, 'surface has width' );
24 is( $surface->h, 320, 'surface has height' );
25 is( $surface->pitch, 640, 'surface has pitch' );
26 my $clip_rect = SDL::Rect->new( 0, 0, 0, 0 );
27 SDL::GetClipRect( $surface, $clip_rect );
28 isa_ok( $clip_rect, 'SDL::Rect' );
29 is( $clip_rect->x, 0, 'clip_rect has x' );
30 is( $clip_rect->y, 0, 'clip_rect has y' );
31 is( $clip_rect->w, 640, 'clip_rect has width' );
32 is( $clip_rect->h, 320, 'clip_rect has height' );
34 my $image = SDL::Surface->load('test/data/logo.png');
35 is( $image->w, 608, 'image has width' );
36 is( $image->h, 126, 'image has height' );
38 $surface->fill_rect( SDL::Rect->new( 0, 0, 32, 32 ),
39 SDL::Color->new( 200, 200, 200 ) );
40 ok( 1, 'Managed to fill_rect' );
42 my $small_rect = SDL::Rect->new( 0, 0, 64, 64 );
43 $image->blit( $small_rect, $surface, $small_rect );
44 ok( 1, 'Managed to blit' );
46 #my $image_format = $surface->display;
47 #$surface->update_rect( 0, 0, 32, 32 );
48 #ok( 1, 'Managed to update_rect' );
49 #$surface->update_rects( SDL::Rect->new( 0, 0, 32, 32 ) );
50 #ok( 1, 'Managed to update_rects' );
52 my $app = SDL::App->new(
56 -init => SDL_INIT_VIDEO
61 my $rect = SDL::Rect->new( 0, 0, $app->w, $app->h );
63 my $blue = SDL::Color->new( 0x00, 0x00, 0xff, );
65 $app->fill_rect( $rect, $blue );
67 diag( 'This is in surface : ' . SDL::Surface::get_pixels($app) );