X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2Fblog-0022.html-inc;h=706ea537074945bb91e1162b2494c72640b80ed3;hb=d6a8ee088684c80264483be3fe6c8d5654d0328b;hp=7f9c593d829b4b3118fe033c07d9644cbe13239e;hpb=e785862422f3e827a242fc244bd57b23443887ce;p=sdlgit%2FSDL-Site.git diff --git a/pages/blog-0022.html-inc b/pages/blog-0022.html-inc index 7f9c593..706ea53 100644 --- a/pages/blog-0022.html-inc +++ b/pages/blog-0022.html-inc @@ -1,25 +1,77 @@
use PDL; + use SDL::Rect; + use SDL::Video; + use SDL::Surface; + use SDL::PixelFormat; +
my ( $bytes_per_pixel, $width, $height ) = ( 4, 200, 400 ); +
my $piddle = zeros( byte, $bytes_per_pixel, $width, $height ); +
my $pointer = $piddle->get_dataref(); +
my $surface = SDL::Surface->new_from( $pointer, $width, $height, 32, + $width * $bytes_per_pixel ); +
warn "Made surface of $width, $height and ". $surface->format->BytesPerPixel; + return ( $piddle, $surface ); +
SDL::Video::lock_surface($surface); + + $piddle ( :, 0 : rand(400), 0 : rand(200) ) .= pdl( rand(225), rand(225), rand(255), 255 ); +
SDL::Video::unlock_surface($surface); +
my $b = SDL::Video::blit_surface( + $surface, SDL::Rect->new( 0, 0, $surface->w, $surface->h ), + $app, SDL::Rect->new( ( $app->w - $surface->w ) / 2, ( $app->h - $surface->h ) / 2, $app->w, $app->h ) + ); + + die "Could not blit: " . SDL::get_error() if ( $b == -1 ); +