Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Passing data to WebGL uniform* APIs
uniform* APIs and, more in general, WebGL APIs which expects buffer requires typed arrays of a suitable type.
If you have data stored in a C/C++ array or
std::vector or any other continguos memory storage, you can use the
cheerp::MakeTypedArray to convert the data into a JS typed array object. Please note that the conversion happens without copying, so it's very efficient.
Please note that arrays of arrays (multidimensional arrays) are not necessarily contiguos in memory when using Cheerp, so you can't do this
float matrix; webgl->uniform4fv(location, cheerp::MakeTypedArray(&matrix));
On the other hand, the following code will work
float matrix; webgl->uniform4fv(location, cheerp::MakeTypedArray(matrix));