Suppose I have an array variable in a shader, declared in a shader storage block:
layout(std430, binding = 2) buffer MyBuffer
{
float lotsOfFloats[];
};
and a struct:
struct myStruct
{
float f1;
vec3 vf1;
}struct1;
Is there a way to “quickly” initialize an object of this structure in a shader using the values in the array in a buffer storage block ( in the lotsOfFloats array in this example)? Say, in C++ one can copy memory from the array to the object:
memcpy(&struct1, &lotsOfFloats[0], sizeof(myStruct) );
Or one can byte copy array values to the object through assignment:
struct1 = *(myStruct*)&lotsOfFloats[0];
Is there a similar way in GLSL? E.g. will work the second way (byte copy assignment) in GLSL?