Can't create ofPolyline from ofVec2f

Before I create an issue on Github, I want to check if I might be doing something wrong.

The docs for ofPolyline say:

Creates an ofPolyline from a vector of ofVec2f or ofPoint objects.`

This works:

vector<ofPoint> pts;
pts.push_back(ofPoint(0, 0));
pts.push_back(ofPoint(100, 100);
ofPolyline line(pts);

But doing the same with ofVec2f crashes on the last line:

vector<ofVec2f> vecs;
vecs.push_back(ofVec2f(0, 0));
vecs.push_back(ofVec2f(100, 100));
ofPolyline line(vecs);

Am I missing something?

To update; you can create an ofPolyline from an ofVec3f vector, but not an ofVec2f vector. This (same as above but with ofVec3f) does work:

vector <ofVec3f> vecs;
vec.push_back(ofVec3f(0, 0));
vec.push_back(ofVec3f(100, 100));
ofPolyline line(vecs);

I tried to take a look at the source, and locally I have a ofPolyline.cpp file (of_v0.9.3_linux64_release/libs/openFrameworks/graphics/ofPolyline.cpp), but I can’t seem to find this file in the Github repo?

Update: created an issue here.

The documentation in the web refers to the current official version. In the repo ofVec* is now deprecated and is recomended to use glm::vec* instead.

ofPolyline is now templated (that’s why there’s no cpp) and by default uses glm::vec3.but you can also create a polyline of glm::vec2 or ofVec2f using:

ofPolyline<glm::vec2> polyline2(vecs);


ofPolyline<ofVec2f> polyline2(vecs);
1 Like

So that means the current documentation is wrong in saying you can use ofVec2f, but it (ofVec2f) will be removed in the next update anyway?

yeah you are correct, the constructor docs should say ofVec3f or ofPoint which are actually the same. if you want to send a PR to ofSite?

@arturo @javl, I can take care of the PR