Fixed shader and program cleanup.

This commit is contained in:
bkaradzic 2013-10-03 20:39:55 -07:00
parent 557c175e61
commit 25917d1cac
2 changed files with 18 additions and 4 deletions

View file

@ -1071,8 +1071,12 @@ namespace bgfx
}
m_numPredefined = 0;
GL_CHECK(glUseProgram(0) );
GL_CHECK(glDeleteProgram(m_id) );
if (0 != m_id)
{
GL_CHECK(glUseProgram(0) );
GL_CHECK(glDeleteProgram(m_id) );
m_id = 0;
}
m_vcref.invalidate(s_renderCtx->m_vaoStateCache);
}

View file

@ -583,6 +583,11 @@ namespace bgfx
struct Shader
{
Shader()
: m_id(0)
{
}
void create(GLenum _type, Memory* _mem)
{
m_id = glCreateShader(_type);
@ -622,7 +627,11 @@ namespace bgfx
void destroy()
{
GL_CHECK(glDeleteShader(m_id) );
if (0 != m_id)
{
GL_CHECK(glDeleteShader(m_id) );
m_id = 0;
}
}
GLuint m_id;
@ -657,7 +666,8 @@ namespace bgfx
struct Program
{
Program()
: m_constantBuffer(NULL)
: m_id(0)
, m_constantBuffer(NULL)
, m_numPredefined(0)
{
}