i facing a problem when i try to access to an array of array with a pointer, i have several arrays declared as following :
BYTE a[5] = {0xcc,0xaa,0xbb,0xcc,0xff};
BYTE b[3] = {0xaa,0xbb,0xff};
thos BYTE arrays represents image that i want to load in memory from a dll, i can access them separately with no difficulty, but i want to access them from a loop with a pointer ...
i tried to put them into an array of array like this :
BYTE* c[2] = {a,b};
but when i want to loop through this pointer c[i] doesent load image at i index into memory, how could i fix it?
im trying to draw images with this method within a loop to avoid repating lines ( consider c is images[i])
void MenuIcon::drawIcons(LPDIRECT3DDEVICE9 npDevice)
{
isMenuVisible = (Pos.x < 100) && (Pos.x > 0)? true : false;
if(isMenuVisible)
for (int i = 0; i < 2; i++)
{
if (icon[i].img == NULL)D3DXCreateTextureFromFileInMemory(npDevice, &images[i], sizeof(images[i]), &icon[i].img);
DrawTexture(icon[i].coord.x, icon[i].coord.y, icon[i].img);
}
}
i try to use my method like this after reading your answer :
void MenuIcon::drawIcons(LPDIRECT3DDEVICE9 npDevice)
{
isMenuVisible = (Pos.x < 100) && (Pos.x > 0)? true : false;
if(isMenuVisible)
for (size_t i = 0; i < images.size(); i++)
{
std::vector<BYTE>& curArray = images[i];
if (icon[i].img == NULL)D3DXCreateTextureFromFileInMemory(npDevice, &curArray, curArray.size(), &icon[i].img);
DrawTexture(icon[i].coord.x, icon[i].coord.y, icon[i].img);
}
}
but it still not drawing nothing .... maybe &curArray is not called proprely?? NB -> i logged both image and size of arrayofarray and it return me correct values....
std::array(or optionallystd::vector) instead.