Hello.
I tried to write small program with scrolled backgroung. I just blited
parts of background image to another position on the screen and then
SDL_Flip(screen), but it was god damn slow…
Please, help me with examples of scrolled background.
Than you.
I forget to add source. This is small example of scrolling background
written by myself. But it’s very slow… Please help me.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed…
Name: scroll.cxx
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20040511/8f1df4c4/attachment.asc
I forget to add source. This is small example of scrolling background
written by myself.
Actually that should be “written by me.”.
But it’s very slow… Please help me.
A few questions:
- What type of machine is this running on? What CPU speed?
- How fast is this code running?
- What kind of video card is being used?
A few things come to mind:
-
32 Bit per pixel data @ 800x600 is almost 2 megabytes PER FRAME.
That’s going to be a lot of data to move even for a modest system. You
should consider using 16bpp unless you have a compelling reason to use
32bpp.
-
I see you’re using SDL_HWSURFACE. That means your backbuffer is most
likely on the video card and not in main memory, which means access to it
is going to be noticeably slower. Change it to SDL_SWSURFACE, and you
should notice a good speedup (though you’ll probably need an
SDL_BlitSurface call added).
-
Does the PNG image being loaded match the bit depth of the display
device? Is it a 32bpp image? If not, then SDL will have to do a manual
conversion of the surface every time which slows things down considerably.
If there’s any doubt, use the SDL_ConvertSurface to convert it to a
surface that matches the display surface.
Hope this helps!
–>Neil-------------------------------------------------------------------------------
Neil Bradley "Your mistletoe is no match for my T.O.W. missile!"
Synthcom Systems, Inc. - Santabot - Futurama
ICQ #29402898