I have searched the forum, read the doc and tutorial sorry if I missed something.
I am trying to draw a trail behind moving planets. Unfortunately, there is an extraline that should not be there linking the last vertex of my vertexArray and the origin of my window. You can see in the picture I uploaded. I have no vertex(0,0) in my array, and even if I had, I am erasing the last points when my array gets larger then 500 points so at some point, it should be erased. However, the extraline is always there and follows the last vertex of my trail.
//MY TRAIL
if(utility_clock.getElapsedTime().asSeconds() > 0.01){
utility_clock.restart();
Vector2f aVec(myState.x, myState.y);
myTrace.push_back(aVec);
}
while(myTrace.size() > 500){
myTrace.erase(myTrace.begin());
}
VertexArray trace(LinesStrip, myTrace.size());
for(vector<Vector2f>::iterator it = myTrace.begin(); it != myTrace.end(); ++it){
it->x -= offset.x;
it->y -= offset.y;
trace.append(Vertex(*it, Color::White));
}
myWin.draw(trace);
I have tried drawing the exact same thing using indexes like in the tutorial, and it works fine.
int cpt = 0;
for(vector<Vector2f>::iterator it = myTrace.begin(); it != myTrace.end(); ++it){
it->x -= offset.x;
it->y -= offset.y;
trace[cpt] = Vertex(*it, Color::White);
cpt++;
}
What's with the function append? Am I using it wrong? I thought it was similar to a push_back function for vectors.