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; m_numPredefined = 0;
GL_CHECK(glUseProgram(0) ); if (0 != m_id)
GL_CHECK(glDeleteProgram(m_id) ); {
GL_CHECK(glUseProgram(0) );
GL_CHECK(glDeleteProgram(m_id) );
m_id = 0;
}
m_vcref.invalidate(s_renderCtx->m_vaoStateCache); m_vcref.invalidate(s_renderCtx->m_vaoStateCache);
} }

View File

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