realbasic-games
[Top] [All Lists]

Re: Canvases sometimes black

To: REALbasic Games <realbasic-games at lists dot realsoftware dot com>
Subject: Re: Canvases sometimes black
From: "Joseph J. Strout" <joe at realsoftware dot com>
Date: Mon, 27 Jun 2005 09:48:38 -0500
Delivered-to: realbasic-games at lists dot realsoftware dot com
References: <BEE5084A dot DD9D%larsjensen at rcn dot com> <d2fcd18d080737fcded2aa9997cb617f at rpsystems dot net>
At 10:36 AM -0400 6/27/05, Troy Rollins wrote:

Certain events occur within the control window which dictate that the canvas window's content must be updated. At those points I call "updateGameScreen" which is a method belonging to the master control module. The updateGameScreen method writes many things to the graphics property of the canvas - including refilling the background image, lots of text things (drawstring and drawStyledText), etc. At the end of this large method which determines what to paint and where, I call PaintBuffered() on the canvas.

This all sounds like a fine approach, if using a standard Canvas. I haven't used this AutoBufferingCanvas, but what I would do in a case like this is either draw directly to the canvas .graphics property, or draw to my offscreen picture (and then end by drawing this picture to the canvas.graphics).

I think the problem here, from Lars's description and what you say above, is that by drawing directly to canvas.graphics, you're not updating the AutoBufferingCanvas's buffer. So when you call PaintBuffered, it paints what the buffer contains (i.e. blackness). I don't know if this AutoBufferingCanvas even provides a way to draw directly to its buffer, but even if it does, it doesn't sound to me any easier or safer than doing it yourself as I describe above.

I had considered putting "updateGameScreen" into the paint event, but then thought that might cause some circular thing to happen with the window attempting to redraw continuously. Is it important to implement the paint event?

Generally so, but I wouldn't worry about it much at this point. Ultimately you should probably have the Paint event call your UpdateGameScreen method, just to handle that odd case when the window has to be redrawn by the system because it was covered (and then revealed) by a dialog or whatnot. But the Paint event will *not* be involved in the normal game animation.

Best,
- Joe

--
Joe Strout                          REAL Software, Inc.

Vote for REALbasic (twice!) in the LinuxWorld Reader's Choice Awards:
http://linux.sys-con.com/general/readerschoice.htm
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>