#!usr/bin/perl
use strict;
use warnings;

use SDL;
use SDLx::App;
use SDLx::Rect;

my $app = SDLx::App->new(
		h	=> 200,
		w	=> 200,
		exit_on_quit => 1,
		);
		
my $background = SDLx::Surface->new(
		h	=> 200,
		w	=> 200,
		);

my $rect = SDLx::Rect->new(0,0,200,200);
$background->draw_rect($rect, 0xFFFFFFFF);

$app->add_show_handler(sub {
	
	################################################
	#
	# These three lines give an indication of the
	# memory leak for blitting surfaces to be in the
	# coordinate arrays.
	#
	################################################
	
	#$background->blit($app);
	#$background->blit($app, [0,0,200,200]);
	#$background->blit($app, [0,0,200,200], [0,0,200,200]);
	
	
	################################################
	#
	# These three lines give an indication that by
	# predefining the $rect coordinates, the 
	# SDLx::Rect->new() is not called every time.
	# This seems to stabilize the memory utilization.
	#
	################################################
	
	#$background->blit($app);
	#$background->blit($app, $rect);
	#$background->blit($app, $rect, $rect);
		
	$app->update;
});
$app->run();		