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 | |
0a01cb9e |
12 | plan ( tests => 14 ); |
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 |
494f077a |
28 | /; |
29 | can_ok ('SDL::Video', @done); |
95f5be30 |
30 | |
31 | #testing get_video_surface |
32 | SDL::Init(SDL_INIT_VIDEO); |
33 | |
0a01cb9e |
34 | my $display = SDL::Video::set_video_mode(640,480,32, SDL_SWSURFACE ); |
35 | |
36 | if(!$display){ |
37 | plan skip_all => 'Couldn\'t set video mode: '. SDL::GetError(); |
38 | } |
95f5be30 |
39 | |
218b5471 |
40 | #diag('Testing SDL::Video'); |
95f5be30 |
41 | |
e4259ddb |
42 | isa_ok(SDL::Video::get_video_surface(), 'SDL::Surface', '[get_video_surface] Checking if we get a surface ref back'); |
43 | |
44 | isa_ok(SDL::Video::get_video_info(), 'SDL::VideoInfo', '[get_video_info] Checking if we get videoinfo ref back'); |
20f544ea |
45 | |
7fa192d4 |
46 | my $driver_name = SDL::Video::video_driver_name(); |
47 | |
e4259ddb |
48 | pass '[video_driver_name] This is your driver name: '.$driver_name; |
7fa192d4 |
49 | |
218b5471 |
50 | |
51 | |
52 | is( ref( SDL::Video::list_modes( $display->format , SDL_SWSURFACE )), 'ARRAY', '[list_modes] Returned an ARRAY! '); |
53 | |
54 | cmp_ok(SDL::Video::video_mode_ok( 100, 100, 16, SDL_SWSURFACE), '>=', 0, "[video_mode_ok] Checking if an integer was return"); |
7fa192d4 |
55 | |
bbe5d2f5 |
56 | 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'); |
57 | |
58 | |
bbe5d2f5 |
59 | #TODO: Write to surface and check inf pixel in that area got updated. |
60 | |
eaf32d63 |
61 | SDL::Video::update_rect($display, 0, 0, 0, 0); |
62 | |
bbe5d2f5 |
63 | #TODO: Write to surface and check inf pixel in that area got updated. |
eaf32d63 |
64 | SDL::Video::update_rects($display, SDL::Rect->new(0, 10, 20, 20)); |
65 | |
b9125226 |
66 | my $value = SDL::Video::flip($display); |
67 | is( ($value == 0) || ($value == -1), 1, '[flip] returns 0 or -1' ); |
19f3ee7b |
68 | |
2739f940 |
69 | $value = SDL::Video::set_colors($display, 0); |
70 | is( $value , 0, '[set_colors] returns 0' ); |
71 | |
0a01cb9e |
72 | my @b_w_colors; |
73 | |
74 | for(my $i=0;$i<256;$i++){ |
75 | $b_w_colors[$i] = SDL::Color->new($i,$i,$i); |
76 | } |
bc1947c7 |
77 | |
494f077a |
78 | |
0a01cb9e |
79 | $value = SDL::Video::set_colors($display, 0, @b_w_colors); |
80 | is( $value , 0, '[set_colors] returns '.$value ); |
81 | |
82 | #TODO: check actual color in palette with get_palette |
494f077a |
83 | |
84 | my @left = qw/ |
df4106bf |
85 | set_palette |
86 | set_gamma |
87 | get_gamma_ramp |
88 | set_gmmma_ramp |
89 | map_RGB |
90 | map_RGBA |
91 | get_RGB |
92 | get_RGBA |
93 | create_RGB_surface_from |
94 | lock_surface |
95 | unlock_surface |
96 | convert_surface |
97 | display_format |
98 | display_format_alpha |
99 | load_BMP |
100 | save_BMP |
101 | set_color_key |
102 | set_alpha |
103 | set_clip_rect |
104 | get_clip_rect |
105 | blit_surface |
106 | fill_rect |
107 | GL_load_library |
108 | GL_get_proc_address |
109 | GL_get_attribute |
110 | GL_set_attribute |
111 | GL_swap_buffers |
112 | GL_attr |
df4106bf |
113 | lock_YUV_overlay |
114 | unlock_YUV_overlay |
115 | display_YUV_overlay |
494f077a |
116 | /; |
117 | |
118 | my $why = '[Percentage Completion] '.int( 100 * $#done / ($#done + $#left) ) ."\% implementation. $#done / ".($#done+$#left); |
119 | |
120 | TODO: |
121 | { |
2739f940 |
122 | local $TODO = $why; |
123 | pass "\nThe following functions:\n".join ",", @left; |
494f077a |
124 | } |
2739f940 |
125 | diag $why; |
126 | |
df4106bf |
127 | |
2739f940 |
128 | pass 'Are we still alive? Checkign for segfaults'; |