polyline.curveTo(ofVec2f); // No matching member function for call to 'curveTo


#1

Hello everyone,

I am doing a graphic tutorial from the Openframeworks book and there seem to be a conflict in the exemple code. Indeed, when I wan to use the x, y coordinates stored in my ofVec2f in a polyline.curveTo(); it says “No matching member function for call to ‘curveTo’”.

Here is the bit of code:

void ofApp::update(){

if (leftMouseButtonPressed) {

    ofVec2f mousePos(ofGetMouseX(), ofGetMouseY());
    if (lastPoint.distance(mousePos) >= minDistance) {
   
        currentPolyline.curveTo(mousePos);  // Here I get the error message
        lastPoint = mousePos;
    }
}

}

And here is the ofBooks link:
https://openframeworks.cc/ofBook/chapters/intro_to_graphics.html#brushesfromfreeformshapes

Thank you!
Juliette


#2

Hello Juliette, welcome to the forum ;). If you change this line:

ofVec2f mousePos(ofGetMouseX(), ofGetMouseY());

to this:

ofPoint mousePos(ofGetMouseX(), ofGetMouseY());

Everything works fine. I am going to update the tutorial, many thanks for pointing this out.

@arturo, should curveTo accepts a glm::vec2 too? or are we ok with an ofPoint?


#3

No, adding cast operators from ofVec2 -> glm::vec3 is problematic since it creates certain ambiguities and some code stopped compiling with very obscure errors


#4

I was meaning glm::vec2 not glm::vec3 :wink: Anyway, the signature in the doc https://openframeworks.cc/documentation/graphics/ofPolyline/#show_curveTo says that curveTo it is supposed to accept ofVec2f, but it is not. We should fix the docs or the code.


#5

no, ofPolyline now accpets glm::vec3 so in order to accept ofVec2f it would need to auto convert to glm::vec3 which is problematic

and yes the docs shouldn’t say that anymore


#6

I see. Is it ok if I change the doc from:

void ofPolyline_::curveTo(const T &to, int curveResolution=20)

To:

void ofPolyline_::curveTo(const glm::vec3 &to, int curveResolution=20)

?


#7

that won’t make any difference since the default is already glm::vec3


#8

Yes, but from a user perspective, if curveTo is giving me an error, it is probably more helpful to find a documentation that tells me which type should the argument has, instead of the generic T. Isn’t it?