Skip to content

Commit

Permalink
merged with experimental
Browse files Browse the repository at this point in the history
  • Loading branch information
Tobias Leich committed Mar 19, 2011
2 parents 67b709e + 9926ffa commit bee3715
Show file tree
Hide file tree
Showing 10 changed files with 47 additions and 75 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG
@@ -1,5 +1,10 @@
Revision history for Perl extension SDL_perl. Revision history for Perl extension SDL_perl.


* 2.531_02 March 19 2011
- Fixes for several examples [jtpalmer]
- Fixes for INSTALL/README file [Pip]
- Fixes for draw_rect [FROGGS]

* 2.531_01 March 9 2011 * 2.531_01 March 9 2011
New features: New features:
- SDLx::Surface draw_polygon(), linking GFX to Surfaces when available [FROGGS] - SDLx::Surface draw_polygon(), linking GFX to Surfaces when available [FROGGS]
Expand Down
3 changes: 1 addition & 2 deletions INSTALL
Expand Up @@ -18,14 +18,13 @@ following libraries (as pre-compiled DLLs for Microsoft Windows platforms):


* libSDL * libSDL
* png * png
* tiff
* jpeg * jpeg
* smpeg * smpeg
* OpenGL (GL) * OpenGL (GL)
* GLUT (GLU) * GLUT (GLU)
* SDL_image * SDL_image
* SDL_mixer * SDL_mixer
* SDL_net
* SDL_tiff
* SDL_gfx * SDL_gfx
* SDL_ttf * SDL_ttf


Expand Down
51 changes: 6 additions & 45 deletions README
@@ -1,53 +1,14 @@
NAME NAME
SDL_perl - Simple DirectMedia Layer for Perl SDL Perl - Simple DirectMedia Layer for Perl

SYNOPSIS SYNOPSIS
use SDL; use SDL;

DESCRIPTION DESCRIPTION
SDL_perl is a package of Perl modules that provide both functional and SDL Perl is a package of Perl modules that provide both functional and
object oriented interfaces to the Simple DirectMedia Layer for Perl 5. object oriented interfaces to the Simple DirectMedia Layer for Perl 5.
This package takes some liberties with the SDL API, and attempts to adhere This package takes some liberties with the SDL API, and attempts to adhere
to the spirit of both the SDL and Perl. to the spirit of both the SDL and Perl.

The SDL Perl 2009 Development Team
Documentation
Nick: magnet

Perl Development
Nick: Garu
Name: Breno G. de Oliveira

Nick: Dngor
Name: Rocco Caputo

Nick: nferraz
Name: Nelson Ferraz

Nick: monsenhor
Name: Ricardo Filipo

Maintainance
Nick: kthakore
Name: Kartik Thakore


Nick: FROGGS The SDL Perl Development Team
Name: Tobias Leich Please see: HTTPS://GitHub.Com/PerlGameDev/SDL/contributors

MacOSX Experimental Usage
Please get libsdl packages from Fink

perl Build.PL
perl Build test
perl Build Bundle
perl Build install

Running SDL Perl Scripts in MacOSX
First set the PERL5LIB environment variable to the dependencies of your
script

%export PERL5LIB=$PERL5LIB:./lib

Use the SDLPerl executable made in the bundle and call your scripts

%SDLPerl.app/Contents/MacOS/SDLPerl yourScript.pl
4 changes: 2 additions & 2 deletions examples/SDLx/SDLx_sprite_animated.pl
Expand Up @@ -17,12 +17,12 @@
); );


my $sprite = SDLx::Sprite::Animated->new( my $sprite = SDLx::Sprite::Animated->new(
image => 'test/data/hero.png', image => 'test/data/hero.bmp',
rect => SDL::Rect->new( 48, 0, 48, 48 ), rect => SDL::Rect->new( 48, 0, 48, 48 ),
ticks_per_frame => 6, ticks_per_frame => 6,
); );
$sprite->set_sequences( left => [ [ 1, 0 ], [ 1, 1 ], [ 1, 2 ] ], ); $sprite->set_sequences( left => [ [ 1, 0 ], [ 1, 1 ], [ 1, 2 ] ], );
$sprite->alpha_key( SDL::Color->new( 0xfc, 0x00, 0xff ) ); $sprite->alpha_key( SDL::Color->new( 0xff, 0x00, 0xff ) );
$sprite->sequence('left'); $sprite->sequence('left');
$sprite->start(); $sprite->start();
my $x = 0; my $x = 0;
Expand Down
4 changes: 2 additions & 2 deletions examples/SDLx/pong.pl
Expand Up @@ -123,7 +123,7 @@ sub on_move {
} }


sub on_event { sub on_event {
my $event = shift; my ( $event, $app ) = @_;


if ( $event->type == SDL_KEYDOWN ) { if ( $event->type == SDL_KEYDOWN ) {
my $key = $event->key_sym; my $key = $event->key_sym;
Expand All @@ -144,7 +144,7 @@ sub on_event {
$paddle->{y_vel} += $paddle->{vel} if $key == SDLK_UP; $paddle->{y_vel} += $paddle->{vel} if $key == SDLK_UP;
$paddle->{y_vel} -= $paddle->{vel} if $key == SDLK_DOWN; $paddle->{y_vel} -= $paddle->{vel} if $key == SDLK_DOWN;
} elsif ( $event->type == SDL_QUIT ) { } elsif ( $event->type == SDL_QUIT ) {
$app->stop(); exit;
} }
} }


Expand Down
5 changes: 4 additions & 1 deletion examples/cookbook/pogl_sdl_texture.pl
Expand Up @@ -115,7 +115,10 @@ sub LoadTexture {
my $nOfColors; my $nOfColors;
my $texture_format; my $texture_format;
my $texture = 0; my $texture = 0;
$surface = SDL::Image::load( $ARGV[0] ); my $img = $ARGV[0] || 'test/data/picture.bmp';

$surface = SDL::Image::load( $img );
die "Couldn't load image: ".SDL::get_error() unless $surface;
SDL::Video::lock_surface($surface); SDL::Video::lock_surface($surface);


#get the number of channels in the SDL surface #get the number of channels in the SDL surface
Expand Down
3 changes: 1 addition & 2 deletions examples/pixel_operations/starry.pl
Expand Up @@ -26,8 +26,7 @@


my $display_matrix = SDLx::Surface->new( surface => $app ); my $display_matrix = SDLx::Surface->new( surface => $app );


#foreach(0..300) while ( !$quit ) {
while (1) {


SDL::Events::pump_events(); SDL::Events::pump_events();
while ( SDL::Events::poll_event($event) ) { while ( SDL::Events::poll_event($event) ) {
Expand Down
2 changes: 1 addition & 1 deletion examples/pixel_operations/tie_matrix.pl
Expand Up @@ -75,7 +75,7 @@ sub update {


foreach ( 0 ... rand( $surface->w ) ) { foreach ( 0 ... rand( $surface->w ) ) {


$matrix->[$_][ rand( $surface->h ) ] = 0xFFFFFFFF / ( $_ + 1 ); $matrix->[$_][ rand( $surface->h ) ] = int(0xFFFFFFFF / ( $_ + 1 ));


} }
SDL::Video::unlock_surface($surface); SDL::Video::unlock_surface($surface);
Expand Down
31 changes: 19 additions & 12 deletions lib/SDLx/FPS.pm
Expand Up @@ -8,24 +8,31 @@ our @ISA = qw(SDL::GFX::FPSManager);


sub new { sub new {
my ( $class, @args ) = @_; my ( $class, @args ) = @_;

my %options;
if ( ref $args[0] ) { if ( ref $args[0] ) {
my %options = %{ $args[0] }; %options = %{ $args[0] };
if ( @args > 1 ) { if ( @args > 1 ) {
Carp::cluck("Extra arguments are not taken when hash is specified"); Carp::cluck("Extra arguments are not taken when hash is specified");
} }
for ( } else {
grep { %options = @args;
my $key = $_; }
!grep $_ eq $key, qw/fps framecount rateticks lastticks rate/;
} keys %options if ( keys %options > 4 ) {
)
{
Carp::cluck("Unrecognized constructor hash key: $_");
}
@args = ( @options{qw/fps framecount rateticks lastticks rate/} );
} elsif ( @args > 4 ) {
Carp::cluck("Too many arguments given"); Carp::cluck("Too many arguments given");
} }

for (
grep {
my $key = $_;
!grep $_ eq $key, qw/fps framecount rateticks lastticks rate/;
} keys %options
)
{
Carp::cluck("Unrecognized constructor hash key: $_");
}
@args = ( @options{qw/fps framecount rateticks lastticks rate/} );
my $fps = $class->SDL::GFX::FPSManager::new( my $fps = $class->SDL::GFX::FPSManager::new(
map defined() ? $_ : 0, map defined() ? $_ : 0,
@args[ 1 .. 4 ] @args[ 1 .. 4 ]
Expand Down
14 changes: 6 additions & 8 deletions src/SDLx/Surface.xs
Expand Up @@ -182,26 +182,23 @@ surfacex_draw_rect ( surface, rt, color )
SV* rt SV* rt
SV* color SV* color
CODE: CODE:
Uint32 m_color = __map_rgba( color, surface->format );
SDL_Rect r_rect; SDL_Rect r_rect;
SV* foo;


if( SvOK(rt) ) if( SvOK(rt) )
{ {
int newly_created_rect = 0; int newly_created_rect = 0;
foo = rect( rt, &newly_created_rect ); SV* foo = rect( rt, &newly_created_rect );
r_rect = *(SDL_Rect*)bag2obj(foo); r_rect = *(SDL_Rect*)bag2obj(foo);
SDL_FillRect(surface, &r_rect, m_color);
SvREFCNT_dec(foo);
} }
else else
{ {
r_rect.x = 0; r_rect.y = 0; r_rect.w = surface->w; r_rect.h = surface->h; r_rect.x = 0; r_rect.y = 0; r_rect.w = surface->w; r_rect.h = surface->h;
SDL_FillRect(surface, &r_rect, m_color);
} }


Uint32 m_color = __map_rgba( color, surface->format );
SDL_FillRect(surface, &r_rect, m_color);

if( SvOK(rt) )
SvREFCNT_dec(foo);

void void
surfacex_draw_rect_blended ( surface, rt, color ) surfacex_draw_rect_blended ( surface, rt, color )
SDL_Surface *surface SDL_Surface *surface
Expand Down Expand Up @@ -235,6 +232,7 @@ surfacex_draw_rect_blended ( surface, rt, color )
if( SvOK(rt) ) if( SvOK(rt) )
SvREFCNT_dec(foo); SvREFCNT_dec(foo);



#ifdef HAVE_SDL_GFX_PRIMITIVES #ifdef HAVE_SDL_GFX_PRIMITIVES


int int
Expand Down

0 comments on commit bee3715

Please sign in to comment.