Bonjour,

Je suis a me familiariser avec GLM, l'OpenGL Mathematics library, mais n'etant pas encore un expert en C++, je rencontre un probleme que je ne comprend pas.

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
#define GLM_SWIZZLE GLM_SWIZZLE_FULL
#include "glm/glm.h"
using namespace glm;

int main(int argc, char **argv)
{
	vec3 testVec = vec3(3.,35.,4.);
	vec3 testVec2 = vec3(13.,15.,14.);
	testVec = testVec2.zyx;
	testVec = testVec2.xyy;
}
Dans le code precedent, ca fonctionne comme je veux, mais la ligne en rouge ne compile pas. En fait, j'ai l'impression que chaque fois que j'utilise un swizzle avec 2 fois la meme composante (.xyy, .yyz, .xxx, etc.) ca ne compile plus.

J'obtient alors les erreurs suivantes dans visual studio:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
 
glm\core\_cvec3.inl(269) : error C2664: 'glm::_xvec3<T>::_xvec3(const glm::_xvec3<T> &)' : cannot convert parameter 1 from 'glm::_cvec3<T,VEC2,VEC3,VEC4,REF2,REF3>' to 'const glm::_xvec3<T> &'
        with
        [
            T=int
        ]
        Reason: cannot convert from 'glm::_cvec3<T,VEC2,VEC3,VEC4,REF2,REF3>' to 'const glm::_xvec3<T>'
        with
        [
            T=int,
            VEC2=glm::_xvec2<int>,
            VEC3=glm::_xvec3<int>,
            VEC4=glm::_xvec4<int>,
            REF2=glm::_xref2<int>,
            REF3=glm::_xref3<int>
        ]
        and
        [
            T=int
        ]
        No user-defined-conversion operator available that can perform this conversion, or the operator cannot be called
        glm\core\_cvec3.inl(268) : while compiling class template member function 'const glm::_xvec3<T> glm::_cvec3<T,VEC2,VEC3,VEC4,REF2,REF3>::_xyy(void) const'
        with
        [
            T=int,
            VEC2=glm::_xvec2<int>,
            VEC3=glm::_xvec3<int>,
            VEC4=glm::_xvec4<int>,
            REF2=glm::_xref2<int>,
            REF3=glm::_xref3<int>
        ]
        glm\core\_xvec3.h(24) : see reference to class template instantiation 'glm::_cvec3<T,VEC2,VEC3,VEC4,REF2,REF3>' being compiled
        with
        [
            T=int,
            VEC2=glm::_xvec2<int>,
            VEC3=glm::_xvec3<int>,
            VEC4=glm::_xvec4<int>,
            REF2=glm::_xref2<int>,
            REF3=glm::_xref3<int>
        ]
        test.cpp(608) : see reference to class template instantiation 'glm::_xvec3<T>' being compiled
        with
        [
            T=int
        ]
C'est sans doute tout bete, mais les idees seraient appreciees.

N.B. GLM peut etre trouve ici : http://glm.g-truc.net/