DarkElvenAngel
Posts: 182
Joined: Tue Mar 20, 2018 9:53 pm

Best way to handle sprites

Sat Nov 09, 2019 5:34 pm

Hello,

I'm working on a raw Linux Framebuffer library and I'm thinking to add sprites if for nothing else I can use it for a mouse cursor.

I'm writing all this is C and I'm not sure how it should work.

My current thinking is to take a rectangle from where the sprite will be placed and save that in a working buffer blit the sprite to the framebuffer then when I have to move it Put the background back and repeat...

I just need a basic flow does this seem like a good approach?

Thanks

blackshard83
Posts: 92
Joined: Fri Jan 10, 2014 8:31 am

Re: Best way to handle sprites

Sat Nov 09, 2019 11:44 pm

Of course that's an approach, but it will work well only if your "background" does never change.

DarkElvenAngel
Posts: 182
Joined: Tue Mar 20, 2018 9:53 pm

Re: Best way to handle sprites

Sun Nov 10, 2019 1:38 am

blackshard83 wrote:
Sat Nov 09, 2019 11:44 pm
Of course that's an approach, but it will work well only if your "background" does never change.
I see that could be a problem since it's very possible that the background could change, how do I deal with that?

DarkElvenAngel
Posts: 182
Joined: Tue Mar 20, 2018 9:53 pm

Re: Best way to handle sprites

Sun Nov 10, 2019 10:48 pm

I'm thinking a double buffer might be the only approach to solve this issue of background changing.

A buffer for the background that is copied to the main frame buffer then apply the sprites over that and use this background buffer in place of the small working buffer. This will require more memory.

Does this approach seem likely to work better than my original plan?

Return to “Graphics programming”