summaryrefslogtreecommitdiffstatshomepage
path: root/3rdparty/bgfx/examples/27-terrain/terrain.cpp
diff options
context:
space:
mode:
Diffstat (limited to '3rdparty/bgfx/examples/27-terrain/terrain.cpp')
-rw-r--r--3rdparty/bgfx/examples/27-terrain/terrain.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/3rdparty/bgfx/examples/27-terrain/terrain.cpp b/3rdparty/bgfx/examples/27-terrain/terrain.cpp
index 71ab88aa128..74d88ac350d 100644
--- a/3rdparty/bgfx/examples/27-terrain/terrain.cpp
+++ b/3rdparty/bgfx/examples/27-terrain/terrain.cpp
@@ -58,7 +58,7 @@ struct BrushData
float m_power;
};
-class Terrain : public entry::AppI
+class ExampleTerrain : public entry::AppI
{
void init(int _argc, char** _argv) BX_OVERRIDE
{
@@ -169,9 +169,14 @@ class Terrain : public entry::AppI
bgfx::destroyProgram(m_terrainProgram);
bgfx::destroyProgram(m_terrainHeightTextureProgram);
- BX_FREE(entry::getAllocator(), m_terrain.m_vertices);
- BX_FREE(entry::getAllocator(), m_terrain.m_indices);
- BX_FREE(entry::getAllocator(), m_terrain.m_heightMap);
+ /// When data is passed to bgfx via makeRef we need to make
+ /// sure library is done with it before freeing memory blocks.
+ bgfx::frame();
+
+ bx::AllocatorI* allocator = entry::getAllocator();
+ BX_FREE(allocator, m_terrain.m_vertices);
+ BX_FREE(allocator, m_terrain.m_indices);
+ BX_FREE(allocator, m_terrain.m_heightMap);
// Shutdown bgfx.
bgfx::shutdown();
@@ -526,4 +531,4 @@ class Terrain : public entry::AppI
int64_t m_timeOffset;
};
-ENTRY_IMPLEMENT_MAIN(Terrain);
+ENTRY_IMPLEMENT_MAIN(ExampleTerrain);