31 bool allowDynamicUpdate);
33 DFType GetFormat()
const;
47 inline void SetLayout(std::vector<MemberLayout>
const& layout);
48 inline std::vector<MemberLayout>
const& GetLayout()
const;
58 bool GetMember(
std::string const& name, T& value)
const;
66 bool GetMember(
std::string const& name,
unsigned int index,
75 static int const shaderDataLookup = 1;
92 auto iter = std::find_if(mLayout.begin(), mLayout.end(),
95 if (iter == mLayout.end())
97 LogError(
"Failed to find member name " + name +
".");
101 if (iter->numElements > 0)
103 LogError(
"Member is an array, use SetMember(name,index,value).");
107 if (iter->offset +
sizeof(T) > mNumBytes)
109 LogError(
"Writing will access memory outside the buffer.");
113 T*
target =
reinterpret_cast<T*
>(mData + iter->offset);
118 template <
typename T>
121 auto iter = std::find_if(mLayout.begin(), mLayout.end(),
124 if (iter == mLayout.end())
126 LogError(
"Failed to find member name " + name +
".");
130 if (iter->numElements > 0)
132 LogError(
"Member is an array, use GetMember(name,index,value).");
136 if (iter->offset +
sizeof(T) > mNumBytes)
138 LogError(
"Reading will access memory outside the buffer.");
142 T*
target =
reinterpret_cast<T*
>(mData + iter->offset);
147 template <
typename T>
151 auto iter = std::find_if(mLayout.begin(), mLayout.end(),
154 if (iter == mLayout.end())
156 LogError(
"Failed to find member name " + name +
".");
160 if (iter->numElements == 0)
162 LogError(
"Member is a singleton, use SetMember(name,value).");
166 if (index >= iter->numElements)
168 LogError(
"Index is out of range for the member array.");
172 if (iter->offset + (index + 1)*
sizeof(T) > mNumBytes)
174 LogError(
"Writing will access memory outside the buffer.");
178 T*
target =
reinterpret_cast<T*
>(mData + iter->offset + index*
sizeof(T));
183 template <
typename T>
187 auto iter = std::find_if(mLayout.begin(), mLayout.end(),
190 if (iter == mLayout.end())
192 LogError(
"Failed to find member name " + name +
".");
196 if (iter->numElements == 0)
198 LogError(
"Member is a singleton, use GetMember(name,value).");
202 if (index >= iter->numElements)
204 LogError(
"Index is out of range for the member array.");
208 if (iter->offset + (index + 1)*
sizeof(T) > mNumBytes)
210 LogError(
"Reading will access memory outside the buffer.");
214 T*
target =
reinterpret_cast<T*
>(mData + iter->offset + index*
sizeof(T));
std::vector< MemberLayout > const & GetLayout() const
GLsizei const GLfloat * value
GLuint const GLchar * name
GLsizei const GLchar *const * string
#define LogError(message)
bool SetMember(std::string const &name, T const &value)
std::vector< MemberLayout > mLayout
GLint GLint GLsizei GLint GLenum format
void SetLayout(std::vector< MemberLayout > const &layout)
bool GetMember(std::string const &name, T &value) const