[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] FastRenderGroup?



Hello Ethan


I'm afraid you will have to use pygame 1.8 (hope that is not the problem, if so, I could zip my pygame1.8 for windows and send it to you, or you will have to modify the lines I actually blit something, remove the spr.blendmode there).

The FastRenderGroup has been renamed to LayeredDirty. (only the file is still named FastRenderGroup)

Download http://www.mypage.bluewin.ch/DR0ID/pygame_projects.html#fast_dirty1 and run the following configurations in the console:

testsprite.py
testsprite.py -update_rects
testsprite.py -FastRenderGroup

testsprite.py -static
testsprite.py -static -update_rects
testsprite.py -static -FastRenderGroup

If you run these configurations from the command line then you see where the LayeredDirty ist fast: its when you have many static sprites. Just as an replacement for the RenderUpdates its a bit slower.

You think, if you use an animated Background it is not of use. That is right because then you will have to update the entire screen. Talking about that, the LayeredDirty has mechanics to switch to full screen update as soon the frame rate drops beneath a certain threshold (you can set the threshold). So doing full background animation would lead to full screen update or if you set the threshold hight enough (and you still do not have to worry about how to draw things fastest (well perhaps you can be faster in simple games, but not using all features)).

In the last days I have been working on a little simple clone of a game I have seen some time ago. It uses the LayeredDirty group ( http://www.mypage.bluewin.ch/DR0ID/BETA/BeerGame.zip use it at your own risk). I have used the LayeredDirty and have found a bug in the handling of the visible flag. Also I have added a source_rect to the DirtySprite/LayeredDirty so you can just set that rect and the DirtyLayered group will draw the right portion of the image (useful for image strip animation). These changes are not fixed in the version 1.1.83.

Some other features are dirty flag, layers and blendmodes. (blendmodes only for pygame 1.8)

Here you can find some explanation what I do in LayeredDirty (yes it uses an dirty rect union algorithm):
http://www.mypage.bluewin.ch/DR0ID/pygame_tutorial01.html#optimizations

I hope I could help you :-)

If you want to chat, I'm often online at #pygame.
Thank you for your interest in the FastRenderGroup, err LayeredDirty.

~DR0ID


Ethan Glasser-Camp schrieb:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

I started looking at DR0ID's FastRenderGroup today. The demo is quite
impressive! I just wanted to know, what makes it fast? In other words,
what's the difference between this and RenderUpdates? My understanding
from rereading emails is that RenderUpdates passes repeated dirty
rectangles to display, and FastRenderGroup optimizes repeated dirty
rectangles away by doing a union operation. Is that true? If so, could
you put text like that on your site, DR0ID? (A possible new name might
be RepeatedRectGroup?)

I also see from rereading the archive that FastRenderGroup is the
preferred Group to use[1]. For what kinds of games? If you wipe the
whole screen each frame, for instance because you have an animated
background, then it doesn't make sense to use either FastRenderGroup
or RenderUpdates, does it?

[1]: http://archives.seul.org/pygame/users/Jun-2007/msg00302.html

Anyhow, it's really exciting to see people working on this. Cheers!

Ethan
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFGs+SihRlgoLPrRPwRAm/zAJ49RSk2n4iBbuHIvuGv3Hwt5hPdtgCeNrHs
WdTUaB2z59tH7eSCfFtPEQ8=
=k1Nv
-----END PGP SIGNATURE-----