mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-24 05:25:12 +00:00
handle texture death
finally fixes resize
This commit is contained in:
parent
d00cdabe6e
commit
f66d723251
6 changed files with 28 additions and 1 deletions
|
@ -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);
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue