36 inline void SetLayout(std::vector<MemberLayout>
const& layout);
37 inline std::vector<MemberLayout>
const& GetLayout()
const;
47 bool GetMember(
std::string const& name, T& value)
const;
55 bool GetMember(
std::string const& name,
unsigned int index,
63 static size_t GetRoundedNumBytes(
size_t numBytes);
69 static int const shaderDataLookup = 0;
86 auto iter = std::find_if(mLayout.begin(), mLayout.end(),
89 if (iter == mLayout.end())
91 LogError(
"Failed to find member name " + name +
".");
95 if (iter->numElements > 0)
97 LogError(
"Member is an array, use SetMember(name,index,value).");
101 if (iter->offset +
sizeof(T) > mNumBytes)
103 LogError(
"Writing will access memory outside the buffer.");
107 T*
target =
reinterpret_cast<T*
>(mData + iter->offset);
112 template <
typename T>
115 auto iter = std::find_if(mLayout.begin(), mLayout.end(),
118 if (iter == mLayout.end())
120 LogError(
"Failed to find member name " + name +
".");
124 if (iter->numElements > 0)
126 LogError(
"Member is an array, use GetMember(name,index,value).");
130 if (iter->offset +
sizeof(T) > mNumBytes)
132 LogError(
"Reading will access memory outside the buffer.");
136 T*
target =
reinterpret_cast<T*
>(mData + iter->offset);
141 template <
typename T>
145 auto iter = std::find_if(mLayout.begin(), mLayout.end(),
148 if (iter == mLayout.end())
150 LogError(
"Failed to find member name " + name +
".");
154 if (iter->numElements == 0)
156 LogError(
"Member is a singleton, use SetMember(name,value).");
160 if (index >= iter->numElements)
162 LogError(
"Index is out of range for the member array.");
166 if (iter->offset + (index + 1)*
sizeof(T) > mNumBytes)
168 LogError(
"Writing will access memory outside the buffer.");
172 T*
target =
reinterpret_cast<T*
>(mData + iter->offset + index*
sizeof(T));
177 template <
typename T>
181 auto iter = std::find_if(mLayout.begin(), mLayout.end(),
184 if (iter == mLayout.end())
186 LogError(
"Failed to find member name " + name +
".");
190 if (iter->numElements == 0)
192 LogError(
"Member is a singleton, use GetMember(name,value).");
196 if (index >= iter->numElements)
198 LogError(
"Index is out of range for the member array.");
202 if (iter->offset + (index + 1)*
sizeof(T) > mNumBytes)
204 LogError(
"Reading will access memory outside the buffer.");
208 T*
target =
reinterpret_cast<T*
>(mData + iter->offset + index*
sizeof(T));
bool SetMember(std::string const &name, T const &value)
GLsizei const GLfloat * value
void SetLayout(std::vector< MemberLayout > const &layout)
GLuint const GLchar * name
GLsizei const GLchar *const * string
#define LogError(message)
std::vector< MemberLayout > const & GetLayout() const
bool GetMember(std::string const &name, T &value) const
std::vector< MemberLayout > mLayout