In case it helps, my first thoughts about how to implement the algorithm are:
class DrawnLine {
std::vector<sf::Vector2i> points;
public:
DrawnLine();
void addPoint(sf::Vector2i p) { points.push_back(p); }
void draw_me(RenderTarget& r) {
//draw lines between points 0 and 1, 1 and 2, etc...
}
}
int main() {
//initialize the window and other stuff
bool drawing = false;
//some kind of container for DrawnLines, if you want to keep track of more than the current one
DrawnLine currentLine;
while(window.isOpen()) {
if (sf::Mouse::isButtonPressed(sf::Mouse::Left)) {
if(drawing) {
currentLine.addPoint(sf::Mouse::getPosition());
} else {
drawing = true;
//start a new line, giving currentLine a new value, possibly saving its old value
}
} else {
drawing = false;
}
//clear/draw/display
}
}