Scrolling background

Hi,
i tried to make scrolling background using SDL and i have to make some
terible mistake because it is teribly slow.
I am using resolution 800x600 (32b colors).
is there any better(faster) solution than using

SDL_BlitSurface(image, &src, screen, &dest);
SDL_UpdateRect(screen,0,0,0,0);

where src y coordinate is incrementing. If i call this two functions in
for cycle i get speed from 6 up to 10 frames per second.
Please help.
Thanx Jan Kratochvil

Well… The usual stuff; make sure…

* ...that the image is in the exact same format as the screen surface.

* ...that the screen surface format is directly supported by the hardware.

* ...that the image is in VRAM, and thus can be blitted by the GPU, or...

* ...that the driver can do fast DMA transfers from system RAM.

Unfortunately, the last two are problematic on some platforms. (For example,
Linux has no targets so far, that support busmaster DMA transfers from sysRAM
to VRAM, which is a major issue if you need to do software rendering.)

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Tuesday 12 June 2001 08:56, Jan Kratochvil wrote:

Hi,
i tried to make scrolling background using SDL and i have to make some
terible mistake because it is teribly slow.
I am using resolution 800x600 (32b colors).
is there any better(faster) solution than using

SDL_BlitSurface(image, &src, screen, &dest);
SDL_UpdateRect(screen,0,0,0,0);

where src y coordinate is incrementing. If i call this two functions in
for cycle i get speed from 6 up to 10 frames per second.
Please help.

Software effects get slow really quickly as you go to higher
resolutions. You may want to look into using OpenGL for a hardware
accelerated scrolling, in case some of the things David mentionned are
hard to achieve.–

Olivier A. Dagenais - Software Architect and Developer

“Jan Kratochvil” wrote in message
news:Pine.LNX.4.33.0106120849030.2859-100000 at twin.jikos.cz

Hi,
i tried to make scrolling background using SDL and i have to make
some
terible mistake because it is teribly slow.
I am using resolution 800x600 (32b colors).
is there any better(faster) solution than using

SDL_BlitSurface(image, &src, screen, &dest);
SDL_UpdateRect(screen,0,0,0,0);

where src y coordinate is incrementing. If i call this two functions
in
for cycle i get speed from 6 up to 10 frames per second.
Please help.
Thanx Jan Kratochvil

Mensaje citado por: Jan Kratochvil :

Hi,
i tried to make scrolling background using SDL and i have to make some
terible mistake because it is teribly slow.
I am using resolution 800x600 (32b colors).
is there any better(faster) solution than using

SDL_BlitSurface(image, &src, screen, &dest);
SDL_UpdateRect(screen,0,0,0,0);

where src y coordinate is incrementing. If i call this two functions in
for cycle i get speed from 6 up to 10 frames per second.
Please help.
Thanx Jan Kratochvil

:slight_smile:
Welcome to the club.
I can’t get more that 30 fps on SDL on 640x480x16 bits by just blitting a
surface to screen and updating.
The only way to get a real fast thing ( 1000 fps ) is to use
SDL_HWSURFACE|SDL_FULLSCREEN but it crash on exit. :frowning:

I am looking for the bug, and I will try to report…

              Miguel Angel Blanch Lardin

         -- http://www.arianne.cx -- Arianne --

The free open source massively multiplayer online role playing game

nuclear cia fbi spy password code encrypt president bomb iran irak korea cuba
Ala yihad mosad kgb free freedom human rights yugoslavia kosovo ebola dna

                -- Echelon must die --

Well… The usual stuff; make sure…

  • …that the image is in the exact same format as the screen surface.

  • …that the screen surface format is directly supported by the hardware.
    can i ask how to check this?

  • …that the image is in VRAM, and thus can be blitted by the GPU, or…
    and this

  • …that the driver can do fast DMA transfers from system RAM.
    and this.

Unfortunately, the last two are problematic on some platforms. (For example,
Linux has no targets so far, that support busmaster DMA transfers from sysRAM
to VRAM, which is a major issue if you need to do software rendering.)

Jan Kratochvil

Miguel,

May I ask why you would want to display more than 30fps?

I can’t get more that 30 fps on SDL on 640x480x16 bits by just blitting a
surface to screen and updating.
The only way to get a real fast thing ( 1000 fps ) is to use
SDL_HWSURFACE|SDL_FULLSCREEN but it crash on exit. :frowning:

Regards,
Nicolai Dufva NielsenOn Tue, 12 Jun 2001, you wrote:

This has been discussed several times before.

In short:

You always have to match the exact CRT refresh rate to produce perfectly
smooth scrolling and animation, especially at high speeds. This is because of
the nasty side effects obverved when the same image is allowed to be
displayed more than once on the CRT. (The eye sees static images rather than
smooth animation, even at very high refresh and frame rates, and ghosting
effects can often be observed as well. 50 Hz refresh rate with 50 Hz frame
rate may look better than 100 Hz with 50 Hz frame rate!)

Just as if this wasn’t problematic enough, modern CRTs require refresh rates
of 70+ Hz for a flicker-free display, due to the high intensity and the fast
phosphor…

//David Olofson — Programmer, Reologica Instruments AB

.- M A I A -------------------------------------------------.
| Multimedia Application Integration Architecture |
| A Free/Open Source Plugin API for Professional Multimedia |
----------------------> http://www.linuxaudiodev.com/maia -' .- David Olofson -------------------------------------------. | Audio Hacker - Open Source Advocate - Singer - Songwriter |--------------------------------------> david at linuxdj.com -'On Thursday 14 June 2001 15:00, Nicolai Dufva Nielsen wrote:

On Tue, 12 Jun 2001, you wrote:

Miguel,

May I ask why you would want to display more than 30fps?