[osg-users] How to byte-align Vec4Array

Thibault Genessay tibogens at gmail.com
Tue Jul 8 04:13:51 PDT 2008

Hi David

On Tue, Jul 8, 2008 at 11:57 AM, David Spilling
<david.spilling at gmail.com> wrote:
> Dear All,
> Can I also guarantee that each std::vector entry will be
> contiguous in memory?

Yes, provided that your compiler follows the C++ standard. See

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

Use &yourvector[0] to get a float* pointer to the beginning of the
array. I'd advocate against using a compiler-specific trick to do
something that is guaranteed by the C++ standard anyway.

Just keep in mind that each element of a Vec4 is 16 bytes long only if
you use floats, i.e. if Vec4 is typedef'ed to Vec4f and not Vec4d.



More information about the osg-users mailing list