diff --git a/src/bgfx.cpp b/src/bgfx.cpp index d3e07bbe..5c3fb269 100755 --- a/src/bgfx.cpp +++ b/src/bgfx.cpp @@ -614,6 +614,8 @@ namespace bgfx void init(CallbackI* _callback, bx::ReallocatorI* _allocator) { + BX_TRACE("Init"); + if (NULL != _allocator) { g_allocator = _allocator; @@ -730,7 +732,6 @@ namespace bgfx void Context::init(bool _createRenderThread) { BX_CHECK(!m_rendererInitialized, "Already initialized?"); - BX_TRACE("init"); m_exit = false; m_frames = 0; @@ -785,11 +786,13 @@ namespace bgfx bx::snprintf(name, sizeof(name), "%02d view", ii); setViewName(ii, name); } + + BX_TRACE("Init complete."); } void Context::shutdown() { - BX_TRACE("shutdown"); + BX_TRACE("Shutdown"); getCommandBuffer(CommandBuffer::RendererShutdownBegin); frame(); diff --git a/src/bgfx_p.h b/src/bgfx_p.h index 0d6a2033..8ef4494f 100755 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -306,7 +306,7 @@ namespace bgfx clear(); } - ~TextVideoMem() + BX_NO_INLINE ~TextVideoMem() { BX_FREE(g_allocator, m_mem); } diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index d9980a09..e14af36a 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -740,13 +740,7 @@ namespace bgfx } else { - if (NULL != m_capture) - { - g_callback->captureEnd(); - BX_FREE(g_allocator, m_capture); - m_capture = NULL; - m_captureSize = 0; - } + captureFinish(); } } @@ -767,6 +761,17 @@ namespace bgfx } } + void captureFinish() + { + if (NULL != m_capture) + { + g_callback->captureEnd(); + BX_FREE(g_allocator, m_capture); + m_capture = NULL; + m_captureSize = 0; + } + } + void saveScreenShot(const char* _filePath) { uint32_t length = m_resolution.m_width*m_resolution.m_height*4; @@ -825,6 +830,8 @@ namespace bgfx void shutdown() { + captureFinish(); + invalidateCache(); #if BGFX_CONFIG_RENDERER_OPENGL @@ -1103,6 +1110,13 @@ namespace bgfx void Program::destroy() { + if (NULL != m_constantBuffer) + { + ConstantBuffer::destroy(m_constantBuffer); + m_constantBuffer = NULL; + } + m_numPredefined = 0; + GL_CHECK(glUseProgram(0) ); GL_CHECK(glDeleteProgram(m_id) ); diff --git a/src/renderer_gl.h b/src/renderer_gl.h index 2d09f1f6..3da047cd 100755 --- a/src/renderer_gl.h +++ b/src/renderer_gl.h @@ -656,6 +656,12 @@ namespace bgfx struct Program { + Program() + : m_constantBuffer(NULL) + , m_numPredefined(0) + { + } + void create(const Shader& _vsh, const Shader& _fsh); void destroy(); void init();