[plt-scheme] Double buffer (scheme/gui)

From: Doug Williams (m.douglas.williams at gmail.com)
Date: Sat Apr 11 16:50:16 EDT 2009

I have an animated-canvas class on PLaneT that does the double-buffering
automatically - I'm sure there are other similar solutions out there too
(e.g., I think frtime has some similar classes).

Doug

On Sat, Apr 11, 2009 at 1:27 PM, Robby Findler
<robby at eecs.northwestern.edu>wrote:

> Nevertheless, double buffering means that you have to have the entire
> thing in a single buffer. Otherwise you'll draw the tunnel with no
> copter and then draw the copter on top, which leads to flicker.
>
> I don't know what the rest of your code does, but perhaps you don't
> really need those two bitmaps at all.
>
> But if you do, then you'll need a third bitmap.
>
> Robby
>
> On Sat, Apr 11, 2009 at 2:22 PM, CHAMLY <marc.chamly at gmail.com> wrote:
> > Yes, But I have 2 bitmaps, because both of my objects have to move
> > independently, the tunnel has to be able to move to the left, without
> moving
> > the Copter, and the Copter has to move Up and Down without moving the
> > tunnel...
> >
> > Marc
> >
> >
> >
> > On Apr 11, 2009, at 8:47 PM, Robby Findler wrote:
> >
> >> Oh! I misread the code. You need to create a single bitmap containing
> >> the whole thing and then draw it. Don't draw two bitmaps (that's
> >> what's causing your flicker).
> >>
> >> Robby
> >>
> >> On Sat, Apr 11, 2009 at 12:59 PM, CHAMLY <marc.chamly at gmail.com> wrote:
> >>>
> >>> Well I already put the 'no-autoclear  to the canvas, my BITMAP-DC-1
> >>> (tunnel)
> >>> doesn't flicker only my BITMAP-DC-2(Object) flickers, I will try to put
> >>> the
> >>> 'no-autoclear somewhere else, and see if it works.
> >>>
> >>> Thank you.
> >>>
> >>> On Apr 11, 2009, at 7:31 PM, Robby Findler wrote:
> >>>
> >>>> Probably you want to pass the 'no-autoclear style to the canvas%
> >>>> object when you create it (I may have got the precise name wrong, but
> >>>> it is listed in the docs for the initialization arguments to canvas%).
> >>>>
> >>>> But you also probably want to only recreate the bitmaps when their
> >>>> content changes, not every time the window is refreshed. In other
> >>>> words, all but the last line below should be somewhere else, not in
> >>>> the on-paint method.
> >>>>
> >>>> Robby
> >>>>
> >>>> On Sat, Apr 11, 2009 at 12:25 PM, CHAMLY <marc.chamly at gmail.com>
> wrote:
> >>>>>
> >>>>> HI!
> >>>>>
> >>>>> I am programming a game on scheme using #lang scheme/gui, the game is
> >>>>>  made
> >>>>> of:
> >>>>> 1) an object (copter) that when you click moves up, otherwise it
> falls
> >>>>> down,
> >>>>> and does not move horizontaly.
> >>>>> 2) a tunnel that moves from right to left, giving the impression that
> >>>>> the
> >>>>> object is moving forward (moving to the right reaching the end of the
> >>>>> tunnel).
> >>>>>
> >>>>>
> >>>>> I have a little problem with my double buffer,
> >>>>> I'm using two bitmaps one to draw the copter, and one to draw my
> tunnel
> >>>>>
> >>>>> Here is what i have in the paint-callback of my canvas:
> >>>>>
> >>>>>           (send BITMAP-DC-1 clear)              ; i move my tunnel
> >>>>>           (send TUNNEL draw-tunnel1  BITMAP-DC-1  y1)
> >>>>>           (send dc draw-bitmap BITMAP-1  (- x-canvas) 0 'solid))
> >>>>>
> >>>>>
> >>>>>           (send BITMAP-DC-2 clear)     ; i move my copter
> >>>>>           (send BITMAP-DC-2 draw-bitmap copterUp  0 0 'solid)
> >>>>>
> >>>>>           (send dc draw-bitmap BITMAP-2  150 (send COPTER
> get-y-copter)
> >>>>>  'solid))
> >>>>>
> >>>>> The problem is that my copter still flickers, and i don't know why??
> >>>>> (i don't draw my copter in BITMAP-DC-1 because afterwords i also use
> >>>>> other
> >>>>> bitmaps to draw my tunnel)
> >>>>>
> >>>>> thanks
> >>>>>
> >>>>>
> >>>>> Marc
> >>>>>          _________________________________________________
> >>>>>  For list-related administrative tasks:
> >>>>>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
> >>>>>
> >>>
> >>>
> >
> >
> _________________________________________________
>  For list-related administrative tasks:
>  http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20090411/6851181d/attachment.html>

Posted on the users mailing list.