PageRenderTime 25ms CodeModel.GetById 11ms app.highlight 11ms RepoModel.GetById 1ms app.codeStats 0ms

/t/core_video_convert_surface.t

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