Re: drawables and refresh rates
- From: Rob Benton <rob benton conwaycorp net>
- To: gtkmm-list <gtkmm-list gnome org>
- Subject: Re: drawables and refresh rates
- Date: Thu, 02 Dec 2004 02:38:46 -0600
Andrew E. Makeev wrote:
Rob Benton wrote:
Jan Hudec wrote:
On Wed, Dec 01, 2004 at 11:14:58 -0600, Rob Benton wrote:
I have a Gdk::Drawable where I'm drawing 2 arcs. A blue circle and
a red arc drawn on top of the blue circle. I've got 2 Gtk::HScale
widgets using a DISCONTINUOUS_UPDATE that modify the angle and width
of the red arc. On update the the blue circle is redrawn and then
the red is redrawn on top of it using the values from the scale
widgets. This causes some flickering on the drawing area. Is there
a better way to do this?
Computer graphics 101. Double buffering.
-------------------------------------------------------------------------------
Jan 'Bulb' Hudec <bulb ucw cz>
Well I'm a mediocre pencil & paper artist but I'm a total noob at
computer graphics. Do you guys know of any resources I could use to
get started?
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.
Regards,
-andrew
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.
Method A looks like this:
----------------------------------------------------------------------
bool MyClass::drawarea_expose_event(GdkEventExpose * e)
{
Glib::RefPtr<Gdk::Window> window = _drawarea.get_window();
window->clear();
draw_circles();
return true;
}
----------------------------------------------------------------------
Method B looks like this:
----------------------------------------------------------------------
void MyClass::draw_circles()
{
_gc->set_foreground(blue);
_gc->draw_arc(/* whole circle */);
_gc->set_foreground(red);
_gc->draw_arc(/* arc */);
}
----------------------------------------------------------------------
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]