openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.85k stars 2.56k forks source link

Small issue using GLM 1.0 or more recent #7910

Open dimitre opened 4 months ago

dimitre commented 4 months ago

Updating a project here I've noticed newer GLM versions got some problems when using an unitialized mat4, like:

    glm::mat4 view;

and worked ok after I've updated to

    glm::mat4 view { 1.0 };

I'm not sure if this will be corrected there in more recent versions, but I'm wondering if we should inspect the core to find some unitialized glm::mat4 and update them, like in ofShadow, ofMatrixStack and ofxAssimpMeshHelper.

PS: It seems #define GLM_FORCE_CTOR_INIT is used correctly in all OF Core.

2bbb commented 4 months ago

maybe, you need to add suffix of float? i.e. glm::mat4 view{1.0f};

2bbb commented 4 months ago

cf. https://subscription.packtpub.com/book/programming/9781786465184/1/ch01lvl1sec7/understanding-uniform-initialization

artificiel commented 4 months ago

@dimitre is #define GLM_FORCE_CTOR_INIT also present in the file where you use the glm::mat4?

because if it's for instance in an autonomous class (that does not import ofMain.h or something) there is no guarantee that the define is "picked-up" prior to your file.

it would be a good occasion to leave uninitialized and try adding a preprocessor define (#6530) and see if it fixes the problem. it creates an additional detail to compile OF, but since most/all people start with a template it's probably not a trouble — and it would be much cleaner than putting #define GLM_FORCE_CTOR_INIT all over the source.

2bbb commented 4 months ago

@dimitre

sorry, previous my pointing out is my misunderstand. glm::mat4 view{1.0} is no problem. 😉