GLM vector have a static length function which returns the dimension of the vector type, so glm::vec2::length() returns 2, glm::vec3::length() returns 3.īecause C++ allows to call static methods on instances of that class you can make the error of calling: glm::vec3 v(2.f, 2.f, 2.f) The only exceptions to this rule are operators which you don't use directly but instead allow to do arithmetic operations so you can do things like: glm::vec3 v1(1.f, 1.f, 1.f) Instead glm uses functions to operate on those classes so if you want to for example normalize a vector you would do: glm::vec3 v(2.f, 2.f, 2.f) GLM classes like vectors, matrices or quaternions don't have methods. cpp files import the glm namespace at the very beginning: using namespace glm Īnd then use the classes and functions without prefix: vec3 v(2.f, 2.f, 2.f) GLM classes and functions are in the glm namespace so to use them you need to either prefix them with glm::: glm::vec3 v(2.f, 2.f, 2.f) OpenFrameworks, since version 0.10 uses GLM as it's default vector math library in the core and although old projects using ofVec* classes should work with minimal changes, if you are starting a new project we recomend to use GLM instead. makes things easier cause the syntax is almost the same across the different languages. It's syntax mimics that of glsl so working with it while working with OpenGL, shaders. OpenGL Mathematics GLM has become the defacto standard for graphics vector math in C++ in the latest years.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |