>
> On 2 Feb 2009, at 19:39, Greg Ercolano wrote:
>
> >> Thanx, I will look into the fl_offscreen; are there any
> >> examples/code snippets here on the site?
> >
> >     I just grepped the fltk 1.3.x 'FL' directory; looks like
> >     the functions are:
> >
> >             fl_create_offscreen(w,h)
> >             fl_begin_offscreen(pixmap)
> >             fl_end_offscreen()
> >             fl_copy_offscreen(x,y,w,h,pixmap,srcx,srcy)
> >             fl_delete_offscreen(pixmap)
> >
> >     I don't think they have docs yet.
> >
> >     My guess is you bracket your regular fltk drawing code
> >     with fl_begin_offscreen() and fl_end_offscreen(), and the
> >     pixels will go into ram instead of a window.
>
> Yes, what Greg says.
> Also, note that unlike "regular" fltk drawing, if you make your
> offscreen "current" by calling fl_begin_offscreen(pixmap) then you
> can draw to it *at any time* - not just within a fltk draw context,
> so this is different and sometimes more convenient than the usual
> fltk way of handling the drawing.
>
> Note also that you have to have *at least* one window mapped before
> you create your first offscreen context, because it uses the mapped
> window to ascertain the correct rendering properties. I'm not sure if
> that is documented or anything, it is just what I discovered trying
> to use them...
>
> So you show your main window, then sometime later you create the
> offscreen...
>
>       pixmap = fl_create_offscreen(w,h)
>
> Then later when you want to draw:
>       fl_begin_offscreen(pixmap)
>
>       (fltk drawing calls)
>
>       fl_end_offscreen()
>
> Then when you want to show part of the offscreen in your view
>
>       fl_copy_offscreen(x,y,w,h,pixmap,srcx,srcy)
>
> inside the ::draw() method of your view widget to blit a rectangle
> from the offscreen onto your view.
>
> That's about it, at a very high level, anyway.
>

Hi,
I'm trying to set up a small example program to play with the offscreen.
I found a old one from Lukasz  (May 03), but I don't get the point in deriving 
your own box and your own window.
I'm trying to use a standard window, but I don't even succeed in 
opening/closing the offscreen: the program crashes just at fl_begin_offscreen. 
What am I doing wrong here actually? I haven't drawn a single widget yet ... 
see my small program:

int main( ) {

   Fl_Double_Window *aWin = new Fl_Double_Window( 400, 400, "Fl_Offscreen test" 
);
  aWin->show( );

  std::cout << "Fl_Double_Window started" << std::endl;

  Fl_Offscreen scr;
  scr = fl_create_offscreen( 200, 200 );

  std::cout << "Fl_Offscreen created" << std::endl;

  fl_begin_offscreen( scr );

  fl_end_offscreen( );

  return Fl::run( );
}

gdb doesn't help either: this is the minimalistic stack trace - rather useless:

Core was generated by `a.out'.
Program terminated with signal 11, Segmentation fault.
[New process 14885]
#0  0xb7b1aa22 in XSetClipMask () from /usr/lib/libX11.so.6
(gdb) bt
#0  0xb7b1aa22 in XSetClipMask () from /usr/lib/libX11.so.6
#1  0xb7ee985c in fl_restore_clip () at fl_rect.cxx:513
#2  0xb7ee9916 in fl_push_no_clip () at fl_rect.cxx:572
#3  0x08048c01 in main () at offscreen-test.cpp:60

(offscreen-test.cpp:60 - fl_begin_offscreen( scr ); )


_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to