danomatika / swig-openframeworks

a SWIG interface for openFrameworks with included Makefile, submodule this in your language wrapper addons
Other
39 stars 11 forks source link

glm issues #18

Closed sphaero closed 3 years ago

sphaero commented 5 years ago

using SWIG Version 3.0.12 and the latest OF from git master I'm running into issues generating the glm binding:

First of all there are some wrong references, I fixed it as follows (notice the m1 and m):

diff --git a/glm/mat3.i b/glm/mat3.i
index cfff444..f4c0cb4 100644
--- a/glm/mat3.i
+++ b/glm/mat3.i
@@ -104,5 +104,5 @@ bool operator!=(mat3 const & m1, mat3 const & m2);
     mat3 operator/(mat3 const & m) {return (*$self) / m;}
     vec3 operator/(vec3 const & v) {return (*$self) / v;}
     bool operator==(mat3 const & m) {return (*$self) == m;}
-    bool operator!=(mat3 const & m1) {return (*$self) != m;}
+    bool operator!=(mat3 const & m) {return (*$self) != m;}
 };
diff --git a/glm/mat4.i b/glm/mat4.i
index 47133fe..210beb7 100644
--- a/glm/mat4.i
+++ b/glm/mat4.i
@@ -105,5 +105,5 @@ bool operator!=(mat4 const & m1, mat4 const & m2);
     mat4 operator/(mat4 const & m) {return (*$self) / m;}
     vec4 operator/(vec4 const & v) {return (*$self) / v;}
     bool operator==(mat4 const & m) {return (*$self) == m;}
-    bool operator!=(mat4 const & m1) {return (*$self) != m;}
+    bool operator!=(mat4 const & m) {return (*$self) != m;}
 };

But then compiling it I get:

/home/arnaud/src/ofPython/src/glmBindings.cpp:4921: error: call of overloaded ‘operator%(float&, const vec3&)’ is ambiguous
    arg2 = reinterpret_cast< glm::vec3 * >(argp2); result = glm::operator %(arg1,(glm::vec3 const &)*arg2);
/home/arnaud/src/openframeworks/libs/glm/include/glm/detail/type_vec2.inl:657: error: invalid operands of types ‘const float’ and ‘const float’ to binary ‘operator%’
    v1.x % v2.x,
    ~~~~~^~~~~~
/home/arnaud/src/openframeworks/libs/glm/include/glm/detail/type_vec2.inl:658: error: invalid operands of types ‘const float’ and ‘const float’ to binary ‘operator%’
    v1.y % v2.y);
    ~~~~~^~~~~~
/home/arnaud/src/openframeworks/libs/glm/include/glm/detail/type_vec2.inl:625: error: invalid operands of types ‘const float’ and ‘float’ to binary ‘operator%’
    v.x % scalar,
    ~~~~^~~~~~~~

The list goes on

sphaero commented 5 years ago

btw, it runs if I just comment out the % operator defines in the interface files and rebuild.

testing this on Python 3.6.7 btw

danomatika commented 5 years ago

Not all scripting languages support the same operators as C++, so you usually have to ignore or wrapp certain things. This appears to be one of them. It could be wrapped with a new "mod()" function for Python using the SWIG language specific defines.

danomatika commented 5 years ago

Another note: as stated in the readme, the current master of this repo stays in sync with the current openFrameworks release. I find it far too time-consuming chasing daily changes from the git master as I don't often OF right now.

danomatika commented 3 years ago

Is this still an issue?

sphaero commented 3 years ago

I don't know I haven't been exploring this further. Close it if you want

danomatika commented 3 years ago

Closing for now.