Double buffering a panel in c++.net

Hi Im fairly new to c++.net and im writing an application which models little creatures represented by coloured squares which move around in a panel. Ive been having problems with screen flicker, and reading around it seems double buffering is the answer. Unfortunately though, I cant seem to find any help on implimenting it in c++ (seems to be lots in c# which I tried to adapt but it didnt work).

Any help would be appreciated, especially if it contains a few exemplory lines of code.

Thanks in advance,

Julian



Answer this question

Double buffering a panel in c++.net

  • Michael Barrett

    If you're using WinForms, I'd expect that setting the double buffered/etc styles as you've seen done in C# would work just fine.

    Yes, I meant the DirectX forum, but if you're using WinForms, then you should look again at setting the double buffered style, and the all paint in WM_PAINT style. I assume the latter kills WM_ERASEBKGND . Also, when you Invalidate your form, pass false as the parameter, to stop the WM_ERASEBKGND message from occuring.



  • Nitronic

    If you're not using WinForms, the C# stuff won't help, as it's built into the framework. Double buffering basically means that you keep two bitmaps in memory, and you use one to draw to the screen while you're rendering to the other one. You keep swapping which one you draw and which you draw on.

    As someone else said, the games forums would contain the most expertise on this subject. All games would be double buffered.



  • Gerardo Rossi

    The games folks could have more information on such issues.

    Thanks,
    Ayman Shoukry
    VC++ Team


  • mogulati

    Sorry, I should have been more specific, I am using WinForms as I'm using managed C++ code (2005 express edition). When you say look on the games forums, do you mean on the microsoft site somewhere

  • Double buffering a panel in c++.net