Board index » delphi » Double Buffering in Canvas?

Double Buffering in Canvas?

Hello!

I have a problem which is sprung out of my not-knowledge of Windows-API..
I wonder if you can draw on the canvas without the canvas showing it,and on a certain command switch so all changes seem to appear instantly.

The windowlockupdate is not the right command,because it simply stores the commands without doing them and when you release the window it just executes them and i will have the same problem...

In games programming,you solve this by a method called 'double-buffering' in which you draw on one screen while you display screen #2.

Can it be done in an easy way..(i'd rather not have two screens)

Grettings from Sweden and Magnus Lidman  

 

Re:Double Buffering in Canvas?


Quote
d95ma...@dtek.chalmers.se (Magnus Lidman) wrote:
>Hello!
>I have a problem which is sprung out of my not-knowledge of Windows-API..
>I wonder if you can draw on the canvas without the canvas showing it,and on a certain command switch so all changes seem to appear instantly.
>The windowlockupdate is not the right command,because it simply stores the commands without doing them and when you release the window it just executes them and i will have the same problem...
>In games programming,you solve this by a method called 'double-buffering' in which you draw on one screen while you display screen #2.
>Can it be done in an easy way..(i'd rather not have two screens)
>Grettings from Sweden and Magnus Lidman  

Try creating a Temporary TCanvas, then copying it to the one you wish
to show.

I.e.  MyCanvas: TCanvas;
      MyCanvas:= TCanvas.Create(Self);

Brien King
bk...@primenet.com

Re:Double Buffering in Canvas?


Quote
>>In games programming,you solve this by a method called 'double-buffering' in which you draw on one screen while you display screen #2.

>>Can it be done in an easy way..(i'd rather not have two screens)

>>Grettings from Sweden and Magnus Lidman  

>Try creating a Temporary TCanvas, then copying it to the one you wish
>to show.

>I.e.  MyCanvas: TCanvas;
>      MyCanvas:= TCanvas.Create(Self);

You could also use something like WinG, which essentially gives you the double
buffer mechanism, and is reasonably fast.  Or use DISPDIB.DLL to shut off the GDI and
set the video mode yourself (or wait for DirectDraw), and write directly to the
screen.

Other Threads