/// <summary> /// Compiles and links vertex and fragment shaders from strings. /// </summary> /// <param name="sVertexShd_">The vertex shader source code string.</param> /// <param name="sFragmentShd_">The fragment shader source code string.</param> /// <returns> /// a new instance /// </returns> public static ShaderProgramGL FromStrings(string sVertexShd_, string sFragmentShd_) { ShaderProgramGL shd = new ShaderProgramGL(); try { shd.FromStrings(sVertexShd_, sFragmentShd_); } catch (Exception e) { shd.Dispose(); throw e; } return(shd); }
/// <summary> /// Creates from strings. /// </summary> /// <param name="vertexShaderCode">The vertex shader code.</param> /// <param name="fragmentShaderCode">The fragment shader code.</param> /// <returns></returns> public static ShaderProgramGL CreateFromStrings(string vertexShaderCode, string fragmentShaderCode) { var vertexShader = CreateShader(ShaderType.VertexShader, vertexShaderCode); var fragmentShader = CreateShader(ShaderType.FragmentShader, fragmentShaderCode); var shaderProgram = new ShaderProgramGL(); shaderProgram.Attach(vertexShader); shaderProgram.Attach(fragmentShader); if (!shaderProgram.Link()) { var e = new ShaderLinkException(shaderProgram.Log); shaderProgram.Dispose(); throw e; } return(shaderProgram); }