Hi, I would like to draw some things offscreen and some things directly. 
Unfortunately I have problems. Below is a code that compiles and runs fine (it 
basically creates an offscreen, erases it and puts it on the screen).

But after uncommenting the only commented line of code I get a seg fault.

#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/Fl_Box.H>
#include <FL/fl_draw.H>
#include <FL/x.H>

class plot_box: public Fl_Box {
 public:
        plot_box(int,int,int,int);
 protected:
        void draw();
 private:
        Fl_Offscreen scr;
};

plot_box::plot_box(int x,int y, int w, int h):Fl_Box(x,y,w,h) {}

void plot_box::draw() {
        if(!scr) {
                scr = fl_create_offscreen(w(),h());
                fl_begin_offscreen(scr);
                fl_color(FL_BLACK);
                fl_rectf(x(),y(),w(),h());
                fl_end_offscreen();
        }
        fl_copy_offscreen(x(),y(),w(),h(),scr,0,0);
}

class mywin: public Fl_Window {
 protected:
        void draw();
 public:
        mywin(int,int);
};

mywin::mywin(int a, int b) : Fl_Window(a,b) {}

void mywin::draw() {
        Fl_Group::draw_child( *(child(0)) );

//after uncommenting below I get a segmentation fault
//
//      fl_draw("test",10,10);
}

int main() {
        mywin *lala =new mywin(400,400);
        plot_box *pbox = new plot_box(0,0,200,200);
        lala->end();
        lala -> show();

        return Fl::run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to