Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What do HWSURFACE and DOUBLEBUF do?

I saw online the use of HWSURFACE|DOUBLEBUF|RESIZABLE to resize the window.

It works but I'm not sure what the HWSURFACE and DOUBLEBUF actually do.

I know it stands for hardware surface and double buffer, but what they actually help with I have no idea.

like image 622
MicChe Avatar asked Mar 19 '15 00:03

MicChe


1 Answers

I'm disappointed that the pygame docs (e.g. http://www.pygame.org/docs/ref/display.html) don't seem to explain this as I would have thought they should have.

Double-buffering, as the description for the tag mentions, is using a separate block of memory to apply all the draw routines and then copying that block (buffer) to video memory as a single operation. Failure to do this can lead to graphical artifacts. A simple example could be flickering of the scene caused by part of background being drawn right before the video refreshes and then other parts afterwards (so they aren't shown until the next refresh).

Hardware surface refers to using memory on the video card ("hardware") for storing draws as opposed to main memory ("software"). The main reason for this is that the bandwidth between main memory and video memory tends to be slow and so being able to draw directly can speed this up. SDL (which PyGame is built on top of) was originally developed to support older video cards which didn't support hardware surfaces and so you have to request extra features to see if your hardware can take advantage of them. At this point in time, my understanding is that pretty much any video card (even on board ones on low end laptops made within the last couple of years (or even things like the Raspberry Pi but I'd need to check it) should support DOUBLEBUF and HWSURFACE. You may want to check the SDL documentation to see if that provides any additional details you need

Hope that helps

like image 99
Foon Avatar answered Oct 20 '22 05:10

Foon