View Full Version : Drawing retained Points with MouseMotionFunc

12-09-2003, 10:04 PM

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

12-10-2003, 02:30 AM
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<point> 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).]

12-10-2003, 09:49 PM
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