Since my answer is also yes, I will follow the K-ballo answer with a minimal example of using a flat array to store a multidimensional data set:
Save the GLfloat pointer and sizes as members of your class:
GLfloat *tgrid; int nx, ny, nz;
In the initialization function:
void CreateGrid(int x, int y, int z) { nx = x; ny = y; nz = z; tgrid = new GLfloat[nx*ny*nz]; }
You will need to define your indexing scheme for proper read-write:
GLfloat GetValueAt(int x, int y, int z) { return tgrid[ (nx*ny*z) + (nx*y) + x ]; } void SetValueAt(int x, int y, int z, GLfloat value) { tgrid[ (nx*ny*z) + (nx*y) + x ] = value; }
Deletion happens directly, since tgrid is just a flat array.
source share