mirror of
https://github.com/tildearrow/furnace.git
synced 2024-11-30 16:33:01 +00:00
so we need to destroy textures
This commit is contained in:
parent
8905a48361
commit
d00cdabe6e
2 changed files with 35 additions and 12 deletions
|
@ -45,6 +45,11 @@ class FurnaceDX9Texture: public FurnaceGUITexture {
|
||||||
dynamic(false) {}
|
dynamic(false) {}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct FurnaceGUIRenderDX9Private {
|
||||||
|
D3DPRESENT_PARAMETERS present;
|
||||||
|
std::vector<FurnaceDX9Texture*> texPool;
|
||||||
|
};
|
||||||
|
|
||||||
struct WipeVertex {
|
struct WipeVertex {
|
||||||
float x, y, z;
|
float x, y, z;
|
||||||
unsigned int color;
|
unsigned int color;
|
||||||
|
@ -223,13 +228,23 @@ FurnaceGUITexture* FurnaceGUIRenderDX9::createTexture(bool dynamic, int width, i
|
||||||
ret->texPre=texPre;
|
ret->texPre=texPre;
|
||||||
ret->dynamic=dynamic;
|
ret->dynamic=dynamic;
|
||||||
ret->format=format;
|
ret->format=format;
|
||||||
|
|
||||||
|
priv->texPool.push_back(ret);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FurnaceGUIRenderDX9::destroyTexture(FurnaceGUITexture* which) {
|
bool FurnaceGUIRenderDX9::destroyTexture(FurnaceGUITexture* which) {
|
||||||
FurnaceDX9Texture* t=(FurnaceDX9Texture*)which;
|
FurnaceDX9Texture* t=(FurnaceDX9Texture*)which;
|
||||||
t->tex->Release();
|
if (t->texPre!=NULL) t->texPre->Release();
|
||||||
|
if (t->tex!=NULL) t->tex->Release();
|
||||||
delete t;
|
delete t;
|
||||||
|
|
||||||
|
for (size_t i=0; i<priv->texPool.size(); i++) {
|
||||||
|
if (priv->texPool[i]==t) {
|
||||||
|
priv->texPool.erase(priv->texPool.begin()+i);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,15 +261,32 @@ void FurnaceGUIRenderDX9::resized(const SDL_Event& ev) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void FurnaceGUIRenderDX9::clear(ImVec4 color) {
|
void FurnaceGUIRenderDX9::clear(ImVec4 color) {
|
||||||
|
device->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,ImGui::ColorConvertFloat4ToU32(color),0,0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FurnaceGUIRenderDX9::present() {
|
||||||
|
device->Present(NULL,NULL,NULL,NULL);
|
||||||
|
|
||||||
if (mustResize) {
|
if (mustResize) {
|
||||||
logI("DX9: resizing buffers");
|
logI("DX9: resizing buffers");
|
||||||
ImGui_ImplDX9_InvalidateDeviceObjects();
|
ImGui_ImplDX9_InvalidateDeviceObjects();
|
||||||
|
|
||||||
if (wipeBuf!=NULL) {
|
if (wipeBuf) {
|
||||||
wipeBuf->Release();
|
wipeBuf->Release();
|
||||||
wipeBuf=NULL;
|
wipeBuf=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (FurnaceDX9Texture* i: priv->texPool) {
|
||||||
|
if (i->tex) {
|
||||||
|
i->tex->Release();
|
||||||
|
i->tex=NULL;
|
||||||
|
}
|
||||||
|
if (i->texPre) {
|
||||||
|
i->texPre->Release();
|
||||||
|
i->texPre=NULL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
priv->present.BackBufferWidth=outW;
|
priv->present.BackBufferWidth=outW;
|
||||||
priv->present.BackBufferHeight=outH;
|
priv->present.BackBufferHeight=outH;
|
||||||
priv->present.BackBufferCount=1;
|
priv->present.BackBufferCount=1;
|
||||||
|
@ -276,12 +308,6 @@ void FurnaceGUIRenderDX9::clear(ImVec4 color) {
|
||||||
|
|
||||||
mustResize=false;
|
mustResize=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
device->Clear(0,NULL,D3DCLEAR_TARGET|D3DCLEAR_ZBUFFER,ImGui::ColorConvertFloat4ToU32(color),0,0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void FurnaceGUIRenderDX9::present() {
|
|
||||||
device->Present(NULL,NULL,NULL,NULL);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FurnaceGUIRenderDX9::newFrame() {
|
bool FurnaceGUIRenderDX9::newFrame() {
|
||||||
|
|
|
@ -20,10 +20,7 @@
|
||||||
#include "../gui.h"
|
#include "../gui.h"
|
||||||
#ifdef INCLUDE_D3D9
|
#ifdef INCLUDE_D3D9
|
||||||
#include <d3d9.h>
|
#include <d3d9.h>
|
||||||
|
struct FurnaceGUIRenderDX9Private;
|
||||||
struct FurnaceGUIRenderDX9Private {
|
|
||||||
D3DPRESENT_PARAMETERS present;
|
|
||||||
};
|
|
||||||
#else
|
#else
|
||||||
typedef void IDirect3D9;
|
typedef void IDirect3D9;
|
||||||
typedef void IDirect3DVertexBuffer9;
|
typedef void IDirect3DVertexBuffer9;
|
||||||
|
|
Loading…
Reference in a new issue