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.





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

Reply via email to