X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FSDL%2FSurface.pm;h=0d58261e778e881c93601b21dafc5375b160185f;hb=f00538b9ce5ee6785496931dbce910271112c961;hp=16eaefbad90725a437ef4b5f6bea5b63e6e880fa;hpb=7b6a53a1f5064ca5b8ab0243f7bcf6209e6bf5a4;p=sdlgit%2FSDL_perl.git diff --git a/lib/SDL/Surface.pm b/lib/SDL/Surface.pm index 16eaefb..0d58261 100644 --- a/lib/SDL/Surface.pm +++ b/lib/SDL/Surface.pm @@ -1,3 +1,15 @@ +package SDL::Surface; +use strict; +use warnings; +require Exporter; +require DynaLoader; +our @ISA = qw(Exporter DynaLoader); +bootstrap SDL::Surface; + +1; + +__END__ + #!/usr/bin/env perl # # Surface.pm @@ -37,7 +49,7 @@ use SDL; use SDL::SFont; use SDL::Color; use SDL::Rect; - +use Data::Dumper; sub new { my $proto = shift; my $class = ref($proto) || $proto; @@ -163,14 +175,10 @@ sub pixel { } sub fill { - croak "SDL::Surface::fill requires a SDL::Rect object" - unless !$SDL::DEBUG || $_[1] == 0 || $_[1]->isa('SDL::Rect'); - croak "SDL::Surface::fill requires a SDL::Color object" - unless !$SDL::DEBUG || $_[2]->isa('SDL::Color'); if ($_[1] == 0 ) { SDL::FillRect(${$_[0]},0,${$_[2]}); } else { - SDL::FillRect(${$_[0]},${$_[1]},${$_[2]}); + SDL::FillRect(${$_[0]},$_[1],$_[2]); } } @@ -202,6 +210,9 @@ sub flip { } sub blit { + $_[1] = 0 unless defined $_[1]; + $_[3] = 0 unless defined $_[3]; + if ($SDL::DEBUG) { croak "SDL::Surface::blit requires SDL::Rect objects" unless ($_[1] == 0 || $_[1]->isa('SDL::Rect')) @@ -209,7 +220,9 @@ sub blit { croak "SDL::Surface::blit requires SDL::Surface objects" unless $_[2]->isa('SDL::Surface'); } - SDL::BlitSurface(map { $_ != 0 ? ${$_} : $_ } @_); + #BlitSurface ( src, src_rect, dest, dest_rect ) + + SDL::BlitSurface( ${$_[0]}, $_[1], ${$_[2]}, $_[3]); } sub set_colors { @@ -240,6 +253,14 @@ sub display_format { $self; } +sub display_format_alpha { + my $self = shift; + my $tmp = SDL::DisplayFormatAlpha($$self); + SDL::FreeSurface ($$self); + $$self = $tmp; + $self; +} + sub rgb { my $self = shift; my $tmp = SDL::ConvertRGB($$self); @@ -526,13 +547,18 @@ C takes a value from 0x00 to 0xff. C converts the surface to the same format as the current screen. +=head2 display_format_alpha () + +C converts the surface to the same format as the +current screen, plus an alpha channel. + =head2 rgb () -C converts the surface to a 24 bit rgb format regardless of the -initial format. + +C converts the surface to a 24 bit rgb format regardless of the initial format. =head2 rgba () -C converts the surface to a 32 bit rgba format regarless of the -initial format. + +C converts the surface to a 32 bit rgba format regarless of the initial format. =head2 print (x,y,text...)