/// <summary> /// Отключение шейдера /// </summary> public void Unbind() { GL.UseProgram(0); if (attribs != null) { foreach (VertexAttribute v in attribs) { GL.DisableVertexAttribArray(v.Handle); } } if (GLProgram == -2) { GraphicalCaps.FallbackToLegacy(); } }
/// <summary> /// Установка шейдера /// </summary> public virtual void Bind() { bool allow = GLProgram > -2; if (allow && GLProgram == -1) { Compile(); if (GLProgram == -2) { allow = false; } } if (allow) { projectionMatrix.Matrix = ShaderSystem.ProjectionMatrix; cameraMatrix.Matrix = ShaderSystem.CameraMatrix; entityMatrix.Matrix = ShaderSystem.EntityMatrix; GL.UseProgram(GLProgram); if (uniforms != null) { foreach (Uniform u in uniforms) { u.Bind(GLProgram); } } if (attribs != null) { foreach (VertexAttribute v in attribs) { if (v.Handle > -1) { GL.EnableVertexAttribArray(v.Handle); } } } } else { GraphicalCaps.FallbackToLegacy(); GL.UseProgram(0); } }