X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=pages%2Fblog-0008.html-inc;h=706ea537074945bb91e1162b2494c72640b80ed3;hb=a05e5d4499fb58198e463162d0385e8a156e1f03;hp=8978342f5d6ba01117e1a0dda5f9dbe8d8a5a674;hpb=ca0a3441dd72000cbbbb4be484b18d0d305fdb29;p=sdlgit%2FSDL-Site.git diff --git a/pages/blog-0008.html-inc b/pages/blog-0008.html-inc index 8978342..706ea53 100644 --- a/pages/blog-0008.html-inc +++ b/pages/blog-0008.html-inc @@ -1,36 +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 ); +