[osg-users] How to byte-align Vec4Array

Gordon Tomlinson gordon.tomlinson at sensor.com
Tue Jul 8 05:52:32 PDT 2008

As long as the compiler follows the C++ spec , stl vectors should be
contiguous memory
But note vec4 could be either a vec4f or vec4d so will only be 16 bytes if
it expands to vec4f


From: osg-users-bounces at lists.openscenegraph.org
[mailto:osg-users-bounces at lists.openscenegraph.org] On Behalf Of David
Sent: Tuesday, July 08, 2008 5:57 AM
To: OpenSceneGraph Users
Subject: [osg-users] How to byte-align Vec4Array

Dear All,

Is there an obvious way of aligning the contents of the Vec4Array to 16 byte
boundaries? Can I also guarantee that each std::vector entry will be
contiguous in memory? i.e. I would like to make sure that array[0].x(),
array[1].x() etc. are all on consecutive 16 byte boundaries.

(I'm using MS VC++ 9, so would natively use __declspec(align(16)) but am not
sure how to "get at" the vector).

If not, can I declare a big array of floats, that is aligned as per
requirements, and pass it into a geometry as a vertex array direclty,
bypassing use of Vec4Array (and Vec4 for that matter)?

I guess if neither of these works, then I'm down to subclassing Vec4Array...



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openscenegraph.org/pipermail/osg-users-openscenegraph.org/attachments/20080708/307c924e/attachment-0003.htm>

More information about the osg-users mailing list