• Advertisement
Sign in to follow this  

deleting primitive

This topic is 2685 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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 program
points.remove( std::find(points.begin(), points.end(), Point2D(20,20) );


It just gives you and idea.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement