Can't draw things FLTK

I want to draw my own widget in FLTK and as the documentation said I need to subclass Fl_Widget and override draw() which is exactly what I did. I'm using FLTK 1.3.2. Am I missing something?

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
#include <FL/Fl_Widget.H>

class Shape : public Fl_Widget
{
public:
	Shape() : Fl_Widget(250, 150, 400, 300) { }
	void draw()
	{
		std::cout << "void Shape::draw()" << '\n';
		fl_line(50, 50, 150, 50); // doesn't draw anything
		fl_rect(70, 70, 80, 80);
	}
};

int main()
{
	Fl_Window* win = new Fl_Window(400, 300);
	win->begin();
	Shape* obj = new Shape;
	win->show();
	win->end();
	return(Fl::run());
}


Thanks in advance to anyone who replies!
I don't know fltk but don't you need to add the shape to the window?
Topic archived. No new replies allowed.