12 #ifndef GLVIS_ATTR_TRAITS_HPP
13 #define GLVIS_ATTR_TRAITS_HPP
17 #include <type_traits>
33 typename TV,
typename TAttr, TAttr TV::*Attrib,
typename TAttrInfo>
37 std::is_integral<typename TAttr::value_type>::value;
41 return &(((TV*)0)->*Attrib);
47 glEnableVertexAttribArray(TAttrInfo::ShaderIdx);
48 glVertexAttribPointer(TAttrInfo::ShaderIdx,
49 std::tuple_size<TAttr>::value,
50 TAttrInfo::AttrGLType,
59 glEnableClientState(TAttrInfo::FFArrayIdx);
60 TAttrInfo::FFSetupFunc(std::tuple_size<TAttr>::value,
61 TAttrInfo::AttrGLType,
69 glDisableVertexAttribArray(TAttrInfo::ShaderIdx);
75 glDisableClientState(TAttrInfo::FFArrayIdx);
83 template<
typename TV,
typename =
int>
86 template<
typename TV,
typename =
int>
89 template<
typename TV,
typename =
int>
92 template<
typename TV,
typename =
int>
107 template<
typename TV>
109 :
AttrBase<TV, decltype(TV::coord), &TV::coord,
110 AttrCoord<TV, decltype((void)TV::coord, 0)>>
112 const static GLenum AttrGLType = GL_FLOAT;
114 const static GLenum FFArrayIdx = GL_VERTEX_ARRAY;
115 constexpr
static auto FFSetupFunc = glVertexPointer;
118 template<
typename TV>
120 :
AttrBase<TV, decltype(TV::norm), &TV::norm,
121 AttrNormal<TV, decltype((void)TV::norm, 0)>>
123 const static GLenum AttrGLType = GL_FLOAT;
125 const static GLenum FFArrayIdx = GL_NORMAL_ARRAY;
129 glNormalPointer(type, stride, ptr);
133 template<
typename TV>
135 :
AttrBase<TV, decltype(TV::color), &TV::color,
136 AttrColor<TV, decltype((void)TV::color, 0)>>
138 const static GLenum AttrGLType = GL_UNSIGNED_BYTE;
140 const static GLenum FFArrayIdx = GL_COLOR_ARRAY;
141 constexpr
static auto FFSetupFunc = glColorPointer;
144 template<
typename TV>
146 :
AttrBase<TV, decltype(TV::texCoord), &TV::texCoord,
147 AttrTexcoord<TV, decltype((void)TV::texCoord, 0)>>
149 const static GLenum AttrGLType = GL_FLOAT;
151 const static GLenum FFArrayIdx = GL_TEXTURE_COORD_ARRAY;
152 constexpr
static auto FFSetupFunc = glTexCoordPointer;
static void clearLegacy()
static void setupLegacy(void *)
static void clearLegacy()
static constexpr bool NormalizeAttr
static constexpr TAttr * getAttrOffset()
static void FFSetupFunc(GLint, GLenum type, GLsizei stride, const GLvoid *ptr)
static void setupLegacy(TV *buffer)