How to avoid breaking with pygame on Linux / X11

I played with pygame (on Debian / Lenny). It seems to work well except for the annoying burst blits (fullscreen or windowed mode).

I use the default SDL driver by default. Googling suggests that a known issue with SDL is that X11 does not provide vsync capabilities (even with a display created with the FULLSCREEN|DOUBLEBUF|HWSURFACE ), and I should use the dga driver instead.

However, working

 SDL_VIDEODRIVER=dga ./mygame.py 

starts pygame initialization with

 pygame.error: No available video device 

(despite the fact that xdpyinfo shows the XFree86-DGA extension).

So: what's the trick for getting unbound gaps? Either get a dga job or some other mechanism?

+6
graphics pygame sdl x11 vsync
source share
2 answers

Well, in the end, I decided to switch to Pyglet , which seems to support OpenGL much better than Pygame, and does not have any flickering problems.

+4
source share

The best way to minimize it is to minimize the frame rate as close as possible to the screen frequency. There is no vsync in the SDL library if you are not using OpenGL through it, so the only way is to get closer to the frame rate. A hardware dual SDL buffer is not guaranteed, although it is good when it is running. I rarely saw this in action.

In my experience with SDL, you should use OpenGL to completely eliminate the gaps. This is a bit of a correction, but drawing simple 2D textures is not that difficult, and you get a few added bonuses that you can implement, for example, rotation, scaling, blending, etc.

However, if you still want to use software rendering, I would recommend using a dirty rectangle update. It's also a bit hard to get used to, but it saves a ton of processing, which can make it easier to update updates until the whole screen scrolls (unless you scroll the entire playback area or something else). Like the time taken to draw to the buffer, at a minimum, this can cause blitting to occur during screen refresh, which causes a break.

+4
source share

All Articles