keronprint.blogg.se

Glm permute vector swizzle
Glm permute vector swizzle











class _swizzle : public _swizzle_base2 _swizzle Provided is to access the attributes after swizzle according to the index, pay attention to the difference and the difference between _swizzle_base0::elem.Ĥ. In other words, when vec3.zy = vec2(2,1), _swizzle_base2::operator=(vecType const&) is actually called The above method provides the set attribute, _swizzle_base2::operator/=(vecType const& ) _swizzle_base2::operator*=(vecType const& ) _swizzle_base2::operator-=(vecType const& ) _swizzle_base2::operator+=(vecType const& ) _swizzle_base2::operator=(vecType const& ) When DUPLICATE_ELEMENTS is 0, that is, there are no identical elements and set attributes. _swizzle_base2 specializes with DUPLICATE_ELEMENTS(0,1) In fact, when the attributes of swizzle have the same elem, there is only the get attribute, because the behavior of vec3.yxy = (1,2,3) is uncertain when it is assigned.

glm permute vector swizzle

class _swizzle_base2 : public _swizzle_base1 _swizzle_base2ĭUPLICATE_ELEMENTS: This parameter refers to whether the attributes of swizzle are the same, such as: vec3.yxy That is to say, when we use vec2 v2 = v3.xz, we actually call _swizzle_base1::operator()() to construct a vec2.Īccording to N being 2, 3 to construct a VecType of 2 elem or 3 elem swizzle.ģ. _swizzle_base1 is specialized with the number of N, mainly to provide the get attribute for the swizzle attribute. class _swizzle_base1 : public _swizzle_base0 _swizzle_base1Į0, E1, E2: the index of each elem of Swizzle

glm permute vector swizzle

class _swizzle_base0 _swizzle_base0, as the bottom class of swizzle, only provides the elem interface, and uses i to get the i-th element.Ģ.

  • Use macros to turn attributes into methods.
  • For example, we cannot use attributes like xz (interval) and zy (reverse order).
  • Using the characteristics of union can make multiple "names" use the same memory area, but the above method does not achieve the Swizzle we want very well.
  • We may be able to think of using uion+struct to achieve.
  • Glm permute vector swizzle how to#

    We can easily write a vec class with two or three attributes in C++, but how to make vec also support the above syntax to mix attributes?.When writing gl shader, I found that vec in the syntax of glsl can support arbitrary mixed attributes like the following syntax.











    Glm permute vector swizzle