Drawing retained Points with MouseMotionFunc


What would you think would be the best and easiest way to draw points to a window in opengl. I need the points to be draw when the MouseMotionFunc Callback is called by GLUT. Then I trap all the pixels, for later use. But I also want the canvas to be drawn in retained mode, allowing anything draw to the canvas to stay there. I’ve tried display lists with minimal results. Is there anything else I can do.

THank you
Anthony Bargnesi

Store all the points in a list, something like this.

struct point
int x, y;
point() {}
point(const point &p) : x(p.x), y(p.y) {}
void operator =(const point &p) {x=p.x; y=p.y;}
operator int *() {return &x;}

vector points;

Then add points to the list in whatever callback you want.

point p;
p.x = x;
p.y = y;

And draw them in the display callback.

for_each(points.begin(), points.end(), glVertex2iv);

[This message has been edited by Bob (edited 12-10-2003).]

Ok. I tried something similar. It worked. I had to draw points and then draw lines connecting points in sequence, to give it the scribble effect. If i just drew points, it would miss drawing pixels occasionally.

THanks a lot