diff --git a/src/gui/gui.h b/src/gui/gui.h index dcdceaf0d..b7a09e3b9 100644 --- a/src/gui/gui.h +++ b/src/gui/gui.h @@ -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); diff --git a/src/gui/image.cpp b/src/gui/image.cpp index 980929e77..e526b43ed 100644 --- a/src/gui/image.cpp +++ b/src/gui/image.cpp @@ -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()); diff --git a/src/gui/render/abstract.cpp b/src/gui/render/abstract.cpp index 05ec3358c..90fc67a01 100644 --- a/src/gui/render/abstract.cpp +++ b/src/gui/render/abstract.cpp @@ -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; } diff --git a/src/gui/render/renderDX9.cpp b/src/gui/render/renderDX9.cpp index 720fc15c4..5799d3e4b 100644 --- a/src/gui/render/renderDX9.cpp +++ b/src/gui/render/renderDX9.cpp @@ -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; } diff --git a/src/gui/sampleEdit.cpp b/src/gui/sampleEdit.cpp index 8f97d6beb..4a85cdd06 100644 --- a/src/gui/sampleEdit.cpp +++ b/src/gui/sampleEdit.cpp @@ -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; diff --git a/src/gui/tutorial.cpp b/src/gui/tutorial.cpp index f9232e6b7..43ed2248d 100644 --- a/src/gui/tutorial.cpp +++ b/src/gui/tutorial.cpp @@ -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) {