From: cthulhuology Date: Fri, 7 Aug 2009 20:59:14 +0000 (-0400) Subject: Added SDLPerl.app bundle to the now fixed Darwin build system X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=3a32e86d2417c9a8078fd75d3f15d11e6bcefecf;p=sdlgit%2FSDL_perl.git Added SDLPerl.app bundle to the now fixed Darwin build system Added .spl filetype for launching SDLPerl.app scripts! --- diff --git a/CHANGELOG b/CHANGELOG index c88c1ca..b8d5929 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,5 +1,13 @@ Revision history for Perl extension SDL_perl. +* Aug 7 2009 David J. Goehrig + - fixed Darwin build breakage + - added support for Mac Ports policies + - updated the name of the bundle + - added Darwin action ./Build bundle to create SDLPerl.app + - fixed SDLPerl.app compilation + - added .spl file type for SDLPerl applications! + * Aug 5 2009 Kartik Thakore - fixed build after Module::Build breakage - fixed openGL header problems diff --git a/MacOSX/Info.plist b/MacOSX/Info.plist index 2d4aa04..29efd98 100644 --- a/MacOSX/Info.plist +++ b/MacOSX/Info.plist @@ -3,16 +3,16 @@ CFBundleDisplayName - SDL Perl + SDLPerl CFBundleDocumentTypes CFBundleTypeExtensions - sdlpl + spl CFBundleTypeIconFile - SDL Perl.icns + SDLPerl.icns CFBundleTypeName SDL Perl Script CFBundleTypeRole @@ -20,15 +20,15 @@ CFBundleExecutable - SDL Perl + SDLPerl CFBundleGetInfoString Multimedia for Perl CFBundleIconFile - SDL Perl.icns + SDLPerl.icns CFBundleIdentifier org.perl.sdl CFBundleName - SDL Perl + SDLPerl CFBundlePackageType APPL CFBundleShortVersionString diff --git a/MacOSX/SDL Perl.icns b/MacOSX/SDLPerl.icns similarity index 100% rename from MacOSX/SDL Perl.icns rename to MacOSX/SDLPerl.icns diff --git a/MacOSX/launcher.m b/MacOSX/launcher.m index 749f664..59ccff5 100644 --- a/MacOSX/launcher.m +++ b/MacOSX/launcher.m @@ -186,6 +186,7 @@ main( int argc, char** argv) [NSApp setMainMenu: [[NSMenu alloc] init]]; sdlplmain = [[SDLPerlMain alloc] init]; + [sdlplmain retain]; [NSApp setDelegate: sdlplmain]; [NSApp run]; diff --git a/make/lib/SDL/Build.pm b/make/lib/SDL/Build.pm index 37354a7..3cade52 100644 --- a/make/lib/SDL/Build.pm +++ b/make/lib/SDL/Build.pm @@ -249,9 +249,11 @@ sub process_support_files { } # Override to create a MacOS Bundle -sub build_bundle +sub ACTION_bundle { - return; + my ($self) = @_; + $self->depends_on('build'); + $self->get_arch($^O)->build_bundle(); } # Override Install method for darwin @@ -259,7 +261,6 @@ sub ACTION_install { my ($self) = @_; require ExtUtils::Install; $self->depends_on('build'); - $self->get_arch($^O)->build_bundle(); ExtUtils::Install::install($self->install_map, 1, 0, $self->{args}{uninst}||0); } diff --git a/make/lib/SDL/Build/Darwin.pm b/make/lib/SDL/Build/Darwin.pm index 1f090da..2dd2222 100644 --- a/make/lib/SDL/Build/Darwin.pm +++ b/make/lib/SDL/Build/Darwin.pm @@ -56,8 +56,7 @@ sub fetch_includes '/System/Library/Frameworks/libvorbisfile.framework/Headers' => '../../lib', '/System/Library/Frameworks/libvorbisenc.framework/Headers' => '../../lib', '../../include' => '../../lib', - '/System/Library/Frameworks/OpenGL.framework/Headers' => - '/System/Library/Frameworks/OpenGL.framework/Libraries', + '/System/Library/Frameworks/OpenGL.framework/Headers' => '/System/Library/Frameworks/OpenGL.framework/Libraries', ); } @@ -75,23 +74,29 @@ sub build_c_source sub build_install_base { - return "SDL Perl.app/Contents/Resources"; + return "SDLPerl.app/Contents/Resources"; } sub build_bundle { - $bundle_contents="SDL Perl.app/Contents"; + $bundle_contents="SDLPerl.app/Contents"; system "mkdir -p \"$bundle_contents\""; mkdir "$bundle_contents/MacOS",0755; - $libs = `sdl-config --libs`; + $cflags = `sdl-config --cflags`; + chomp($cflags); + $cflags .= ' ' . `perl -MExtUtils::Embed -e ccopts`; + chomp($cflags); + $libs = `sdl-config --libs`; + chomp($libs); + $libs .= ' ' . `perl -MExtUtils::Embed -e ldopts`; chomp($libs); $libs =~ s/-lSDLmain//g; - system "gcc $libs -framework Cocoa `perl -MExtUtils::Embed -e ldopts` MacOSX/launcher.o -o \"$bundle_contents/MacOS/SDL Perl\""; - + print STDERR "gcc $cflags MacOSX/launcher.m $libs -framework Cocoa -o \"$bundle_contents/MacOS/SDLPerl\""; + print STDERR `gcc $cflags MacOSX/launcher.m $libs -framework Cocoa -o \"$bundle_contents/MacOS/SDLPerl\"`; mkdir "$bundle_contents/Resources",0755; system "echo \"APPL????\" > \"$bundle_contents/PkgInfo\""; system "cp MacOSX/Info.plist \"$bundle_contents/\""; - system "cp \"MacOSX/SDL Perl.icns\" \"$bundle_contents/Resources\""; + system "cp \"MacOSX/SDLPerl.icns\" \"$bundle_contents/Resources\""; } 1; diff --git a/src/OpenGL.xs b/src/OpenGL.xs index 13b3e58..47f22c2 100644 --- a/src/OpenGL.xs +++ b/src/OpenGL.xs @@ -37,8 +37,14 @@ #include +#ifdef PERL_DARWIN +#include +#include +#else #include #include +#endif + #ifdef USE_THREADS #define HAVE_TLS_CONTEXT diff --git a/test/testcolor.spl b/test/testcolor.spl new file mode 100644 index 0000000..9865b62 --- /dev/null +++ b/test/testcolor.spl @@ -0,0 +1,63 @@ +#!/usr/bin/env perl +# + +use SDL; +use SDL::App; +use SDL::Event; + +use vars qw/ $app /; + +print STDERR < 320, -height => 240, -depth => 8; + +my %colors = ( + red => (new SDL::Color -r => 255, -g => 0, -b => 0 ), + green => (new SDL::Color -r => 0, -g => 255, -b => 0), + blue => (new SDL::Color -r => 0, -g => 0, -b => 255), + yellow => (new SDL::Color -r => 255, -g => 255, -b => 0), + purple => (new SDL::Color -r => 255, -g => 0, -b => 255), + white => (new SDL::Color -r => 255, -g => 255, -b => 255) +); + + +$x = 0; $y = 0; +$rect = new SDL::Rect -x => $x, -y => $y, + -w => $app->width / scalar(keys %colors), -h => $app->height(); + +print "Sorted colors:\n"; + +for ( sort keys %colors ) { + print "$_ " . join (",",$colors{$_}->r(), $colors{$_}->g(), + $colors{$_}->b()) . "\n"; +} + +for ( sort keys %colors ) { + $rect->x($x); + $x += $rect->width(); + $app->fill($rect,$colors{$_}); +} + +$app->sync(); + +$last = new SDL::Color -r => 128, -g => 128, -b => 128; + +$app->sync(); +$app->loop( { + SDL_QUIT() => sub { exit(0); }, + SDL_KEYDOWN() => sub { $app->fullscreen(); }, + SDL_MOUSEBUTTONDOWN() => sub { + my $e = shift; + if ($e->button == 3) { + $last = $app->pixel($e->button_x(),$e->button_y()); + print STDERR "X: ", $e->button_x(), " Y: ", $e->button_y(), + " R: ", $last->r(), " G: ", $last->g(), + " B: ", $last->b(), "\n"; + } else { + $app->pixel($e->button_x(),$e->button_y(),$last); + } + }, +});