Re: drawables and refresh rates
- From: Carl Nygard <cjnygard fast net>
- To: Rob Benton <rob benton conwaycorp net>
- Cc: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: drawables and refresh rates
- Date: Sat, 04 Dec 2004 02:09:20 -0500
On Sat, 2004-12-04 at 01:04, Rob Benton wrote:
> Carl Nygard wrote:
> > On Fri, 2004-12-03 at 04:43, Andrew E. Makeev wrote:
> >
> >>Rob Benton wrote:
> >>
> >>
> >>>Andrew E. Makeev wrote:
> >>>
> >>>
> >>>>Before to answer you, we need to know how do you "draw" your circles?
> >>>>The common way is to use expose_event to redraw only those parts of
> >>>>the drawing area that actually were changed. In this case I never
> >>>>seen any flickering in my applications even on Celeron 300Mhz.
> >>>>
> >>>
> >>>Right now I'm using 2 methods. Method A handles the expose event of
> >>>the Gtk::DrawingArea which then calls method B. Method B is also
> >>>connected to the value changed signal of both the Gtk::HScale widgets.
> >>>
> >
> >
> > I do something like:
> >
> > Method A handles expose events, and redraws exposed rectangle from
> > internal pixmap.
> >
> > Method B connected to value changed signal, draws to internal pixmap,
> > calls queue_draw() which eventually triggers Method A.
> >
>
> Carl I did some reading on double buffering. Where I've been stuck is
> that in order to start drawing to a Gdk::Drawable, it has to be realized
> first. Pixmap looks like what I need but its create methods all take a
> Glib::RefPtr<Gdk::Drawable>. And I get a segfault when I try that.
>
> > You can add efficiency by keeping track of the bounding box of what you
> > redraw, and only trigger expose events for those rectangles.
> >
>
> How would I do that? I have 1 drawing area widget which
> is 100x100. I draw a complete blue circle and then a red arc on top of
> that. Finally, to smooth out the edges I load an svg which is a smooth
> black circle outline. The flickering comes even if I don't use
> window->clear() just b/c each draw command overlaps the previous one.
>
Hooking into the expose_event should work. Gtk takes care of the double
buffering itself. I think it's automatic, but I could be wrong...
Just create the pixmap and draw to it first time through the expose
callback? Or some other ugly hack, I don't remember the answer. Could
be hook into configure event, or realize event. There's examples on
this because allocating colors has the same sort of problem.
// .. create widgets
_widg->signal_expose_event().
connect(SigC::slot(*this, &GtkScreen::_ExposeCB));
// initialization
_widg->queue_draw();
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]