On 6 Feb 2009, at 15:01, Fabio Bracci wrote:

> Moreover, I also managed to create the offscreen outside the draw()  
> in the derived window, but then you need to precede the  
> fl_create_offscreen by Fl::flush( ); aWin->make_current( );
> Alternatively you still can create it within the draw() function,  
> but I dislike that as it is an action to be taken once, so it's  
> ugly to have draw() check all the time for an initialized  
> pointer ... at least, in my opinion.

This is always going to be a matter of opinion, of course.
I much prefer to do it within the draw method, for a number of  
reasons, but mainly because that style is congruent with what you  
would do using many other graphical rendering contexts, e.g. that  
idiom is commonplace in OpenGL and Cairo code, and is widely understood.

Ah! Perhaps you think that checking the rendering context is valid,  
whilst in the draw method, has a performance impact?
Let me assure you that when it comes to rendering even a fairly  
simple view, the cost of one extra conditional test is undetectable.  
Even simple graphics operations chew cpu cycles up!

> I have two questions:
>
> a) including <FL/x.H> is ugly for cross-platform programming, can I  
> include an header automatically selecting x.h or win32.h or any  
> platform related header which is needed?

That is exactly what x.H does - it is a wrapper for the appropriate  
platform-specific content. So you should include x.H on any platform,  
and the appropriate (X11, win32, OSX) stuff will then be included.

> b) so far the drawing is done through fl_rectf, would it work the  
> same way if full widgets are drawn?

I assume by now you have seen my subclassed-Fl_Group example and know  
that the answer to this question is yes...

-- 
Ian

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

Reply via email to