mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 18:45:54 -05:00
Fixed GL memory leaks.
This commit is contained in:
parent
a5948679ca
commit
45365db46a
4 changed files with 33 additions and 10 deletions
|
@ -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();
|
||||
|
|
|
@ -306,7 +306,7 @@ namespace bgfx
|
|||
clear();
|
||||
}
|
||||
|
||||
~TextVideoMem()
|
||||
BX_NO_INLINE ~TextVideoMem()
|
||||
{
|
||||
BX_FREE(g_allocator, m_mem);
|
||||
}
|
||||
|
|
|
@ -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) );
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
Loading…
Reference in a new issue