View Single Post
Old Jun 2nd, 2006, 12:12 PM   #1
coder0xff
Unverified User
 
coder0xff's Avatar
 
Join Date: Mar 2006
Posts: 18
Rep Power: 0 coder0xff is on a distinguished road
Adjacent data members

I have a class Vector. The first members I have typed into the class:

Scalar x;
Scalar y;
Scalar z;

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;}
__________________
Brent

Two things are infinite: the universe and human stupidity; and Im not sure about the universe. -- Albert Einstein

Last edited by coder0xff; Jun 2nd, 2006 at 12:22 PM.
coder0xff is offline   Reply With Quote