Advice: -Read the lab sheet. -Read the small C++ tutorial if youre unsure. -Download files from webpage, and have a look at the sample code. -Read FLTK documentation - specificaly you will be interested in drawing routines, callbacks and subclassing -If you are planning on just drawing one point on the screen, it is probably best to inherit from Fl_Widget -If you are planning on making a 'frame-buffer' style drawing system, it is probably easyer to inherit from Fl_Box -If you want to draw lines using a frame-buffer you can just copy the simple bresenham line routine at the end (if you want to do something fancier, look up woo pixels & lines [grafix gems?]) -It is probably easiest to call your serial reading class by using the fltk::add_timeout event -A suggested design is to have a drawing class, a validation class, a serial reader, and the main program with the fltk code. -Remember, if you include a C file you may need to do: extern "C" { #include "cfile.h" } A real quick C++ tutorial. Basic program, identical to C: [code] #include int main(void) { printf("Hello world!\n"); return 0; } [/code] Now, a class, Animal: [code] #include class Animal { public: Animal() {printf("I made an animal");}; //This is the constructor ~Animal() {printf("I unmade an animal");}; //This is the destructor void PrintfHello() { printf("hello.\n"); } }; int main(void) { Animal a; printf("Hello world!\n"); a.PrintfHello(); return 0; } [/code] Declare a class with the class keyword, then the name of the class. In C++ you have "access rights" such as public, protected and private. This is for information hiding, if you want to be able to call the functions from anywhere, you need to make them public. The constructor is the function that gets called as soon as an animal is created (ie: static variable, or dynamic (new)) An example of inheritance: [code] #include class Animal { public: Animal() {printf("I made an animal\n");}; //This is the constructor ~Animal() {printf("I unmade an animal\n");}; //This is the destructor void PrintfHello() { printf("hello.\n"); } }; class Dog : public Animal { public: Dog() : Animal() { printf("I made a dog\n"); } }; int main(void) { Animal a; printf("Hello world!\n"); a.PrintfHello(); Dog *pdog; pdog = new Dog; pdog->PrintfHello(); delete pdog; return 0; } [/code] Now we have a class dog, which inherits from animal. An example of virtual functions: [code] #include class Animal { public: Animal() {printf("I made an animal\n");}; //This is the constructor ~Animal() {printf("I unmade an animal\n");}; //This is the destructor virtual void MakeNoise() = 0; }; class Dog : public Animal { public: Dog() : Animal() { printf("I made a dog\n"); } void MakeNoise() { printf("woof\n"); } }; class Cat : public Animal { public: Cat() : Animal() { printf("I made a cat\n"); } void MakeNoise() { printf("meow\n"); } }; int main(void) { Animal *pa; Dog *pdog = new Dog; Cat *pcat = new Cat; pa = pdog; pa->MakeNoise(); pa = pcat; pa->MakeNoise(); delete pdog; delete pcat; return 0; } [/code] And an example of how to seperate into .h files and .cpp files: [code] //in .h class Cat : public Animal { public: Cat(); void MakeNoise(); }; //in .cpp Cat::Cat(): Animal() { printf("I made a cat\n"); } void Cat::MakeNoise() { printf("meow\n"); } [/code] ======================== Draw line routine (no clipping): {warning: very old code} ======================== [code] int Sign(int x) { if (x>0) return 1; if (x<0) return -1; return 0; } void SafeDrawLine(int a,int b,int c,int d,DWORD col) { int i,s,d1x,d1y,d2x,d2y,u,v,m,n; u= c - a; v= d - b; d1x = Sign(u); d1y = Sign(v); d2x = Sign(u); d2y = 0; m = abs(u); n = abs(v); if (!(m>n)) { d2x = 0 ; d2y = Sign(v); m = abs(v); n = abs(u); } s = m >> 1; for (i=0;i