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

Re: [pygame] Double buffer?



On Wed, 2005-08-24 at 11:08 +0100, Dan wrote:
> I'm writing a game that (in theory) uses double buffering. At the start
> of the game I do this:
> 
>   screen = pygame.display.set_mode((430, 200), DOUBLEBUF|HWSURFACE)

The flags to set_mode() are more of a "request" than a real "demand".
You can find out if you really got a DOUBLEBUF display by checking the
display surface.

    if screen.get_flags() & DOUBLEBUF:
        print "it worked!"

The SDL library only supports DOUBLEBUF on HWSURFACE displays. The
DOUBLEBUF pretty much implies the other. Also, I don't think SDL
supports HWSURFACE in any windowed environment. This is just something
the SDL display backends fail to deal with. So you should actually be
using DOUBLEBUF|FULLSCREEN for this to have a chance at working.

This all changes a bit with OPENGL. When the display is OPENGL you
pretty much need to have DOUBLEBUF enabled. Single buffered opengl
stinks. With OPENGL though, you can get DOUBLEBUF inside of a window.
But with OPENGL, none of the pygame.draw and Surface.blit functions
really work. Use the flags OPENGL|DOUBLEBUF to get that running.
Fullscreen is optional for the OPENGL mode.

Lastly, be aware that even if the display surface is not hardware double
buffered. SDL internally does a software buffering so that nothing is
actually transferred to the screen until a display.flip() or
display.update() call is made.