SDLx::Text - replacing old text don't work as expected #209

asb-capfan opened this Issue Dec 22, 2011 · 3 comments


None yet
2 participants


If a SDLx::Text is drawn, then altered (the text string) and redrawn, the old text remains visible.

Example-Code showing the problem:


use strict;
use warnings;
use SDL;

use SDL;
use SDLx::App; 
use SDLx::Text;

my $app = SDLx::App->new(
    exit_on_quit => 1,

my $message = SDLx::Text->new;

$message->write_to( $app, "Hello, World!" );

$message->write_to( $app );


More information:
OS: Windows 7 x64
Perl: Strawberry Perl 5.12.2 built for MSWin32-x64-multi-thread version 2.53501 (perl -e "use SDL 999;")
SDL::version is 1.2.14 (cf.
SDL::linked_version is 1.2.14

This issue was discussed on the mailing list the 22th December 2011.


Blaizer commented Dec 23, 2011

This is not a bug... this is just how SDL surfaces work. All surfaces, the app surface included, save the pixels drawn on them. Doing update() on the app doesn't change any of the pixels on the surface, it merely shows the pixels saved into the app surface on the user's screen.

Your example is drawing 'hello world' to the app surface at (0, 0), then redundantly updating and giving the user no time to see the changes. Then instantly drawing 'peter' at (0, 0) on top of that, on the app surface, and showing the user.

Blaizer closed this Dec 23, 2011

Yes, that's indeed what teh code does. Kartik Thakore stated on the mailing list "You shouldnt have to do this.":

Do this.

$message->write_to( $app, "Hello, World!" );

my $s = $message->surface;
$s->draw_rect([0,0,$s->w,$s->h], 0);


$message->write_to( $app );

So, maybe there is a misunderstanding. Why does SDLx::Text have at all the possibility to change the text of the object? Is the reason, that the user don't have to create a new object for drawing another, different text?


Blaizer commented Dec 23, 2011

Yes, you're right. The text() method is also used internally to set the text in the first place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment