0
C++のSDL_BlitSurfaceからセグメンテーションフォルトが発生しています。SDL_BlitSurfaceセグメンテーションフォールト
ここでコード
mainScreen->draw(0, 0, background, NULL);
'S(mainScreenスクリーンクラスのインスタンスである)及びScreenクラスの描画機能が
void Screen::draw(float x, float y, Texture* source, SDL_Rect* clip)
{
SDL_Rect offset;
offset.x = x;
offset.y = y;
if (source->myimage == NULL) throw 5;
if (this->screen == NULL) throw 6;
SDL_BlitSurface(source->myimage, NULL, this->screen, &offset);
}
として実装されており、次のようにテクスチャが定義されています。
class Texture
{
public:
Texture(std::string imagepath);
~Texture();
private:
SDL_Surface* myimage;
float width;
float height;
friend class Screen;
//friend void Screen::draw(float x, float y, Texture source, SDL_Rect* clip);
};
イメージがテクスチャクラスに読み込まれた領域を踏んできて、うまくいきました。 また、別の関数でSDL_FillRectを使用すると、this->screen
が正しくロードされていることが分かります。あなたが(それはMYIMAGEに割り当てられます)表面で行われていない
SDL_FreeSurface(optimizedImage);
:
問題を示す完全で最小限の例を投稿してください。 – genpfault