[of-dev] glm

arturo castro arturo at openframeworks.cc
Mon Mar 28 14:59:54 PDT 2016

yeah that works and it's already done like that.

the problem is with ofVec containers, ofMesh and ofPolyline which have
some methods that return a vector<ofVec3f>. you can't just cast those or
even make an automatic copy so i've templated ofMesh and ofPolyline.

the macro in ofConstants defines the default types for ofMesh and
ofPolyline as ofVec3f or glm::vec3.

but then some classes in the core will use ofMesh and ofPolyline and we
would need to template those too if we wanted to be able to define this
from user code which would make compiling pretty slow i think

On 28.03.2016 23:39, Lukasz Karluk wrote:
> what if the conversion is done in a header file which is linked to the
> project. then a project macro should be able to switch OF vec to glm vec.
> if glm is being used everywhere internally then the conversions should
> only be happening within the OF api layer, in the header files no?
> --   
> *Lukasz Karluk*
> On 29 Mar 2016, at 5:14 AM, arturo castro <arturo at openframeworks.cc
> <mailto:arturo at openframeworks.cc>> wrote:
>> no, i don't think there's any way to do that cause those classes are
>> also used in the core so the core needs to be recompiled and use the
>> same setting as the project if that setting changes.
>> the only solution i think would be to have anything that uses those
>> classes also templated but it seems to much
>> but the idea is that that would be changed by users just that you would
>> change it for all your projects instead of for per project.
>> also even if you have that setting set to glm most things will still
>> work, it's mostly things like:
>> vector<ofVec3f> vec = mesh.getVertices()
>> or anything that returns a vector of vec that would need to be fixed
>> when using glm as the default.
>> On 28.03.2016 19:59, Elliot Woods wrote:
>>> Is it possible to switch on a project macro
>>> rather than necessarily needing to edit the ofConstants.h?
>>> (users can have the option on how they make the switch themselves)
>>> -- 
>>> -- 
>>> Elliot Woods
>>> elliot <mailto:elliot at kimchiandchips.com>@KimchiAndChips.com
>>> <http://kimchiandchips.com>
>>> <http://www.kimchiandchips.com/>
>>> UK : +447944977628
>>> KR : +821034458086
>>> On 29 March 2016 at 02:56:56, arturo castro (arturo at openframeworks.cc
>>> <mailto:arturo at openframeworks.cc>
>>> <mailto:arturo at openframeworks.cc>) wrote:
>>>> On 28.03.2016 19:39, Elliot Woods wrote:
>>>>> (Maybe that's what's on the table already?)
>>>> :) yeah that's more or less what's in there now, it even has a macro in
>>>> ofConstants that switches the only 2 vec containers in the core from
>>>> using glm <-> ofVec so old projects should work right away and there
>>>> shouldn't be any copies even for vectors.
>>>> the only case that won't compile in old projects is something like:
>>>> camera.getPosition().length()
>>>> which would need to be changed to one of:
>>>> ofVec3f pos = camera.getPosition();
>>>> pos.length()
>>>> or
>>>> glm::length(camera.getPosition());
>>>> And yes totally agree that the main reason for changing to glm is that
>>>> the current classes are super inconsistent, didn't knew that there were
>>>> issues with inversions ... but if there are more reason to switch, this
>>>> is the kind of code that we really don't want to maintain.
>>>> Also I've just spoke with theo and he seems to be ok with switching to
>>>> the current implementation if we keep the "legacy" mode as the default
>>>> by now and all the examples still using ofVec. additionally we could
>>>> enable glm by default while it's in master and then switch to legacy for
>>>> the release
>>>> again, switching from legacy to glm is only a matter of changing a macro
>>>> in ofConstants and only involves the return types of ofMesh/ofPolyline,
>>>> the vector math internally and the return types for everything else
>>>> would still be glm which auto converts from/to ofVec
>>>> _______________________________________________
>>>> of-dev mailing list
>>>> of-dev at dev.openframeworks.cc <mailto:of-dev at dev.openframeworks.cc>
>>>> http://dev.openframeworks.cc/listinfo.cgi/of-dev-openframeworks.cc
>> _______________________________________________
>> of-dev mailing list
>> of-dev at dev.openframeworks.cc <mailto:of-dev at dev.openframeworks.cc>
>> http://dev.openframeworks.cc/listinfo.cgi/of-dev-openframeworks.cc
> _______________________________________________
> of-dev mailing list
> of-dev at dev.openframeworks.cc
> http://dev.openframeworks.cc/listinfo.cgi/of-dev-openframeworks.cc

More information about the of-dev mailing list