Revision history for Perl extension SDL_perl.
+* Aug 7 2009 David J. Goehrig <dgoehrig@cpan.org>
+ - 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 <thakore.kartik@gmail.com>
- fixed build after Module::Build breakage
- fixed openGL header problems
<plist version="1.0">
<dict>
<key>CFBundleDisplayName</key>
- <string>SDL Perl</string>
+ <string>SDLPerl</string>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>CFBundleTypeExtensions</key>
<array>
- <string>sdlpl</string>
+ <string>spl</string>
</array>
<key>CFBundleTypeIconFile</key>
- <string>SDL Perl.icns</string>
+ <string>SDLPerl.icns</string>
<key>CFBundleTypeName</key>
<string>SDL Perl Script</string>
<key>CFBundleTypeRole</key>
</dict>
</array>
<key>CFBundleExecutable</key>
- <string>SDL Perl</string>
+ <string>SDLPerl</string>
<key>CFBundleGetInfoString</key>
<string>Multimedia for Perl</string>
<key>CFBundleIconFile</key>
- <string>SDL Perl.icns</string>
+ <string>SDLPerl.icns</string>
<key>CFBundleIdentifier</key>
<string>org.perl.sdl</string>
<key>CFBundleName</key>
- <string>SDL Perl</string>
+ <string>SDLPerl</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
[NSApp setMainMenu: [[NSMenu alloc] init]];
sdlplmain = [[SDLPerlMain alloc] init];
+ [sdlplmain retain];
[NSApp setDelegate: sdlplmain];
[NSApp run];
}
# 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
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);
}
'/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',
);
}
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;
#include <SDL.h>
+#ifdef PERL_DARWIN
+#include <gl.h>
+#include <glu.h>
+#else
#include <GL/gl.h>
#include <GL/glu.h>
+#endif
+
#ifdef USE_THREADS
#define HAVE_TLS_CONTEXT
--- /dev/null
+#!/usr/bin/env perl
+#
+
+use SDL;
+use SDL::App;
+use SDL::Event;
+
+use vars qw/ $app /;
+
+print STDERR <<USAGE;
+ Right click on any pixel to get its color values
+ Left click on any pixel to set its value to the last selected
+USAGE
+
+$app = new SDL::App -width => 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);
+ }
+ },
+});