Original Post
Hi,
I have allocated a 1D array to store and access like a 4D array because I need to use this array as a 3D texture that is of the RGBA format. so i need something like tex[x][y][z][4]. i have allocated like this:
char *tex = calloc(x*y*z*4, sizeof(char));
now, when i access this array from a 4 level for loop i have been doing:
tex[i + j*x + k*x*y + l*x*y*z]
however, this is not packed correctly. what am i doing wrong? and how should i access this texture to properly store the RGBA values for this 3D texture using this 1D array. Thanks.