Okay, I wrote this reply before seeing you'd solved the problem, but I'll post it anyways in case you or someone else hits a similar issue in the future.
Quote:
|
Originally Posted by coder0xff
Scalar is a typedef for double. There are several other members (data and code) I examined this class at runtime and discovered that the doubles are not packed tightly in memory, ie: &x+sizeof(Scalar) != &y. This expression evaluates to true. Is there a way I can ensure they are adjacent in memory? I want to be able to use the data in calls to OpenGL array routines, but would rather avoid converting each Vector to a struct PackedVert3{Scalar x,y,x;}
|
Structure/class packing is generally done to provide for the fastest memory access of the members. If you will be using your own methods most of the time, and only calling OpenGL functions at the end of a cycle, then a possible approach would be to leave the packing as is, but construct a pack() method to return an instance (or reference to) such a packed structure. To me, this seems a reasonable compromise, but given that I've never worked with OpenGL, it might not be an appropriate solution.