Re: Blitting and sprites in Cairo

Chris Wilson <[email protected]>
Newsgroups gmane.comp.lib.cairo
Message-ID <[email protected]>
On Wed, May 15, 2013 at 10:47:31AM +0200, Donn wrote:
> How would you move a sprite across a background?
> 
> The sprite could be:
> 
> draw rectangle 32x32
> clip()
> push_group()
> draw sprite with cairo functions
> s=pop_group()
> 
> But now:
> 
> Draw background once
> loop start
>  Copy rect of bg where sprite is gonna go //How do you do this?
>   translate() //move sprite
>   set_source(s)
>   paint() //Draw the sprite
>  //Replace the backdrop
>  ?? //Some kind of set_source + paint again?
> loop
> 
> That kind of jazz.

Assuming you've disposed off the background layer and only have the
frontbuffer left - yes, you would need to make a copy of the area to be
damaged (after undoing the old sprite and before applying the new).

However, since you will want to double-buffer the expose event at least,
you can use that as a composition step and not burn the sprites into the
backdrop.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
-- 
cairo mailing list
[email protected]
http://lists.cairographics.org/mailman/listinfo/cairo
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.