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

Re: [pygame] blitting surface with surface-alpha to fullscreen display



Nelson, Scott schrieb:

I've been messing with pygame for awhile and am having a blast! Thanks for a great site, pygame.org people! And, I just got on this list and already its been very helpful!


I ran into a performance snag trying to blit a surface with surface-alpha to a fullscreen display surface (trying to do a fade-to-black for the screen). It works great (realtime) when the display is windowed. Lotsa fun! But, when the display is fullscreen, each blit takes almost a second to complete in 640x480 on a beefy machine.

Now, I've read the pygame docs on surfaces and displays and searched this list (finding some related discussions) and can't quite nail down what my problem is.

So, my question is: why does it take me so long to blit in fullscreen mode? And, how can I create the surfaces in such a way that the blit performs at realtime in both windowed and fullscreen mode?

Here's some snatches of my code. I grabbed the important bits, as it would be too much code to post all my classes in their entirety.

…Set up windowed mode:

pygame.display.set_mode((640, 480))

...or set up fullscreen mode:

pygame.display.set_mode((640, 480), pygame.FULLSCREEN | pygame.HWSURFACE)

...creating the surface to do the fade:

self._fadeSurface = pygame.Surface(size)

self._fadeSurface.fill(color)

self._fadeSurface.set_alpha(alpha)

self._fadeSurface = self._fadeSurface.convert()

...blitting the fade surface to the display:

self._targetSurface.blit(self._fadeSurface, (0, 0))

In windowed mode, pygame.display.Info() returns:

<VideoInfo(hw = 1, wm = 1,video_mem = 238032

blit_hw = 1, blit_hw_CC = 1, blit_hw_A = 0,

blit_sw = 1, blit_sw_CC = 1, blit_sw_A = 0,

bitsize = 32, bytesize = 4,

masks = (16711680, 65280, 255, 0),

shifts = (16, 8, 0, 0),

losses = (0, 0, 0, 8)>

In fullscreen mode, pygame.display.Info() returns:

<VideoInfo(hw = 1, wm = 1,video_mem = 244688

blit_hw = 1, blit_hw_CC = 1, blit_hw_A = 0,

blit_sw = 1, blit_sw_CC = 1, blit_sw_A = 0,

bitsize = 32, bytesize = 4,

masks = (16711680, 65280, 255, 0),

shifts = (16, 8, 0, 0),

losses = (0, 0, 0, 8)>

So, the alpha HW acceleration capabilities of the display in either mode are the same. I do a convert() on the surface before blitting so it's format should match the display's. Why is the blit so slow in one case (fullscreen surface) and realtime in the other (windowed surface)? I'm sure this has something to do with mismatches in surface modes, but I haven’t been able to get a handle on the details.

Thanks in advance...

-Scott

Hi

try to use convert_alpha() instead of convert() and the screen without the pygame.HWSURFACE flag.

~DR0ID