Skip to content

Instantly share code, notes, and snippets.

Created September 19, 2012 09:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/3748626 to your computer and use it in GitHub Desktop.
Save anonymous/3748626 to your computer and use it in GitHub Desktop.
sdl-pdl bindings
#!/usr/bin/perl -w
use strict;
use warnings;
use SDL;
use SDLx::App;
use PDL;
my $app = SDLx::App->new(
title => "PDL and SDL aplication",
width => 640, height => 640, eoq => 1,);
sub make_surface_piddle {
my $piddle = rpic('/home/andrei/Pictures/picture.jpg');
my ($bytes_per_pixel,$width,$height) = $piddle->dims;
my $pointer = $piddle->get_dataref();
my $s = SDL::Surface->new_from(
$pointer, $width, $height, 32,
$width * $bytes_per_pixel
);
my $surface = SDLx::Surface->new( surface => $s );
warn "Made surface of $width, $height and ". $surface->format->BytesPerPixel;
return ( $piddle, $surface );
}
my ( $piddle, $surface ) = make_surface_piddle();
$app->add_show_handler( sub {
$surface->blit( $app, [0,0,$surface->w,$surface->h], [10,10,0,0] );
$app->update();
});
$app->run();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment