From d8c2572a18cbb731df7ed4dfb8e16001819da242 Mon Sep 17 00:00:00 2001 From: PipStuart Date: Thu, 17 Mar 2011 16:05:33 -0500 Subject: [PATCH 01/11] B3HG491: Removed SDL_net && renamed SDL_tiff to just tiff as FROGGS asked me to. --- INSTALL | 196 +++++++++++++++++--------------------------------------- 1 file changed, 59 insertions(+), 137 deletions(-) diff --git a/INSTALL b/INSTALL index 23235c72..05e1f106 100644 --- a/INSTALL +++ b/INSTALL @@ -1,162 +1,86 @@ ------------------------------------------------------------------------------ | SDL Perl -| Install Information Doc +| INSTALL Information Doc ------------------------- -Well, there has to become a time when every project has a file dictating the -best known way to install a program. - -In this case, the time is now. - Table of Contents: - 1 : System Requirements [ANAL1] - 2 : Grabbing the necessary version of SDL Perl, release [PROD2] - 3 : Same as above, but of the bleeding edge variety [EMO3] - -ANAL1: System Requirements - -For SDL Perl, you will, of course need a copy of libSDL. Which should be -available via your system's usual method of grabbing this. Generally a -package manager similar to Gentoo's Emerge, Fedora's yum, opensuse's YaST, -Debian|Ubuntu's apt, etc., etc., will have libSDL as the package. I (Katrina -Payne) really have no idea the best method to get it working in the best -practice method on Windows. - -Anyways, oddly enough, SDL Perl's package on your system may not include all -the files required for this to properly install. Go figure, huh? - -Additional libaries you need to make certain are on your systems: - - * png - * jpeg - * smpeg - * OpenGL (GL) - * GLUT (GLU) - * SDL_image - * SDL_mixer - * SDL_net - * SDL_tiff - * SDL_gfx - * SDL_ttf - -Yeah, there are allegedly tests to make sure these are on your system, -however sometimes we are a little forgetful, and we miss them. - -PROD2: Grabbing the Necessary Version of SDL Perl, release - -This is kind of redundant at this point, as you more than likely have this -file, or most likely do not need this section. However, for the sake of -completeness, I am including this (perhaps this section should be the one with -the ANAL1 find index?). - -(skip to 0COOL if you have cpan set up on your system) - -Anyways go onto your shell, assuming it is bash, and not something silly like -tcsh, ksh, zsh or lispsh (in which case, you likely know what you are doing), -type the following (FOR GREAT JUSTICE!): - - $ perl -MCPAN -e "shell" - -General convention states that prefixing a command with a '$' indicates you -are doing this command in Userland. Do _not_ type the dollar sign. If you -really do like typing dollar signs compulsively, we do have a donation button -that you make use of. - -You will be confronted with a large amount of options for how to properly set -this up. As far as I (Katrina) am (is) aware, generally the defaults should be -fine for most cases. In the odd cases they are not, well check the contacts -information for more details. In the CONTACTS file (eventually). - -0COOL - -In the very odd occurance that you have already done this in this shell in -some previous time in a spot that this user can see the required items for, -you would simply type: +----------------- + * System Requirements + * Grabbing the Necessary Version of SDL Perl, Release + * Same as Above, but Bleeding Edge - $ cpan +System Requirements: +------------------- -You will be presented with the CPAN prompt at this point. It is best if you -type the following command to make certain you are aware of the options -involved in the matter as you are doing this, incase I (Katrina) screw up -this file, and you can let me (Katrina) know fully well, how much of a screw -up you think I made: +SDL Perl's package on your system should be able to install everything needed +for the SDL module to be properly installed. FYI, this may include the +following libraries (as pre-compiled DLLs for Microsoft Windows platforms): - CPAN> help + * libSDL + * png + * tiff + * jpeg + * smpeg + * OpenGL (GL) + * GLUT (GLU) + * SDL_image + * SDL_mixer + * SDL_gfx + * SDL_ttf -Yeah, CPAN> denotes we are now inside CPAN BTW. And know you know, and -knowing is half the battle. +Grabbing the Necessary Version of SDL Perl, Release: +--------------------------------------------------- -After this, you should prolly make certain your kit is up to date. This can -be done via: +It might be a good idea to run from your shell prompt (where the '$' dollar- +sign denotes the prompt itself, so what you should type follows it): - CPAN> upgrade /.*/ + $ cpan -I am certain some of the other more established monks will prolly be -thwapping me with their canes (I am hoping for a high grade mahogany, made by -the trees on the planet Malkior 7, where the trees are over 400 feet high. -AND BREATHE FIRE! Built through the ancient blood rituals of the Malkior -People, these canes are nigh indestructable and can bend the fabric of the -universe--they are also a very fine material. Very impressive) +You will be presented with the CPAN prompt at this point. -Alright now that your kit is insanely up to date you would type: + CPAN> upgrade /.*/ - CPAN> install SDLPerl +Yeah, CPAN> denotes we are now prompted inside CPAN and recommending upgrading +everything out-of-date. Then with your site up-to-date: -Now you are ready to run and program SDLPerl applications. + CPAN> install SDL -EMO3: Same as Above, but The Bleeding Edge. +This should fully prepare you to run and program SDL Perl applications. -If you have already initially grab the git repo, jump do to [9CEREAL] +Same as Above, but Bleeding Edge: +-------------------------------- -Well, in this case you will need git install onto the computer. This project, -at the time of writing this (20091022), uses github to manage its services. -You can grab your copy of the git repo via: +As of Thu Mar 17, 2011, you'll need git installed on your machine in order to +clone from GitHub by running: - $ git clone git://github.com/kthakore/SDL_perl.git + $ git clone https://GitHub.Com/PerlGameDev/SDL.git -In case you did not read [PROD2], the '$' you have here indicates that this -stuff is typed into a shell prompt in somewhere in userland. You do not -actually need to type the '$' on the shell. Your shell provides the Big Money -for you!... unless you are using something odd like tcsh... or know how to -customised your prompt... or possibly 1006 other posibilities that have not -really occured to me (Katrina) at the time of writing this. +To update your clone, go into the directory that the git repo is in +(i.e., into the git repo itself, not merely the directory that you did the +`git clone` in) and type the following: -9CEREAL + $ git pull -When you want to update your clone--as they need to be fed. I mean, you would -not want to starve your clone. I mean, while I am not certain Geneva -conventions apply to clones as they technically are not human, you know, not -being created by God, and .'. not having souls (though you need to ask: do you -really want a soulless monster displeased at you? I mean, it can do what it -wants without worrying of eternal damnation). So to feed this monstrocity that -you have raised on your computer (which work by a wizard's magic anyways), -you go into the directory that the git repo is in (in the git repo itself, not -the directory that you did the `git clone` in), and type the following: +Now to build, run: - $ git pull + $ perl Build.PL -Now to build this, you type the arcane words (and no, it really does not -matter what sign the moon is in... but if it makes you feel better, you can -type this when the moon is in the sextan sign, just my own suggestion) +Then to test: - $ perl Build.PL - $ perl Build test && perl Build Bundle + $ perl Build test -Okay.. the first one, will build the require tools you need to work with to -install the wonder, that is the developmental version of SDL Perl. +Only MacOS used to also require you to: -The next one goes: + $ perl Build bundle -Okay, I am testing to make certain the system can handle me. +... but that shouldn't be necessary anymore. -If that goes well (and _only_ if), it goes, "wow! It likes me! IT REALLY -LIKES ME!"--after prancing around in front of the mirror and trying to do up -her Perl and XS coloured hair in a nice looking manner, and choose a pretty -dress to wear (she will try to be the best looking developmental perl libary -on the system. Oh~ all the _other_ developmental perl libraries will be so -jealous of her~). +Katrina Payne (the original author of this file) had a cute anecdote here +about SDL Perl being a blushing girl who fails testing and enjoys watching +InuYasha. Quirky! ;) I couldn't quite bear to replace it all so here's her +paragraph of glory from Thu Oct 22, 2009: -Then if there is an issue getting herself all pretty this command will have + "Then if there is an issue getting herself all pretty this command will have her just stop there... your best bet is to give her comfort food. Of the kind of reports on the SDL Perl tracker, as I am not really certain if SDL Perl likes Hagan Daaz, but then I have not ask her, and well, you really are @@ -165,15 +89,13 @@ for why she does not look pretty--programs that end up not compiling properly tend to have self esteem issues. Sending something to the tracker pretty much is a way of telling her you are interested... this usually helps her to stop watching old reruns of Inu Yasha (yeah, SDL Perl is still kind of -young) and get back to feeling better. +young) and get back to feeling better." -Anyways, if all goes well and she feels all pretty looking, she just skips -all the romance and moves into your system with perl Build install. Yush, -that is right, you type in: +Finally you're done with melodramatic testing and ready to type: - # perl Build install + # perl Build install -Oh yeah, '#' is a form of notation that this command is to be typed in as the -avatar user... or a super user account. +The '#' above denotes that this command should be entered from a root or +super-user account which has sufficient module installation permissions. -And... bob is your uncle. +Then your installation of SDL Perl should be complete. Yay! Enjoy! =) From 5b922195a4aaddead70eb8090596b02ef7563e58 Mon Sep 17 00:00:00 2001 From: "Jeffrey T. Palmer" Date: Thu, 17 Mar 2011 20:24:24 -0400 Subject: [PATCH 02/11] Fix pong example --- examples/SDLx/pong.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/SDLx/pong.pl b/examples/SDLx/pong.pl index f91bd0b5..4275a353 100644 --- a/examples/SDLx/pong.pl +++ b/examples/SDLx/pong.pl @@ -123,7 +123,7 @@ sub on_move { } sub on_event { - my $event = shift; + my ( $event, $app ) = @_; if ( $event->type == SDL_KEYDOWN ) { my $key = $event->key_sym; From e577ede2ce98fc84e82fceb8ad4800662d984a68 Mon Sep 17 00:00:00 2001 From: "Jeffrey T. Palmer" Date: Thu, 17 Mar 2011 20:26:49 -0400 Subject: [PATCH 03/11] Allow starry.pl to exit on quit --- examples/pixel_operations/starry.pl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/pixel_operations/starry.pl b/examples/pixel_operations/starry.pl index ed1cccbc..a4a22cc3 100644 --- a/examples/pixel_operations/starry.pl +++ b/examples/pixel_operations/starry.pl @@ -26,8 +26,7 @@ my $display_matrix = SDLx::Surface->new( surface => $app ); -#foreach(0..300) -while (1) { +while ( !$quit ) { SDL::Events::pump_events(); while ( SDL::Events::poll_event($event) ) { From f333b69e717df526844f98cf64fb50e601aa3af7 Mon Sep 17 00:00:00 2001 From: "Jeffrey T. Palmer" Date: Thu, 17 Mar 2011 20:28:42 -0400 Subject: [PATCH 04/11] Color must be an integer --- examples/pixel_operations/tie_matrix.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/pixel_operations/tie_matrix.pl b/examples/pixel_operations/tie_matrix.pl index 3aa272d8..8c429345 100644 --- a/examples/pixel_operations/tie_matrix.pl +++ b/examples/pixel_operations/tie_matrix.pl @@ -75,7 +75,7 @@ sub update { foreach ( 0 ... rand( $surface->w ) ) { - $matrix->[$_][ rand( $surface->h ) ] = 0xFFFFFFFF / ( $_ + 1 ); + $matrix->[$_][ rand( $surface->h ) ] = int(0xFFFFFFFF / ( $_ + 1 )); } SDL::Video::unlock_surface($surface); From bd6ed70cce1a985059772829419d6da1ae83f6df Mon Sep 17 00:00:00 2001 From: "Jeffrey T. Palmer" Date: Thu, 17 Mar 2011 20:41:26 -0400 Subject: [PATCH 05/11] Use bmp, change alpha key --- examples/SDLx/SDLx_sprite_animated.pl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/SDLx/SDLx_sprite_animated.pl b/examples/SDLx/SDLx_sprite_animated.pl index 964158eb..436f39e6 100644 --- a/examples/SDLx/SDLx_sprite_animated.pl +++ b/examples/SDLx/SDLx_sprite_animated.pl @@ -17,12 +17,12 @@ ); my $sprite = SDLx::Sprite::Animated->new( - image => 'test/data/hero.png', + image => 'test/data/hero.bmp', rect => SDL::Rect->new( 48, 0, 48, 48 ), ticks_per_frame => 6, ); $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->start(); my $x = 0; From 8d2b6db64c9ec3a4f5eda4de34dd9acfa9e51ffa Mon Sep 17 00:00:00 2001 From: kthakore Date: Thu, 17 Mar 2011 21:46:35 -0400 Subject: [PATCH 06/11] Use a default value that works --- examples/cookbook/pogl_sdl_texture.pl | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/examples/cookbook/pogl_sdl_texture.pl b/examples/cookbook/pogl_sdl_texture.pl index 38afa1ea..10620668 100644 --- a/examples/cookbook/pogl_sdl_texture.pl +++ b/examples/cookbook/pogl_sdl_texture.pl @@ -115,7 +115,10 @@ sub LoadTexture { my $nOfColors; my $texture_format; 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); #get the number of channels in the SDL surface From 91797b67f56351ece82602ef8a4488f45e912855 Mon Sep 17 00:00:00 2001 From: kthakore Date: Thu, 17 Mar 2011 21:54:59 -0400 Subject: [PATCH 07/11] Pong has no app solutino --- examples/SDLx/pong.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/SDLx/pong.pl b/examples/SDLx/pong.pl index f91bd0b5..b28dfcfb 100644 --- a/examples/SDLx/pong.pl +++ b/examples/SDLx/pong.pl @@ -144,7 +144,7 @@ sub on_event { $paddle->{y_vel} += $paddle->{vel} if $key == SDLK_UP; $paddle->{y_vel} -= $paddle->{vel} if $key == SDLK_DOWN; } elsif ( $event->type == SDL_QUIT ) { - $app->stop(); + exit; } } From 262ee206b820d289c1fd836c8bac9660075c46af Mon Sep 17 00:00:00 2001 From: "Jeffrey T. Palmer" Date: Thu, 17 Mar 2011 21:58:15 -0400 Subject: [PATCH 08/11] Allow non-hashref constructor args --- lib/SDLx/FPS.pm | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/lib/SDLx/FPS.pm b/lib/SDLx/FPS.pm index cc16ebf7..310957a4 100644 --- a/lib/SDLx/FPS.pm +++ b/lib/SDLx/FPS.pm @@ -8,24 +8,31 @@ our @ISA = qw(SDL::GFX::FPSManager); sub new { my ( $class, @args ) = @_; + + my %options; if ( ref $args[0] ) { - my %options = %{ $args[0] }; + %options = %{ $args[0] }; if ( @args > 1 ) { Carp::cluck("Extra arguments are not taken when hash is specified"); } - 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/} ); - } elsif ( @args > 4 ) { + } else { + %options = @args; + } + + if ( keys %options > 4 ) { 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( map defined() ? $_ : 0, @args[ 1 .. 4 ] From d5fb633b5a76532b328d4be02f2f64ccc3197745 Mon Sep 17 00:00:00 2001 From: PipStuart Date: Fri, 18 Mar 2011 13:09:57 -0500 Subject: [PATCH 09/11] B3ID8L8: Tidied up README to have Team refer to GitHub && did away with outdated MacOSX section. --- README | 51 ++++++--------------------------------------------- 1 file changed, 6 insertions(+), 45 deletions(-) diff --git a/README b/README index 2a44e8ec..59045201 100644 --- a/README +++ b/README @@ -1,53 +1,14 @@ NAME - SDL_perl - Simple DirectMedia Layer for Perl - + SDL Perl - Simple DirectMedia Layer for Perl + SYNOPSIS use SDL; - + 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. This package takes some liberties with the SDL API, and attempts to adhere 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 - Name: Tobias Leich - -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 +The SDL Perl Development Team + Please see: HTTPS://GitHub.Com/PerlGameDev/SDL/contributors From cf30cde564e2dc3bd03e1edbd002c394e1569095 Mon Sep 17 00:00:00 2001 From: Tobias Leich Date: Sat, 19 Mar 2011 20:04:50 +0100 Subject: [PATCH 10/11] removing blending stuff from draw_rect, this will be added as draw_rect_blended later --- src/SDLx/Surface.xs | 48 ++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 35 deletions(-) diff --git a/src/SDLx/Surface.xs b/src/SDLx/Surface.xs index 8197f587..e3efcbda 100644 --- a/src/SDLx/Surface.xs +++ b/src/SDLx/Surface.xs @@ -183,44 +183,22 @@ surfacex_draw_rect ( surface, rt, color ) SV* rt SV* color CODE: - AV* ar = __list_rgba( color ); - int a = SvUV(*av_fetch(ar, 3, 0)); - - SDL_Rect r_rect; - SV* foo; - - if( SvOK(rt) ) - { - int newly_created_rect = 0; - foo = rect( rt, &newly_created_rect ); - r_rect = *(SDL_Rect*)bag2obj(foo); - } - else - { - r_rect.x = 0; r_rect.y = 0; r_rect.w = surface->w; r_rect.h = surface->h; - } - - //Only do alpha blitting if we are doing on video surface and there is an alpha value; - if( a != 0xFF && SDL_GetVideoSurface() == surface) - { - SDL_Surface *alpha_surface = SDL_CreateRGBSurface( - surface->flags, r_rect.w, r_rect.h, - 32, 0xFF000000, 0xFF0000, 0xFF00, 0xFF - ); - - Uint32 m_color = __map_rgba( color, alpha_surface->format ); - SDL_FillRect(alpha_surface, NULL, m_color); - SDL_BlitSurface(alpha_surface, NULL, surface, &r_rect ); - SDL_FreeSurface( alpha_surface); - } - else - { - Uint32 m_color = __map_rgba( color, surface->format ); - SDL_FillRect(surface, &r_rect, m_color); - } + Uint32 m_color = __map_rgba( color, surface->format ); + SDL_Rect r_rect; if( SvOK(rt) ) + { + int newly_created_rect = 0; + SV* foo = rect( rt, &newly_created_rect ); + r_rect = *(SDL_Rect*)bag2obj(foo); + SDL_FillRect(surface, &r_rect, m_color); SvREFCNT_dec(foo); + } + else + { + 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); + } #ifdef HAVE_SDL_GFX_PRIMITIVES From 82ffd38f4944db0e7480bc2e12c191d4a37f1c35 Mon Sep 17 00:00:00 2001 From: kthakore Date: Sat, 19 Mar 2011 15:08:04 -0400 Subject: [PATCH 11/11] Updated the changes of merged in branches so far --- CHANGELOG | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 72f927f9..a6478bf2 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,10 @@ 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 New features: - SDLx::Surface draw_polygon(), linking GFX to Surfaces when available [FROGGS]