public void AttachShaders(ContentRef<VertexShader> v, ContentRef<FragmentShader> f, ContentRef<GeometryShader> g = new ContentRef<GeometryShader>())
{
DualityApp.GuardSingleThreadState();
if (this.glProgramId == 0) this.glProgramId = GL.CreateProgram();
else this.DetachShaders();
this.compiled = false;
this.vert = v;
this.frag = f;
this.geom = g;
// Assure all shaders are compiled
if (this.vert.IsAvailable) this.vert.Res.Compile();
if (this.frag.IsAvailable) this.frag.Res.Compile();
if (this.geom.IsAvailable) this.geom.Res.Compile();
// Attach all shaders
if (this.vert.IsAvailable) GL.AttachShader(this.glProgramId, this.vert.Res.OglShaderId);
if (this.frag.IsAvailable) GL.AttachShader(this.glProgramId, this.frag.Res.OglShaderId);
if (this.geom.IsAvailable) GL.AttachShader(this.glProgramId, this.geom.Res.OglShaderId);
}