I'm working on a flow visualization task where I need to analyze the data in some way. The visualization iswritten by someone else and expects a vector of GLFloat containing the data. However, I would much prefer to have a class structure like below. Is there any way to achieve this without copying the data (like a union)?
struct Vertex
{
math::vec3 pos;
float time;
float velocity;
};
class Pathline
{
std::vector<Vertex> points;
};
//these have the same data
std::vector<Pathline> lines;
std::vector<GLfloat> lineData;
Thanks
From your example, several issues come to my mind:
Probably you could reword your structure to something like:
struct Vertex
{
GLfloat[3] pos;
GLfloat time;
GLFloat velocity;
};
std::vector<Vertex> lineVertexData;
std::vector<GLfloat> lineData;
And if you have additional external data to define the pathlines, you could go one step further.
All depends on how far you want to do"philosophically correct" C++ code. Some times difficult to achieve with OpenGL.
As soon as your 2 structures are equivalent, you may cast your pointer/reference between. But this equivalence is not quite easy.
Answering your question:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.