/
core_video_convert_surface.t
57 lines (45 loc) · 1.46 KB
/
core_video_convert_surface.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
use strict;
use SDL;
use SDL::Rect;
use SDL::Color;
use SDL::Video;
use SDL::Surface;
use SDL::PixelFormat;
use SDL::Palette;
use Test::More;
use Data::Dumper;
use Devel::Peek;
use lib 't/lib';
use SDL::TestTool;
my $videodriver = $ENV{SDL_VIDEODRIVER};
$ENV{SDL_VIDEODRIVER} = 'dummy' unless $ENV{SDL_RELEASE_TESTING};
if ( !SDL::TestTool->init(SDL_INIT_VIDEO) ) {
plan( skip_all => 'Failed to init video' );
}
my $hwdisplay = SDL::Video::set_video_mode( 640, 480, 8, SDL_HWSURFACE );
my $surface = SDL::Video::convert_surface( $hwdisplay, $hwdisplay->format, 0 );
isa_ok(
$surface, 'SDL::Surface',
'[convert_surface] makes copy of surface correctly'
);
warn 'Copy conversion failed: ' . SDL::get_error if !$surface;
my $display = SDL::Surface->new( SDL_HWSURFACE, 640, 480, 8, 0, 0, 0, 0 );
my $surface2 = SDL::Video::convert_surface( $display, $hwdisplay->format, 0 );
isa_ok(
$surface2, 'SDL::Surface',
'[convert_surface] makes copy of surface converted surface HW->HW'
);
warn 'HW->HW conversion failed: ' . SDL::get_error if !$surface2;
$display = SDL::Surface->new( SDL_SWSURFACE, 640, 480, 8, 0, 0, 0, 0 );
my $surface3 = SDL::Video::convert_surface( $display, $hwdisplay->format, 0 );
isa_ok(
$surface3, 'SDL::Surface',
'[convert_surface] makes copy of surface converted surface SW->SW'
);
warn 'SW->SW conversion failed: ' . SDL::get_error if !$surface3;
if ($videodriver) {
$ENV{SDL_VIDEODRIVER} = $videodriver;
} else {
delete $ENV{SDL_VIDEODRIVER};
}
done_testing;