How to use fl_rectf() correctly?

20 views
Skip to first unread message

Graham Reitz

unread,
Jul 25, 2016, 1:29:04 PM7/25/16
to fltk.general
Hello,

What am I missing in the following code?  I have been unable to get a green filled box to appear in the window.  A blank window appears with the following message in the terminal CGContextFillRects: invalid context 0x0.

int main( int argc, const char* argv[] )


{

   Fl_Window *window = new Fl_Window(600,300);

   
   window
->
begin();

   
   fl_rectf( 10, 10, 50, 50, FL_GREEN );

   
   window
->
end();

   window->show();

   
   return Fl::run();

}



Thank you in advance for any assistance.

Graham

Greg Ercolano

unread,
Jul 25, 2016, 1:45:03 PM7/25/16
to fltkg...@googlegroups.com
On 07/25/16 09:04, Graham Reitz wrote:
> Hello,
>
> What am I missing in the following code?
> I have been unable to get a green filled box to appear in the window.

Start with the docs for 'Drawing Things In FLTK':
http://www.fltk.org/doc-1.3/drawing.html

Note all drawing functions are /only/ allowed within the draw()
method of a derived class.

You might want to start with a simple example from the cheat page
that shows how to draw an 'X':
http://seriss.com/people/erco/fltk/#FltkX

..you can of course replace the line drawing functions with an fl_rectf() call,
and go from there.

Graham Reitz

unread,
Jul 25, 2016, 5:45:33 PM7/25/16
to fltk.general, erco_...@seriss.com
Thanks again!
Reply all
Reply to author
Forward
0 new messages