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