Example #1
0
void WrappedOpenGL::glDetachShader(GLuint program, GLuint shader)
{
	m_Real.glDetachShader(program, shader);
	
	// check that shader still exists, it might have been deleted. If it has, it's not too important
	// that we detach the shader (only important if the program will attach it elsewhere).
	if(m_State >= WRITING && program != 0 && shader != 0 && GetResourceManager()->HasCurrentResource(ShaderRes(GetCtx(), shader)))
	{
		GLResourceRecord *progRecord = GetResourceManager()->GetResourceRecord(ProgramRes(GetCtx(), program));
		RDCASSERT(progRecord);
		{
			SCOPED_SERIALISE_CONTEXT(DETACHSHADER);
			Serialise_glDetachShader(program, shader);

			progRecord->AddChunk(scope.Get());
		}
	}
}
void WrappedOpenGL::glDetachShader(GLuint program, GLuint shader)
{
  m_Real.glDetachShader(program, shader);

  // check that shader still exists, it might have been deleted. If it has, it's not too important
  // that we detach the shader (only important if the program will attach it elsewhere).
  if(m_State >= WRITING && program != 0 && shader != 0 &&
     GetResourceManager()->HasCurrentResource(ShaderRes(GetCtx(), shader)))
  {
    GLResourceRecord *progRecord =
        GetResourceManager()->GetResourceRecord(ProgramRes(GetCtx(), program));
    RDCASSERT(progRecord);
    {
      SCOPED_SERIALISE_CONTEXT(DETACHSHADER);
      Serialise_glDetachShader(program, shader);

      progRecord->AddChunk(scope.Get());
    }
  }
  else
  {
    ResourceId progid = GetResourceManager()->GetID(ProgramRes(GetCtx(), program));
    ResourceId shadid = GetResourceManager()->GetID(ShaderRes(GetCtx(), shader));

    if(!m_Programs[progid].linked)
    {
      for(auto it = m_Programs[progid].shaders.begin(); it != m_Programs[progid].shaders.end(); ++it)
      {
        if(*it == shadid)
        {
          m_Programs[progid].shaders.erase(it);
          break;
        }
      }
    }
  }
}