SDL_Flip doesn't wait vsync under X11

http://www.libsdl.org/cgi/docwiki.cgi/SDL_5fFlip says

If your display mode is using the flags pygame.HWSURFACE and pygame.DOUBLEBUF,
this will wait for a vertical retrace and swap the surfaces. If you are using
a different type of display mode, it will simply update the entire contents of
the surface.

It doesn’t work with SDL under X11, wich mean that every SDL applications runs
with tearing artefacts under X11. IMHO it is a CRITIAL bug. I know it’s due to
X11, but a solution must be found NOW ! It’s amazing to imagine that simple
graphical applications that could be done on a C64 cannot be done under
Linux/X11 in 2007 :).

http://bugzilla.libsdl.org/show_bug.cgi?id=406 Opened

With pygame installed, you can easily test it (if you like to take risks) by
typing on a terminal:

python -c “curl http://lesuisse.net/vsynctest.py

or run the following python code-----------------------------------
#!/usr/bin/python
import math,sys,time,pygame
pygame.init()
screen =
pygame.display.set_mode((640,480),pygame.FULLSCREEN|pygame.DOUBLEBUF|pygame.HWSURFACE)
c=0
while 1:
c=((c+1)%2)*255
for event in pygame.event.get():
if event.type in [2,5,6,12]:
sys.exit()
screen.fill((c,c,c))
pygame.display.flip()

It doesn’t work with SDL under X11, wich mean that every SDL applications runs
with tearing artefacts under X11. IMHO it is a CRITIAL bug. I know it’s due to
X11, but a solution must be found NOW !

Right now, huh?

The docs say your surface must have the HWSURFACE flag…even if you
request it on X11, the SDL_Surface returned by SDL_SetVideoMode() won’t
have it. X11 doesn’t expose that functionality to clients.

If you have a good way to make it happen, we’ll implement it. But I
think it would take an X11 extension to do so.

(It’s worth noting that glX can be set to do real hardware page
flipping, if you can use OpenGL…we expose this with
SDL_GL_SWAP_CONTROL in SDL_GL_SetAttribute(), and there are environment
variables in the Nvidia drivers to force it on GL contexts, too.)

–ryan.

Hello !

If you have a good way to make it happen, we’ll implement it. But I
think it would take an X11 extension to do so.

For those things DGA was used. And i think you can still use it in
SDL, but your app later needs more permissions for example to /dev/mem
or needs to be run as root.

CU