public void Initialize(params Shader[] shaders)
{
//if (shaders.Length < 1) { throw new ArgumentException(); }
if (glCreateProgram == null)
{
glCreateProgram = OpenGL.GetDelegateFor<OpenGL.glCreateProgram>();
glAttachShader = OpenGL.GetDelegateFor<OpenGL.glAttachShader>();
glLinkProgram = OpenGL.GetDelegateFor<OpenGL.glLinkProgram>();
glDetachShader = OpenGL.GetDelegateFor<OpenGL.glDetachShader>();
glDeleteProgram = OpenGL.GetDelegateFor<OpenGL.glDeleteProgram>();
glGetAttribLocation = OpenGL.GetDelegateFor<OpenGL.glGetAttribLocation>();
glUseProgram = OpenGL.GetDelegateFor<OpenGL.glUseProgram>();
glGetProgramiv = OpenGL.GetDelegateFor<OpenGL.glGetProgramiv>();
glGetUniformLocation = OpenGL.GetDelegateFor<OpenGL.glGetUniformLocation>();
}
uint programId = glCreateProgram();
foreach (Shader item in shaders)
{
glAttachShader(programId, item.ShaderId);
}
glLinkProgram(programId);
if (this.GetLinkStatus(programId) == false)
{
string log = this.GetInfoLog(programId);
throw new Exception(
string.Format("Failed to compile shader with ID {0}: {1}",
programId.ToString(), log));
}
foreach (Shader item in shaders)
{
glDetachShader(programId, item.ShaderId);
}
this.ProgramId = programId;
}