[osg-users] FloatArray usage in UniformBuffer example

P. Que porqueosg at protonmail.com
Mon Nov 18 00:17:37 PST 2019


Hi, I'm trying to learn how to use uniform buffers in OSG. Looking at https://github.com/openscenegraph/OpenSceneGraph/blob/master/examples/osguniformbuffer/osguniformbuffer.cpp#L156, it seems to use the `FloatArray` type for cpu-side memory storage of the data, and `theFloatArray->setBufferObject(ubo.get());` to associate that data with the UBO (for later uploading via UniformBufferBinding).

If this understanding is correct, I'm rather surprised the cpu-side storage of the data has a custom type - an api more like `ubo->setBuffer(&theFloatArray, theFloatArraySize)` would allow arbitrary cpu-side storage of data, within a `std::vector`, for example.

What is the significance of the `FloatArray->setBufferObject(bufferObject)` API, and is it required for using Uniform Buffers?
Thank you.
-P. Que
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20191118/11428ce6/attachment.html>


More information about the osg-users mailing list