SDL using a background image

Hello,

I have a 640 x 480 display being driven by an ATmel at91SAM9261 and I’m
trying SDL for the graphics, everything is fine but is kind of slow, it
refreshes almost every second, is not that bad, but what I have to display
is a big graphic in the background (340x340) and 10 small moving graphics (4
x 340) over it, my question is is there a way to set that big image in the
background and only be refreshing the other small 10?, because as soon I
remove the static big graphic everything works very fast as you might
guessed.

Thanks

Alberto

Hello,

I have a 640 x 480 display being driven by an ATmel at91SAM9261 and I’m
trying SDL for the graphics, everything is fine but is kind of slow, it
refreshes almost every second, is not that bad, but what I have to display
is a big graphic in the background (340x340) and 10 small moving graphics (4
x 340) over it, my question is is there a way to set that big image in the
background and only be refreshing the other small 10?, because as soon I
remove the static big graphic everything works very fast as you might
guessed.

Thanks

Alberto

Hi Jose Alberto,

You should take a look into the concept of “Dirty rect” updating. To
keep it short, you need only to draw the background once (as long as
it doesn’t move) and then redraw only pieces of the screen that have
been changed.

A more detailed tutorial can be found at:

-ThiagoOn Thu, Feb 12, 2009 at 6:46 AM, Jose Alberto Arredondo wrote:

Hello,

I have a 640 x 480 display being driven by an ATmel at91SAM9261 and I’m
trying SDL for the graphics, everything is fine but is kind of slow, it
refreshes almost every second, is not that bad, but what I have to display
is a big graphic in the background (340x340) and 10 small moving graphics (4
x 340) over it, my question is is there a way to set that big image in the
background and only be refreshing the other small 10?, because as soon I
remove the static big graphic everything works very fast as you might
guessed.

Thanks

Alberto


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Take a look at SDL_Layer http://code.google.com/p/sdl-layer/. I haven’t used
it myself only because I haven’t need it yet. But from what you are
describing, this might be what you are looking for? SDL_Layer was discussed
in length on this list awhile back.

HTH,

AlvinOn Thursday 12 February 2009 00:45:19 Jose Alberto Arredondo wrote:

Hello,

I have a 640 x 480 display being driven by an ATmel at91SAM9261 and I’m
trying SDL for the graphics, everything is fine but is kind of slow, it
refreshes almost every second, is not that bad, but what I have to display
is a big graphic in the background (340x340) and 10 small moving graphics
(4 x 340) over it, my question is is there a way to set that big image in
the background and only be refreshing the other small 10?, because as soon
I remove the static big graphic everything works very fast as you might
guessed.

Thanks

Alberto

Did you use SDL_DisplayFormat()? That can speed things up quite a bit.

Jonny DOn Thu, Feb 12, 2009 at 5:53 AM, Alvin wrote:

On Thursday 12 February 2009 00:45:19 Jose Alberto Arredondo wrote:

Hello,

I have a 640 x 480 display being driven by an ATmel at91SAM9261 and I’m
trying SDL for the graphics, everything is fine but is kind of slow, it
refreshes almost every second, is not that bad, but what I have to
display
is a big graphic in the background (340x340) and 10 small moving graphics
(4 x 340) over it, my question is is there a way to set that big image in
the background and only be refreshing the other small 10?, because as
soon
I remove the static big graphic everything works very fast as you might
guessed.

Thanks

Alberto

Take a look at SDL_Layer http://code.google.com/p/sdl-layer/. I haven’t
used
it myself only because I haven’t need it yet. But from what you are
describing, this might be what you are looking for? SDL_Layer was discussed
in length on this list awhile back.

HTH,

Alvin


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

And SDL_Layer is still maintained :slight_smile:
Unfortunately I did not have any feedback from anybody having compiled or used it except one developer which uses it for a karaoke program.

This lib is not heavy and might be useful to avoid managing a list of dirty rectangles. If one day you want to switch to a flip refresh method, then you just have a flag to change, your program remains the same. Moreover you can achieve nice parallax effects.

Julien

— En date de?: Jeu 12.2.09, Jonathan Dearborn a ?crit?:de: Jonathan Dearborn
Objet: Re: [SDL] SDL using a background image
?: “A list for developers using the SDL library. (includes SDL-announce)”
Date: Jeudi 12 F?vrier 2009, 13h01

Did you use SDL_DisplayFormat()?? That can speed things up quite a bit…

Jonny D

On Thu, Feb 12, 2009 at 5:53 AM, Alvin wrote:

On Thursday 12 February 2009 00:45:19 Jose Alberto Arredondo wrote:

Hello,

I have a 640 x 480 display being driven by an ATmel at91SAM9261 and I’m

trying SDL for the graphics, everything is fine but is kind of slow, it

refreshes almost every second, is not that bad, but what I have to display

is a big graphic in the background (340x340) and 10 small moving graphics

(4 x 340) over it, my question is is there a way to set that big image in

the background and only be refreshing the other small 10?, because as soon

I remove the static big graphic everything works very fast as you might

guessed.

Thanks

Alberto

Take a look at SDL_Layer http://code.google.com/p/sdl-layer/. I haven’t used

it myself only because I haven’t need it yet. But from what you are

describing, this might be what you are looking for? SDL_Layer was discussed

in length on this list awhile back.

HTH,

Alvin


SDL mailing list

SDL at lists.libsdl.org

http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  __________________________________________________________________________________________________

Ne pleurez pas si votre Webmail ferme ! R?cup?rez votre historique sur Yahoo! Mail ! http://fr.docs…yahoo.com/mail/transfert_mails.html

I still have to get around to trying SDL_Layer. Another option is using
Sprig, which can do the Dirty work for you.

Jonny DOn Thu, Feb 12, 2009 at 7:37 AM, julien CLEMENT wrote:

And SDL_Layer is still maintained :slight_smile:
Unfortunately I did not have any feedback from anybody having compiled or
used it except one developer which uses it for a karaoke program.

This lib is not heavy and might be useful to avoid managing a list of dirty
rectangles. If one day you want to switch to a flip refresh method, then you
just have a flag to change, your program remains the same. Moreover you can
achieve nice parallax effects.

Julien

— En date de : Jeu 12.2.09, Jonathan Dearborn <@Jonathan_Dearborn> a
?crit :

De: Jonathan Dearborn <@Jonathan_Dearborn>
Objet: Re: [SDL] SDL using a background image
?: “A list for developers using the SDL library. (includes SDL-announce)” <
sdl at lists.libsdl.org>
Date: Jeudi 12 F?vrier 2009, 13h01

Did you use SDL_DisplayFormat()? That can speed things up quite a bit.

Jonny D

On Thu, Feb 12, 2009 at 5:53 AM, Alvin wrote:

On Thursday 12 February 2009 00:45:19 Jose Alberto Arredondo wrote:

Hello,

I have a 640 x 480 display being driven by an ATmel at91SAM9261 and I’m
trying SDL for the graphics, everything is fine but is kind of slow, it
refreshes almost every second, is not that bad, but what I have to
display
is a big graphic in the background (340x340) and 10 small moving
graphics
(4 x 340) over it, my question is is there a way to set that big image
in
the background and only be refreshing the other small 10?, because as
soon
I remove the static big graphic everything works very fast as you might
guessed.

Thanks

Alberto

Take a look at SDL_Layer http://code.google.com/p/sdl-layer/. I haven’t
used
it myself only because I haven’t need it yet. But from what you are
describing, this might be what you are looking for? SDL_Layer was
discussed
in length on this list awhile back.

HTH,

Alvin


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Ne pleurez pas si votre Webmail ferme. R?cup?rez votre historique sur
Yahoo! Mailhttp://fr.rd.yahoo.com/mail_fr/taglines/caramail/*http://fr.docs.yahoo.com/mail/transfert_mails.html


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Wow, yeah!

That definitely helped a lot, I getting the same speed as if there is no big
image,
in the regular computer I was getting 6 seconds every turn, now I got it to
4 sec!!
that of course in the micro controller is taking 1 1/2 minutes!, so
hopefully now it should be 1/3 on the time less

What I’m doing is rotating (using rotozoom) 10 small rectangles over a
circular image, so I was timing how long does it takes for the rectangles to
do a full lap over that circle

Thanks a lot!, I will use the SDL_Display format in all my images

Sounds like an awesome project. What are you working on? What kernel
are you using? What kind of display driver?

If you can hack the display driver, you might consider adding some
features like what gaming consoles used to have where you create a
table of “sprites” which gets checked while sending your picture to
the display. This optimizes the amount of data copying you have to do.

Links to your work would be greatly appreciated!On Wed, Feb 11, 2009 at 11:45 PM, Jose Alberto Arredondo wrote:

Hello,

I have a 640 x 480 display being driven by an ATmel at91SAM9261 and I’m
trying SDL for the graphics


http://codebad.com/

That definitely helped a lot, I getting the same speed as if there is no big
image,
in the regular computer I was getting 6 seconds every turn, now I got it to
4 sec!!
that of course in the micro controller is taking 1 1/2 minutes!, so
hopefully now it should be 1/3 on the time less

What I’m doing is rotating (using rotozoom) 10 small rectangles over a
circular image, so I was timing how long does it takes for the rectangles to
do a full lap over that circle

It’s also faster if you don’t rotozoom, but precalculate the rotated images
that you’ll need.

See ya,
-Sam Lantinga, Founder and President, Galaxy Gameworks LLC