private static int LoadProgram(string vertexShader, string fragmentShader) { int id = GLES20.CreateProgram(); if (id == 0) { throw new Exception("Could not create new program."); } int vertexShaderId = LoadShader(GLES20.GL_VERTEX_SHADER, vertexShader); int fragmentShaderId = LoadShader(GLES20.GL_FRAGMENT_SHADER, fragmentShader); GLES20.AttachShader(id, vertexShaderId); GLES20.AttachShader(id, fragmentShaderId); GLES20.LinkProgram(id); GLES20.DeleteShader(vertexShaderId); GLES20.DeleteShader(fragmentShaderId); int status; GLES20.GetProgramiv(id, GLES20.GL_LINK_STATUS, out status); if (status == 0) { string log = GLES20.GetProgramInfoLog(id); GLES20.DeleteProgram(id); throw new Exception("Error linking program: " + log); } GLES20.ValidateProgram(id); GLES20.GetProgramiv(id, GLES20.GL_VALIDATE_STATUS, out status); if (status == 0) { string log = GLES20.GetProgramInfoLog(id); throw new Exception("Results of validating program: " + status + ". Log: " + log); } CheckError("Program load"); return(id); }
private void glesControl1_OnDestroy() { GLES20.DeleteProgram(_program); _buffer.Dispose(); }