Gabriele Farina wrote:
i find the most important optimization for gui stuff is if each control has a "dirty" type flag, and only redrawing the control when it has changed. usually this is the only thing that needs to be done.I'm working on a GUI engine writte using Pygame. I'm at a good point, I finished all the widgets I need, but I have to know how can I impreve my script speed. I'd like to know some tricks for speeding up my GUI, in paticular i'd like to know how can I update only a single part of a surface.
the pygame sprite stuff is fairly optimized. i would assume it would be as fast or faster than anything similar you implement yourself. especially if you render your sprites with the 'update regions', which SDL usually needs for full speed. It is a lot of work to get those update regions done correctly, and the sprite groups handle it all automatic.Other 2 things: 1) Using sprites makes the script work slower or not??
surface locking is usually only needed for video surfaces. these are surfaces with the HWSURFACE flag enabled. it means the pixel data for the surface lives on the graphics card memory. in order to access these pixels you need to "lock" them, otherwise the graphics card may feel free to move them around inside its memory. it is safe to lock a surface that doesn't need it though, and that won't be a performance issue either.2) How does surfaces-lock work??When (and why) I have to use it??