   Is this correct?
vector<int> myVector;int size = 10;int oneMaskImage[64][64][4];int i,j,k,c;for(k = 0; k < size; k ++){for (i = 0; i < 64; i++) {for (j = 0; j < 64; j++) { c = rand()%256; oneMaskImage[j][0] =  c; oneMaskImage[j][1] =  c; oneMaskImage[j][2] =  c; oneMaskImage[j][3] =  255;}}   myVector.push_back(oneMaskImage);}The above is wrong. How would define 'myVector', so it would store the mask images? i.e. what type shall I use in vector<????> myVector   
  int[64][64][4]   ;  I'm pretty sure that vectors of arrays are illegal. I think a vector requires that the objects in the vector be copyable/assignable, which they are not.If you create a wrapper object around oneMaskImage and define an assignment operator and constructor that might work.Alternatively you could try a 4 dimensional vector:vector<vector<vector<vector<int>>>> allMyData;   ;  Solution 1 (preferable):Reorganize your data structures and don't rely on raw arrays. (I'm sure someone else will show an example.)Solution 2:oneMaskImage is an array of consecutive 64 * 64 * 4 int:s (which could be unsigned chars on most systems btw).To push it make into a vector you need to either flatten it (push each element separately), or you instead store pointers in the vectors to a memory block where you just copy sizeof(oneMaskImage) chars. Both are fairly inflexible and bug-probable solutions.   ;Quote:Original post by mylifemysoulvector<int> myVector;int size = 10;int oneMaskImage[64][64][4];int i,j,k,c;for(k = 0; k < size; k ++){for (i = 0; i < 64; i++) {for (j = 0; j < 64; j++) { c = rand()%256; oneMaskImage[j][0] =  c; oneMaskImage[j][1] =  c; oneMaskImage[j][2] =  c; oneMaskImage[j][3] =  255;}}   myVector.push_back(oneMaskImage);}The above is wrong. How would define 'myVector', so it would store the mask images? i.e. what type shall I use in vector<????> myVectorYou are attempting to store a multi-dimensional array in an integer.One solution is to have the vector store muli-dimensional arrays.  You can make the array a class/struct to accomplish this.However, your intent may be to store pointers to your arrays in your vector so you would change the vector's template parameter to an int pointer instead of an int.  Note - this would necessitate that you allocate your arrays dynamically otherwise the pointers your store would all point to the same memory allocation i.e. the same multi-dimensional array which is unlikely to be desirable.If you wrap the multi-dimensional array in a struct/class you can have the memory allocated for the array in a constructor and cleaned in a destructor cleanly avoiding having to do so explicitly yourself or necessitating the need for some sort of smart pointer.Hope this helps.   ;struct Color{Color(int r,int g,int b,int a):r(r),g(g),b(b),a(a){}int r,g,b,a;};vector<Color> myVector;int size = 10;int oneMaskImage[64][64][4];int i,j,k,c;for(k = 0; k < size; k ++){for (i = 0; i < 64; i++) {for (j = 0; j < 64; j++) { c = rand()%256; oneMaskImage[j][0] =  c; oneMaskImage[j][1] =  c; oneMaskImage[j][2] =  c; oneMaskImage[j][3] =  255;  Color newColor(oneMaskImage[j][0],oneMaskImage[j][1],oneMaskImage[j][2],oneMaskImage[j][3]);myVector.push_back(newColor);}}}You can access myVector as it was a 2d image by myVector[x + y * width]Edit: Oh by the way I don't know why you are doing this 10 times.   ;Quote:Original post by karwostsI'm pretty sure that vectors of arrays are illegal. I think a vector requires that the objects in the vector be copyable/assignable, which they are not.If you create a wrapper object around oneMaskImage and define an assignment operator and constructor that might work.Alternatively you could try a 4 dimensional vector:vector<vector<vector<vector<int>>>> allMyData;I've tried this. It's a pain in the ass. Maybe I did something wrong.The real problem is I want to define a vector of textures. Each texture is defined like oneMaskImage.If I only have 1 texture (I don't define the vector), the following code works fine.  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, oneMaskImage);But, I want to create the number of masks dynamically (from what user inputs). Therefore, I want to use a vector of 'oneMaskImage' to do this job.So if I do what you suggested like below:vector<vector<vector<vector<GLubyte>>>> myVector;Then here in the ??? place below what shall I use?  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, ????);I thought would be myVector[currentNumber]; but it always compiled wrong   ;Quote:Original post by mylifemysoulQuote:Original post by karwostsI'm pretty sure that vectors of arrays are illegal. I think a vector requires that the objects in the vector be copyable/assignable, which they are not.If you create a wrapper object around oneMaskImage and define an assignment operator and constructor that might work.Alternatively you could try a 4 dimensional vector:vector<vector<vector<vector<int>>>> allMyData;I've tried this. It's a pain in the ass. Maybe I did something wrong.The real problem is I want to define a vector of textures. Each texture is defined like oneMaskImage.If I only have 1 texture (I don't define the vector), the following code works fine.  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, oneMaskImage);But, I want to create the number of masks dynamically (from what user inputs). Therefore, I want to use a vector of 'oneMaskImage' to do this job.So if I do what you suggested like below:vector<vector<vector<vector<GLubyte>>>> myVector;Then here in the ??? place below what shall I use?  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, ????);I thought would be myVector[currentNumber]; but it always compiled wrongYou need to supply a pointer just as oneMaskImage is an alias for the address of the first element in your "texture".1)  Make your texture a struct/class2)  Place pointers/objects of the "texture" type in a vector (or any other suitable container)3)  supply myVector[index] to the gl function call; where the index will select the the proper pointer to the "texture" you want to use.  If your vector stores objects then of course use the address operator like so &myVector[index].Having a vector or vectors of vectors will cost you performance wise.  If you're feeling lucky you can just store int pointers in your array as I said before but you need to allocate/deallocate memory appropriately yourself as vectors only handle the construction and destruction of objects...not whether doing that actually mutates memory in any way.   ;  Thanks for all the replies.Quote:Original post by Black Knight *** Source Snippet Removed ***You can access myVector as it was a 2d image by myVector[x + y * width]Edit: Oh by the way I don't know why you are doing this 10 times.This is a nice example of wrapping stuff. But I still have a question like what I mentioned above.Actually, the oneMaskImage is an image. But myVector is an array of images.With only one 'oneMaskImage', the following is right: glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, oneMaskImage);How would I use the myVector in the glTexImage2D?for(int i = 0; i < size; i ++)glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, (some casting here???????) myVector);;Quote:Original post by SimulacrumQuote:Original post by mylifemysoulQuote:Original post by karwostsI'm pretty sure that vectors of arrays are illegal. I think a vector requires that the objects in the vector be copyable/assignable, which they are not.If you create a wrapper object around oneMaskImage and define an assignment operator and constructor that might work.Alternatively you could try a 4 dimensional vector:vector<vector<vector<vector<int>>>> allMyData;I've tried this. It's a pain in the ass. Maybe I did something wrong.The real problem is I want to define a vector of textures. Each texture is defined like oneMaskImage.If I only have 1 texture (I don't define the vector), the following code works fine.  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, oneMaskImage);But, I want to create the number of masks dynamically (from what user inputs). Therefore, I want to use a vector of 'oneMaskImage' to do this job.So if I do what you suggested like below:vector<vector<vector<vector<GLubyte>>>> myVector;Then here in the ??? place below what shall I use?  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, WIDTH, HEIGHT, 0, GL_RGBA, GL_UNSIGNED_BYTE, ????);I thought would be myVector[currentNumber]; but it always compiled wrongYou need to supply a pointer just as oneMaskImage is an alias for the address of the first element in your "texture".1)  Make your texture a struct/class2)  Place pointers/objects of the "texture" type in a vector (or any other suitable container)3)  supply myVector[index] to the gl function call; where the index will select the the proper pointer to the "texture" you want to use.  If your vector stores objects then of course use the address operator like so &myVector[index].Having a vector or vectors of vectors will cost you performance wise.  If you're feeling lucky you can just store int pointers in your array as I said before but you need to allocate/deallocate memory appropriately yourself as vectors only handle the construction and destruction of objects...not whether doing that actually mutates memory in any way.Thanks for the reply.Like in the 'Black Knight' 's reply. He gave a good example of wrapping the colour in the structure.But then the myVector[index] will return a value a that struture, rather than the GLubyte[64][64][4]. I suddenly get confused? How do I convert the struct type to the [][][] array type?