private static void CheckError(string operation) { int error; int lastError = GLES20.GL_NO_ERROR; while ((error = GLES20.GetError()) != GLES20.GL_NO_ERROR) { lastError = error; } if (lastError != GLES20.GL_NO_ERROR) { throw new Exception(operation + " produced error code " + lastError + "."); } }