Fix if you change from normal to normalfast render mode, then move to inside a block with fog of some sort like lava/water, then resize the game window, and you are using Direct3D9, your game crashes. (Thanks fam0r)

So for the 87th time, I have permanently fixed the issue of leaking GFX resources for good.
This commit is contained in:
UnknownShadow200 2020-01-09 12:20:43 +11:00
parent d38f3a67b8
commit 4fed6a6c7a

View File

@ -185,8 +185,8 @@ static void UpdateClouds(void) {
int extent; int extent;
int x1, z1, x2, z2; int x1, z1, x2, z2;
if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&clouds_vb); Gfx_DeleteVb(&clouds_vb);
if (!World.Blocks || Gfx.LostContext) return;
if (EnvRenderer_Minimal) return; if (EnvRenderer_Minimal) return;
extent = Utils_AdjViewDist(Game_ViewDistance); extent = Utils_AdjViewDist(Game_ViewDistance);
@ -263,8 +263,8 @@ static void UpdateSky(void) {
int extent, height; int extent, height;
int x1, z1, x2, z2; int x1, z1, x2, z2;
if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&sky_vb); Gfx_DeleteVb(&sky_vb);
if (!World.Blocks || Gfx.LostContext) return;
if (EnvRenderer_Minimal) return; if (EnvRenderer_Minimal) return;
extent = Utils_AdjViewDist(Game_ViewDistance); extent = Utils_AdjViewDist(Game_ViewDistance);
@ -346,8 +346,8 @@ static void UpdateSkybox(void) {
}; };
int i; int i;
if (Gfx.LostContext) return;
Gfx_DeleteVb(&skybox_vb); Gfx_DeleteVb(&skybox_vb);
if (Gfx.LostContext) return;
if (EnvRenderer_Minimal) return; if (EnvRenderer_Minimal) return;
for (i = 0; i < SKYBOX_COUNT; i++) { vertices[i].Col = Env.SkyboxCol; } for (i = 0; i < SKYBOX_COUNT; i++) { vertices[i].Col = Env.SkyboxCol; }
@ -685,8 +685,8 @@ static void UpdateMapSides(void) {
VertexP3fT2fC4b* ptr; VertexP3fT2fC4b* ptr;
VertexP3fT2fC4b* cur; VertexP3fT2fC4b* cur;
if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&sides_vb); Gfx_DeleteVb(&sides_vb);
if (!World.Blocks || Gfx.LostContext) return;
block = Env.SidesBlock; block = Env.SidesBlock;
if (Blocks.Draw[block] == DRAW_GAS) return; if (Blocks.Draw[block] == DRAW_GAS) return;
@ -744,8 +744,8 @@ static void UpdateMapEdges(void) {
VertexP3fT2fC4b* ptr; VertexP3fT2fC4b* ptr;
VertexP3fT2fC4b* cur; VertexP3fT2fC4b* cur;
if (!World.Blocks || Gfx.LostContext) return;
Gfx_DeleteVb(&edges_vb); Gfx_DeleteVb(&edges_vb);
if (!World.Blocks || Gfx.LostContext) return;
block = Env.EdgeBlock; block = Env.EdgeBlock;
if (Blocks.Draw[block] == DRAW_GAS) return; if (Blocks.Draw[block] == DRAW_GAS) return;
@ -798,7 +798,6 @@ static void OnContextLost(void* obj) {
} }
static void UpdateAll(void) { static void UpdateAll(void) {
DeleteVbs();
UpdateMapSides(); UpdateMapSides();
UpdateMapEdges(); UpdateMapEdges();
UpdateClouds(); UpdateClouds();
@ -806,6 +805,7 @@ static void UpdateAll(void) {
UpdateSkybox(); UpdateSkybox();
EnvRenderer_UpdateFog(); EnvRenderer_UpdateFog();
Gfx_DeleteDynamicVb(&weather_vb);
if (Gfx.LostContext) return; if (Gfx.LostContext) return;
/* TODO: Don't allocate unless used? */ /* TODO: Don't allocate unless used? */
weather_vb = Gfx_CreateDynamicVb(VERTEX_FORMAT_P3FT2FC4B, WEATHER_VERTS_COUNT); weather_vb = Gfx_CreateDynamicVb(VERTEX_FORMAT_P3FT2FC4B, WEATHER_VERTS_COUNT);