On 23.01.2012 10:23, Kai-Uwe Behrmann wrote: > I try to create a Fl_Group derived widget, which redirects pixels > by means of a fl_offscreen buffer for manipulation. > fl_offscreen works fine, pixel manipulation is fine, but drawing is > displaced. > > My_Group::draw() > { > if(init || resize) > { > off = fl_create_offscreen(w(),h()); > off_buf = new unsigned char[w()*h()*4]; > } > fl_begin_offscreen(off); > Fl_Group::draw(); > fl_read_image(off_buf,0,0,w(),h()); > fl_end_offscreen(); > // do some stuff with off_buf ... > fl_draw_image(off_buf, x(),y(),w(),h()); > } > > If I comment out the offscreen stuff the Fl_Group::draw() draws > everything correctly. Now I think that Fl_Group draws into the > Fl_Double_Window's offscreen buffer on window coordinates. > Obviously I want FL_Group::draw() to draw into Fl_Groups local > coordinates. The My_/FL_Group widget has a x() and y() value. > The desired way to workaround that difference > between Fl_Group and my derived My_Group would be to set an > offset before the Fl_Group::draw() command above.
... or set the Fl_Group's coordinates temporarily to (0,0) before calling draw() and reset them afterwards. > Is there a way to place a global drawing instruction like: > all following drawing operations must use a specified offset? The matrix functions allow that (fl_translate() etc.), but not all drawing functions work with these coordinate transformations. It depends on which drawing functions you need... > An alternative might be to use a offscreen buffer that is equal to > the window buffer. But that seems not economic, as the offscreen > buffers will overlap and most space is in them not used. IMHO the easiest way is to manipulate the group coordinates as written above, but maybe there are other options... Albrecht _______________________________________________ fltk mailing list fltk@easysw.com http://lists.easysw.com/mailman/listinfo/fltk