Commit | Line | Data |
b7ed9095 |
1 | #!perl -w |
2 | # Copyright (C) 2009 kthakore |
3 | # |
4 | # Spec tests for SDL::Surface |
5 | # |
6 | |
7 | BEGIN { |
9a70569a |
8 | unshift @INC, 'blib/lib', 'blib/arch'; |
9 | } |
b7ed9095 |
10 | |
11 | use strict; |
12 | use SDL; |
13 | use SDL::Config; |
14 | use SDL::Surface; |
15 | use SDL::App; |
16 | use SDL::Rect; |
17 | use SDL::Color; |
41a5a9ee |
18 | use Test::More tests => 17; |
9a70569a |
19 | |
20 | my $surface |
af85b4e9 |
21 | = SDL::Surface->new( SDL::SDL_ANYFORMAT(), 640, 320, 8, 0, 0, 0, 0 ); |
9a70569a |
22 | isa_ok( $surface, 'SDL::Surface' ); |
af85b4e9 |
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' ); |
9a70569a |
33 | |
a7fbee87 |
34 | my $image = SDL::IMG_Load('test/data/logo.png'); |
9a70569a |
35 | is( $image->w, 608, 'image has width' ); |
36 | is( $image->h, 126, 'image has height' ); |
37 | |
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' ); |
41 | |
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' ); |
45 | |
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' ); |
51 | |
52 | my $app = SDL::App->new( |
53 | -title => "Test", |
54 | -width => 640, |
55 | -height => 480, |
56 | -init => SDL_INIT_VIDEO |
57 | ); |
b7ed9095 |
58 | |
59 | pass 'did this pass'; |
60 | |
41a5a9ee |
61 | my $image_format = $image->display; |
62 | isa_ok( $image_format, 'SDL::Surface' ); |
63 | |
64 | my $image_format_alpha = $image->display_alpha; |
65 | isa_ok( $image_format_alpha, 'SDL::Surface' ); |
66 | |
9a70569a |
67 | my $rect = SDL::Rect->new( 0, 0, $app->w, $app->h ); |
b7ed9095 |
68 | |
9a70569a |
69 | my $blue = SDL::Color->new( 0x00, 0x00, 0xff, ); |
b7ed9095 |
70 | |
9a70569a |
71 | $app->fill_rect( $rect, $blue ); |
b7ed9095 |
72 | |
9a70569a |
73 | diag( 'This is in surface : ' . SDL::Surface::get_pixels($app) ); |
b7ed9095 |
74 | |
75 | pass 'did this pass'; |
76 | |