How do I print vector values of type glm::vec3 that have been passed by reference?

前端 未结 5 1616
星月不相逢
星月不相逢 2020-12-25 10:12

I have a small obj loader and it takes two parameters and passes them back to the input variables.. however this is my first time doing this and i\'m not sure how to print s

5条回答
  •  野趣味
    野趣味 (楼主)
    2020-12-25 10:24

    I think the most elegant solution might be a combination of the two answers already posted, with the addition of templating so you don't have to reimplement the operator for all vector/matrix types (this restricts the function definition to header files, though).

    #include 
    
    template
    std::ostream& operator<<(std::ostream& out, const genType& g)
    {
        return out << glm::to_string(g);
    }
    

提交回复
热议问题