ofPolyline.getVertices() not working

Hi could you help me with a question ?

why this code is not  working 
 vector <ofVec3f> vertices = polyline.getVertices(); 
but this one works :
vector<glm::vec3>vertices = polyline.getVertices();

this is the output error :

**/home/chrysl666/Documents/of_v20191229_linux64gcc6_release/apps/myApps/Polylines/src/ofApp.cpp:42: error: conversion from ‘std::vector<glm::vec<3, float, (glm::qualifier)0>, std::allocator<glm::vec<3, float, (glm::qualifier)0> > >’ to non-scalar type ‘std::vector<ofVec3f>’ requested**
**         vector<ofVec3f>vertices = polyline.getVertices();**
**                                   ~~~~~~~~~~~~~~~~~~~~^~**

I suppose ofVec3f should support glm::vec3 .. but is not making the proper casting

I am following the ofBook exercises

Maybe this one it’s of some help?

A quick solution is:

auto vertices = polyline.getVertices(); 

vertices will be a vector <glm::vec3> but using auto allows you to get whatever the function returns without having to check the type.

ofVec3f converts back and forth to glm::vec3 but vector containers can’t auto convert between two different types. So any code which returns a vector glm::vec3 can’t be converted to vector unfortunately. The link @Bencilari posts explains it a bit more.

Tnx . @Bencilari and @theo , helps a lot !
little annoying to following the ofbook using this glm adaptation :confused: but`s ok !

1 Like