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