Typos fixed
[sdlgit/SDL_perl.git] / t / core_video.t
CommitLineData
df4106bf 1#!/usr/bin/perl -w
df4106bf 2use strict;
3use SDL;
2739f940 4use SDL::Color;
4510df28 5use SDL::Surface;
df4106bf 6use SDL::Config;
7fa192d4 7use Devel::Peek;
4510df28 8use Data::Dumper;
df4106bf 9use Test::More;
eaf32d63 10use SDL::Rect;
df4106bf 11
b3cdeb39 12plan ( tests => 21 );
df4106bf 13
14use_ok( 'SDL::Video' );
494f077a 15
16my @done =
17 qw/
df4106bf 18 get_video_surface
19 get_video_info
8a2411d0 20 video_driver_name
7dda1934 21 list_modes
bbe5d2f5 22 set_video_mode
218b5471 23 video_mode_ok
eaf32d63 24 update_rect
25 update_rects
19f3ee7b 26 flip
2739f940 27 set_colors
69341787 28 set_palette
5e9f2784 29 set_gamma
7b7e8017 30 set_gamma_ramp
2d2bb756 31 map_RGB
32 map_RGBA
494f077a 33 /;
69341787 34
494f077a 35can_ok ('SDL::Video', @done);
95f5be30 36
37#testing get_video_surface
d5a2f5ac 38SDL::init(SDL_INIT_VIDEO);
95f5be30 39
0a01cb9e 40my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE );
41
42if(!$display){
56edfae7 43 plan skip_all => 'Couldn\'t set video mode: '. SDL::geterror();
0a01cb9e 44 }
95f5be30 45
218b5471 46#diag('Testing SDL::Video');
95f5be30 47
e4259ddb 48isa_ok(SDL::Video::get_video_surface(), 'SDL::Surface', '[get_video_surface] Checking if we get a surface ref back');
49
50isa_ok(SDL::Video::get_video_info(), 'SDL::VideoInfo', '[get_video_info] Checking if we get videoinfo ref back');
20f544ea 51
7fa192d4 52my $driver_name = SDL::Video::video_driver_name();
53
e4259ddb 54pass '[video_driver_name] This is your driver name: '.$driver_name;
7fa192d4 55
218b5471 56
57
58is( ref( SDL::Video::list_modes( $display->format , SDL_SWSURFACE )), 'ARRAY', '[list_modes] Returned an ARRAY! ');
59
60cmp_ok(SDL::Video::video_mode_ok( 100, 100, 16, SDL_SWSURFACE), '>=', 0, "[video_mode_ok] Checking if an integer was return");
7fa192d4 61
bbe5d2f5 62isa_ok(SDL::Video::set_video_mode( 100, 100 ,16, SDL_SWSURFACE), 'SDL::Surface', '[set_video_more] Checking if we get a surface ref back');
63
64
bbe5d2f5 65#TODO: Write to surface and check inf pixel in that area got updated.
66
eaf32d63 67SDL::Video::update_rect($display, 0, 0, 0, 0);
68
bbe5d2f5 69#TODO: Write to surface and check inf pixel in that area got updated.
eaf32d63 70SDL::Video::update_rects($display, SDL::Rect->new(0, 10, 20, 20));
71
b9125226 72my $value = SDL::Video::flip($display);
73is( ($value == 0) || ($value == -1), 1, '[flip] returns 0 or -1' );
19f3ee7b 74
f00538b9 75$value = SDL::Video::set_colors($display, 0, SDL::Color->new(0,0,0));
76is( $value , 0, '[set_colors] returns 0 trying to write to 32 bit display' );
2739f940 77
5e9f2784 78$value = SDL::Video::set_palette($display, SDL_LOGPAL|SDL_PHYSPAL, 0);
69341787 79
80is( $value , 0, '[set_palette] returns 0 trying to write to 32 bit surface' );
81
7b7e8017 82my $zero = [0,0,0,0];
83SDL::Video::set_gamma_ramp($zero, $zero, $zero); pass '[set_gamma_ramp] ran';
69341787 84
5e9f2784 85SDL::Video::set_gamma( 1.0, 1.0, 1.0 ); pass '[set_gamma] ran ';
69341787 86
0a01cb9e 87my @b_w_colors;
88
89for(my $i=0;$i<256;$i++){
90 $b_w_colors[$i] = SDL::Color->new($i,$i,$i);
91 }
f00538b9 92my $hwdisplay = SDL::Video::set_video_mode(640,480,8, SDL_HWSURFACE );
93
94if(!$hwdisplay){
56edfae7 95 plan skip_all => 'Couldn\'t set video mode: '. SDL::geterror();
f00538b9 96 }
97
98$value = SDL::Video::set_colors($hwdisplay, 0);
99is( $value , 0, '[set_colors] returns 0 trying to send empty colors to 8 bit surface' );
100
5e9f2784 101$value = SDL::Video::set_palette($hwdisplay, SDL_LOGPAL|SDL_PHYSPAL, 0);
69341787 102
103is( $value , 0, '[set_palette] returns 0 trying to send empty colors to 8 bit surface' );
bc1947c7 104
494f077a 105
f00538b9 106$value = SDL::Video::set_colors($hwdisplay, 0, @b_w_colors);
107is( $value , 1, '[set_colors] returns '.$value );
0a01cb9e 108
5e9f2784 109$value = SDL::Video::set_palette($hwdisplay, SDL_LOGPAL|SDL_PHYSPAL, 0, @b_w_colors );
69341787 110
111is( $value , 1, '[set_palette] returns 1' );
112
113
2d2bb756 114is( SDL::Video::map_RGB($hwdisplay->format, 10, 10 ,10) > 0, 1, '[map_RGB] maps correctly to 8-bit surface');
115is( SDL::Video::map_RGBA($hwdisplay->format, 10, 10 ,10, 10) > 0, 1, '[map_RGBA] maps correctly to 8-bit surface');
494f077a 116
117my @left = qw/
df4106bf 118 get_gamma_ramp
df4106bf 119 get_RGB
120 get_RGBA
121 create_RGB_surface_from
122 lock_surface
123 unlock_surface
124 convert_surface
125 display_format
126 display_format_alpha
127 load_BMP
128 save_BMP
129 set_color_key
130 set_alpha
131 set_clip_rect
132 get_clip_rect
133 blit_surface
134 fill_rect
135 GL_load_library
136 GL_get_proc_address
137 GL_get_attribute
138 GL_set_attribute
139 GL_swap_buffers
140 GL_attr
df4106bf 141 lock_YUV_overlay
142 unlock_YUV_overlay
143 display_YUV_overlay
494f077a 144 /;
145
146my $why = '[Percentage Completion] '.int( 100 * $#done / ($#done + $#left) ) ."\% implementation. $#done / ".($#done+$#left);
147
148TODO:
149{
2739f940 150 local $TODO = $why;
151 pass "\nThe following functions:\n".join ",", @left;
494f077a 152}
2739f940 153 diag $why;
154
df4106bf 155
8be6ce42 156pass 'Are we still alive? Checking for segfaults';