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