Simple question. What is the best way to turn a CGPoint into a GLKVector?
These structures are identical so it would be nice to be able to reinterpret_cast or memcpy or something like that. My solution below works but hardly seems optimum. I’m creating a GLKVector2 on the stack assigning each member then returning this as a value which is then assigned to another GLKVector.
It’s not going to break the bank or anything but there must be a neater way to do this?
GLKVector2 Vector2FromPoint(CGPoint point)
{
GLKVector2 v;
v.x = point.x;
v.y = point.y;
return v;
}
You could try using memcpy in a function like this:
but then it is probably better to have:
if you really want optimization, you could go for a macro:
so you can do:
of course, as you know, macros will not be that much type-safe…