I have floats in a context
float* floats = calloc(3, sizeof(float));
float& x = floats[0];
float& y = floats[1];
float& z = floats[2];
How do I assign them to a glm::vec3
such that I can perform operations on them? Is it really a matter of:
glm::vec3 vertex = { x, y, z };
// Transform and Rotate vertex
X = vertex.x;
y = vertex.y;
z = vertex.z;
Or is there a way I can bind the values to the vec3
Casting to a vec3
worked as expected, with the underlying floats changing when I changed the vec3
values.
vec3& vertex = (*reinterpret_cast<vec3*>(floats));
vertex.x = 1;
assert(floats[0] == vertex.x);