use SDL::SFont;
use SDL::Color;
use SDL::Rect;
-
+use Data::Dumper;
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
}
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]);
}
}
}
sub blit {
+ $_[1] = 0 unless defined $_[1];
+ $_[3] = 0 unless defined $_[3];
+
if ($SDL::DEBUG) {
- croak "SDL::Surface::blit does not accept undef use SDL::NULL" if ( !defined($_[1]) || !defined($_[3]) );
croak "SDL::Surface::blit requires SDL::Rect objects"
unless ($_[1] == 0 || $_[1]->isa('SDL::Rect'))
&& ($_[3] == 0 || $_[3]->isa('SDL::Rect'));
croak "SDL::Surface::blit requires SDL::Surface objects"
unless $_[2]->isa('SDL::Surface');
}
-
- SDL::BlitSurface(map { (defined($_) && $_ != 0)? ${$_} : $_ } @_) if defined(@_);
+ #BlitSurface ( src, src_rect, dest, dest_rect )
+
+ SDL::BlitSurface( ${$_[0]}, $_[1], ${$_[2]}, $_[3]);
}
sub set_colors {
$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);
C<SDL::Surface::display_format> converts the surface to the same format as the
current screen.
+=head2 display_format_alpha ()
+
+C<SDL::Surface::display_format_alpha> converts the surface to the same format as the
+current screen, plus an alpha channel.
+
=head2 rgb ()
-C<SDL::Surface::rgb> converts the surface to a 24 bit rgb format regardless of the
-initial format.
+
+C<SDL::Surface::rgb> converts the surface to a 24 bit rgb format regardless of the initial format.
=head2 rgba ()
-C<SDL::Surface::rgba> converts the surface to a 32 bit rgba format regarless of the
-initial format.
+
+C<SDL::Surface::rgba> converts the surface to a 32 bit rgba format regarless of the initial format.
=head2 print (x,y,text...)