//私の構造/クラス
class ImgObj{
public:
unsigned int *textu; //image
};
// 基本的な機能を持つ私の一般的なオブジェクト
class Aobj {
protected:
ImgObj *_obj;
public:
Aobj();
virtual ~Aobj();
ImgObj *getB(int p);
void add(unsigned int *texture);
};
//Here a create an array of that structure
void Aobj::setFrameCount(int q) {
_obj = new ImgObj[q];
}
//Adding it
void Aobj::add(unsigned int *texture, int size)
{
counter++; (counter is 0, I didn't specify this but it is there)
_obj[counter-1].textu = (unsigned int *)malloc(size);
_obj[counter-1].textu = texture;
}
// Getting back the buffer
ImgObj *Aobj::getB(int p) {
return &_obj[p];
}
//Extending the main object with some other functions which are not present here
class Background : public Aobj {
public:
Background();
virtual ~Background();
};
//---------------------------------
// 私の MAIN テスト // 基本的に画像を割り当てようとしていますが、ループで 2 回目の割り当てを行った後 // クラッシュします
Main::Main()
{
// image bytes 11704 -> 77w * 38h * 4
unsigned int *texture = new unsigned int[11704]; //an example
//Now imagine I'm filling this array with an image...
int size = 11704;
Background *background = new Background;
background->setFrameCount(1);
background->add(texture, size);
unsigned int *testtex; //testing
while(true)
{
testtex = background->getB(0)->textu;
}
// When using this it crashes (the first time works fine, the second time crash)
}