handle texture death

finally fixes resize
This commit is contained in:
tildearrow 2024-05-15 19:52:05 -05:00
parent d00cdabe6e
commit f66d723251
6 changed files with 28 additions and 1 deletions

View file

@ -1491,6 +1491,7 @@ class FurnaceGUIRender {
virtual float getTextureU(FurnaceGUITexture* which);
virtual float getTextureV(FurnaceGUITexture* which);
virtual FurnaceGUITextureFormat getTextureFormat(FurnaceGUITexture* which);
virtual bool isTextureValid(FurnaceGUITexture* which);
virtual bool lockTexture(FurnaceGUITexture* which, void** data, int* pitch);
virtual bool unlockTexture(FurnaceGUITexture* which);
virtual bool updateTexture(FurnaceGUITexture* which, void* data, int pitch);

View file

@ -53,7 +53,19 @@ FurnaceGUITexture* FurnaceGUI::getTexture(FurnaceGUIImages image, FurnaceGUIBlen
if (img->data==NULL) return NULL;
if (img->width<=0 || img->height<=0) return NULL;
bool createTex=false;
if (img->tex==NULL) {
createTex=true;
} else {
if (!rend->isTextureValid(img->tex)) {
rend->destroyTexture(img->tex);
img->tex=NULL;
createTex=true;
}
}
if (createTex) {
img->tex=rend->createTexture(false,img->width,img->height,true,bestTexFormat);
if (img->tex==NULL) {
logE("error while creating image %d texture! %s",(int)image,SDL_GetError());

View file

@ -35,6 +35,10 @@ FurnaceGUITextureFormat FurnaceGUIRender::getTextureFormat(FurnaceGUITexture* wh
return GUI_TEXFORMAT_UNKNOWN;
}
bool FurnaceGUIRender::isTextureValid(FurnaceGUITexture* which) {
return (which!=NULL);
}
bool FurnaceGUIRender::lockTexture(FurnaceGUITexture* which, void** data, int* pitch) {
return false;
}

View file

@ -91,6 +91,12 @@ FurnaceGUITextureFormat FurnaceGUIRenderDX9::getTextureFormat(FurnaceGUITexture*
return t->format;
}
bool FurnaceGUIRenderDX9::isTextureValid(FurnaceGUITexture* which) {
if (which==NULL) return false;
FurnaceDX9Texture* t=(FurnaceDX9Texture*)which;
return (t->tex!=NULL);
}
bool FurnaceGUIRenderDX9::lockTexture(FurnaceGUITexture* which, void** data, int* pitch) {
FurnaceDX9Texture* t=(FurnaceDX9Texture*)which;
D3DLOCKED_RECT lockedRect;
@ -519,6 +525,7 @@ bool FurnaceGUIRenderDX9::quit() {
iface->Release();
iface=NULL;
}
priv->texPool.clear();
dead=false;
return true;
}

View file

@ -1478,7 +1478,7 @@ void FurnaceGUI::drawSampleEdit() {
}
}
if (sampleTex==NULL || sampleTexW!=avail.x || sampleTexH!=avail.y) {
if (sampleTex==NULL || sampleTexW!=avail.x || sampleTexH!=avail.y || !rend->isTextureValid(sampleTex)) {
if (sampleTex!=NULL) {
rend->destroyTexture(sampleTex);
sampleTex=NULL;

View file

@ -792,6 +792,9 @@ void FurnaceGUI::drawTutorial() {
}
if (cvTex==NULL) {
cvTex=rend->createTexture(true,320,224,false,bestTexFormat);
} else if (!rend->isTextureValid(cvTex)) {
rend->destroyTexture(cvTex);
cvTex=rend->createTexture(true,320,224,false,bestTexFormat);
}
if (cv->pleaseInitSongs) {