SRL Archive - OSR Help

GetDebugCanvas?


Echo_

2011-04-15 15:21:46

I recently started a game project with Simba but am having issues with the function GetDebugCanvas. All of the tuts I have read use it but I get an Unkown Identifier error when I try to use it in Simba(SCAR function perhaps?). Is there something I can use that is the same or similar to GetDebugCanvas that will work with Simba?

Extra info: these are the tuts I was using.
http://villavu.com/forum/showthread.php?t=40754
http://villavu.com/forum/showthread.php?t=50776

Dgby714

2011-04-15 15:35:58

function GetDebugCanvas: TCanvas;
begin
Result := GetMufasaBitmap(GetDebugBitmap()).ToTBitmap.Canvas;
end;

Wizzup?

2011-04-15 15:41:54

Dgby, that will leak a lot. ToTBitmap creates a new TBitmap.

Echo_, create a T(Mufasa)Bitmap and do your magic on it, then paint it to the Debug image/window. That's how you should do it, do not perform the painting directly on the window.

Wizzup?

2011-04-15 15:48:47

To clarify, you should generally always be drawing to an ``off screen'' bitmap. Once you're done drawing, you can paint it on the screen. Most programs use two of these off screen bitmaps, draw one to the screen and already work on the other one. It's called double buffering. Single buffering is when you use a single off screen bitmap. Single should suffice.

Why? To prevent overhead and general flickering. For example, you don't want the window to repaint when you've changed only one pixel. You also don't want it to draw stuff to the screen when you're not done painting. That can cause incomplete images and tearing.

So, generally you can just work on a TMufasaBitmap (or TBitmap if you really want that canvas for whatever reason). When you're done painting, draw it to the debug image. Then start painting again.


Further reading: https://secure.wikimedia.org/wikipedia/en/wiki/Multiple_buffering#Double_buffering_in_computer_graphics

Echo_

2011-04-16 14:02:51

Thanks Dgby and Wizzup, I got it working the way I want it to :)