[Gambas-user] DrawingArea problems

Timothy Marshal-Nichols timothy.marshal-nichols at ...247...
Wed Oct 11 09:21:09 CEST 2006


> -----Original Message-----
> From: gambas-user-bounces at lists.sourceforge.net [mailto:gambas-user-
> bounces at lists.sourceforge.net] On Behalf Of Benoit Minisini
> Sent: 10 October 2006 18:42
> To: mailing list for gambas users
> Subject: Re: [Gambas-user] DrawingArea problems
> 
> On Tuesday 10 October 2006 19:20, Christopher Brian Jack wrote:
> > Is there a glitch with drawing to DrawingAreas?
> >
> > My former code to use a backbuffer:
> >
> > ========== 8x ==================================
> >
> > private backBuffer as Picture
> >
> > public sub Form_Open()
> >   '...
> >   backBuffer=new Picture(640,480,FALSE)
> >   '...
> > End
> >
> > public sub Render()
> >   Draw.Begin(GfxArea)  'GfxArea is a DrawingArea
> >   Draw.Picture(backBuffer,0,0,0,0,640,480) 'buckBuffer is a Picture
> >   Draw.End()
> >   'Blank back buffer
> >   Draw.Begin(backBuffer)
> >   FillRect(0,0,640,480,&H000000&)
> >   Draw.End()
> > End
> >
> > ========== 8x ==================================
> >
> > Is not drawing to the DrawingArea any more.  Is there a semantic
that
> > changed that makes this so it has to be done differently or is
something
> > in 1.9.44 broken thus causing this...?
> >
> 
> This won't work if you don't set the Drawing.Cached property.
> 
> Anyway, what you want to do is what is already done by the
Drawing.Cached
> property. Unless you need the back buffer for doing something other
than
> drawing on it...
> 

I have found that there are two reasons for using a buffer like this:

1. If you have lots of small objects to draw it can look better as you
do not see all the background objects draw over the foreground objects.
You reduce the screen flicker as objects are drawn.

2. It can be faster, again if you have a lot of objects to draw. Drawing
to memory is faster than drawing to the screen. So if background objects
get covered by foreground objects. You can speed things up if you draw a
more complex picture or image to the screen. 

Both these points depend on what you are drawing. They are not true in
all cases. So you need to experiment.

The other point I would make is that I would make the backBuffer an
Image. An Image is stored in memory while a Picture is stored on the X
server. 

Thanks

8-) Timothy Marshal-Nichols
<mailto: timothy.marshal-nichols at ...247...>







More information about the User mailing list