[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [pygame] Hashido



> Moving very large pictures on the screen is it fundamentally slow?
> Or do i do something wrong?

basically yes, but there are things you can do that can make a big
difference.


> With 2 big surface (around 300,300) each... it is ok.
> But as soon as I reach 3 surfaces I have a clear slow down.
> should I lock the screen before doing my 3 blits?
> Would I gain substantial speed?
> should I erase independantly the 3 surfaces?

ok, this might be good material for a new tutorial...

there's three main things you can do to your program to make sure
it is running at top speed. locking the surfaces won't make a
difference for filling and blit routines. in fact hardware
accelerated surfaces can't be blit() or fill() when they are
locked.

first, make sure all surfaces are properly located in hardware
or software. hardware surfaces aren't widely supported, but when
they are they can make a big difference (see bottom paragraph for
more hardware info). if your program is doing simple blits with
colorkey or opaque surfaces, using all hardware surfaces will be
the best way to go. if using lots of alpha and pixel effects
then using software surfaces will be faster.

second, this one is easy and important. make sure all your surfaces
are the same format. this means the same bpp, colormasks, etc. the
fastest blits are the ones with the same surface format. otherwise
the blit must do a conversion during the blit, slowing things down.
all surfaces have a "convert()" function, and with no arguments it
will create a new surface converted to the same format as the display.

third, only update the parts of the screen that have changed, and
call pygame.display.update() with a list of changed rectangle areas.
this requires a little more work, since you must carefully build
the screen by changing certain areas, but the payoff is a much higher
fps. this of course doesn't really work for a game with fullscreen
scrolling/paralax/or any type of situation where the whole display
is changing every frame.


> Ah I miss my good old amiga..... erasing with so easy! with the hardware
> blitter and even the floppy DMA... ;)

yes, at this point hardware acceleration for the 2d stuff isn't
usully available on pygame. if you use windows fullscreen you can
get hardware acceleration, and under linux i believe you can do
fullscreen DGA to get hardware acceleration. I've found that hardware
blits are usually about 3x faster than the software ones. you can
find out more info about what types of blits are accelerated by
creating a VideoInfo object, pygame.display.Info()



____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org