I've made a ton of progress on my Perl/SDL digital dashboard this week. (For anyone who cares, there are pics and video on my blog).

In some ways SDL is a godsend, in others maddening. I suppose a lot of it comes from the lack of documentation. I've also found a lot of bugs. As soon as I figure out why the newest releases won't install, I hope to start getting active in it's development. (At least in the bug reporting aspect).

So my animation manager works perfectly and fast. I decide to write a snippet to post here ( a subset of what I've done) that loads animated gifs. Adjusts the offsets if the image frame is smaller than the image, gathers up the timing info. And hours later, I give up (for now). I keep running into oddity after oddity. What I thought would be a 5 minutes snippet has taken a good six hours.

Anyway, here's my question. I know that an SDL::Rect is a surface in a sense. But apparently, I don't understand it's behavior like I thought it did.

If you were to look at the docs for SDL::Surface, you get the impression that the rectangles only server to denote locations within surfaces. Take the following example.
my $s_rect = SDL::Rect->new(-x => 0, -y => 0, -width => 64, -height => +64); # Source my $d_rect = SDL::Rect->new(-x => 0, -y => 0, -width => 64, -height => +64); # Destination $sprite->blit($s_rect,$app,$d_rect);
Now if I were to use the same rectangle for the source and destination
my $s_rect = SDL::Rect->new(-x => 0, -y => 0, -width => 64, -height => +64); # Source my $d_rect = SDL::Rect->new(-x => 0, -y => 0, -width => 64, -height => +64); # Destination $sprite->blit($s_rect,$app,$s_rect);
I'd expect from the documentation that it would work the same way, but apparently it doesn't. It appears to be blitting on itself.

So when you blit, is the copying following along the following lines using the rectangles for temporary buffers?

surface > src_rect > dst_rect > app

If someone could shed some light on this, I'd really appreciate it.

-Lee

perl digital dash (in progress)

In reply to SDL Surfaces and Rectangles by shotgunefx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.