realbasic-nug
[Top] [All Lists]

Re: canvas flicker on windows builds

To: "REALbasic NUG" <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: canvas flicker on windows builds
From: "Maarten de Vries" <maarten dot de dot zoveelste at gmail dot com>
Date: Fri, 30 Jun 2006 18:04:11 +0200
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=GENT3FoUIGN6qKSAlPUJ85nYV+sG+GwxzFbLy8XTIAqmNNDS2QMxtzM3Q7gPNrX+XfImacC7F4Cv8HEWgyvM7iQ+k+T/66wN1Ml08pyKGEjafc9H2MEQYzl4vd46muVtCfbsi1hbkw82cNOr8XWZ29rxO7CXUQPovFnpV15bdiI=
References: <E101F8EC-0492-4FC2-8646-F71096CE6C0D at mac dot com> <20060630155034 dot E2EA57F01A at swarthymail-a3 dot dreamhost dot com>
What id do is this:
Set EraseBackground to false
Draw stuff to a picture
In the paint event, draw the picture to the canvas

When you need to update, call "Canvas.Refresh FALSE". This is an optional
parameter to specify whether or not the background should be erased this
time. It defaults to true, which is why normally you'd get flickering by
calling refresh. But if you say false it won't flicker (much). There is
nothing wrong with refresh, as long as you specify false.

The reason why you shouldn't just paint directly to the canvas is that it's
going to be empty if you put a window in front of it. By using the paint
event, you redraw it every time it needs to be redrawn.

Maarten


On 30/06/06, joe at strout dot net <joe at strout dot net> wrote:

On Jun 30, 2006, at 15:36 UTC, John Kubie wrote:

> The flicker I am seeing is unacceptable. As I said before, I would
> love to see an example of a simple, flicker-free project.

There are many, and it's trivial to make such.  As others have pointed
out, you simply need to avoid calling Refresh; draw directly into the
canvas.graphics instead, without erasing.

If you want an example, drag two pictures into a canvas, and throw on a
checkbox with this code:

if me.Value then
   Canvas1.graphics.DrawPicture picture1, 0, 0
else
   Canvas1.graphics.DrawPicture picture2, 0, 0
end if

This will swap pictures on every click with no flicker, even on
non-double-buffered systems like Windows.

Best,
- Joe

--
Joe Strout -- joe at strout dot net
Verified Express, LLC     "Making the Internet a Fucked up Place"
http://www.verex.com/


_______________________________________________
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>