deleting primitive

Started by
1 comment, last by juanpablo56 13 years, 6 months ago
Hi,

Lets say i created two points on 2d world:

glBegin(GL_POINTS);
glVertex3f(20, 20, 0);
glEnd();

glBegin(GL_POINTS);
glVertex3f(50, 50, 0);
glEnd();

How can i erase only one of them while keeping other one?
Advertisement
You can either capture them using classes or variables. For example :
struct Point2D{ float _x,_y; Point(float x = 0.0f, float y = 0.0f) : _x(x), _y(y) {}};bool operator == (const Point2D& p1, const Point2D& p2){ return p1.x == p2.x && p2.y == p1.y;}std::vector<Point2D> points;points.push_back( Point2D(20,20));points.push_back( Point2D(50,50));void drawPoint(const Point2D& p){ glBegin(GL_POINTS);   glVertex3f(p.x, p.y,0.0f); glEnd();}void draw(){ std::for_each(points.begin(),points.end(),drawPoint);}//somewhere in your programpoints.remove( std::find(points.begin(), points.end(), Point2D(20,20) );


It just gives you and idea.
Edge cases will show your design flaws in your code!
Visit my site
Visit my FaceBook
Visit my github
thanks for your solution..

This topic is closed to new replies.

Advertisement