From 6412c5e0763dc079312cd5c81cb077d0c393b2b4 Mon Sep 17 00:00:00 2001 From: Branimir Karadžić Date: Tue, 8 Mar 2016 11:44:52 +0100 Subject: Update BGFX and BX (nw) --- 3rdparty/bgfx/examples/27-terrain/terrain.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to '3rdparty/bgfx/examples/27-terrain/terrain.cpp') 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); -- cgit v1.2.3-70-g09d2