I have a class that goes like this:
class myType
{
union {
float data[4];
other_vector4_type v
} ;
typedef union {
float data[4];
other_vector4_type v
} myType-internal_t;
<various member functions, operator overloads>
}
Now I want to use this type in my vertex buffer, but the sizeof()
isn't as expected. I aligned the class to 16 bytes.
sizeof(myType)
yields 64.
sizeof(myType::myType-internal_t)
yields 32.
I've read quite a few articles on data alignment but I don't know where I'm using extra data. I tried stripping out the custom constructor but it remains the same, swapping the class keyword for struct
doesn't change it either (I don't understand what it's for, as it happens!)
This is annoying, I'll use the internal type for now since I won't be touching the data often, but it would be great to have the class work like I want.