MediaPlayer
に接続したGLSurfaceView
にどのフラグメントシェーダを使用するかを示す整数がRecyclerView
に設定されています。私のGLSurfaceView.Renderer
では、私は次のコードを置く:GLSurfaceView.Renderer - オンザフライでシェーダプログラムを変更する
public void onFragmentShaderChanged(int filterPosition)
{
mFragmentShader = VideoUtils.getFragmentShader(mContext, filterPosition);
GLES20.glDeleteProgram(mProgram);
mProgram = createProgram(mVertexShader, VideoUtils.getFragmentShader(mContext, filterPosition));
if (mProgram == 0) {
return;
}
maPositionHandle = GLES20.glGetAttribLocation(mProgram, "aPosition");
checkGlError("glGetAttribLocation aPosition");
if (maPositionHandle == -1) {
throw new RuntimeException("Could not get attrib location for aPosition");
}
maTextureHandle = GLES20.glGetAttribLocation(mProgram, "aTextureCoord");
checkGlError("glGetAttribLocation aTextureCoord");
if (maTextureHandle == -1) {
throw new RuntimeException("Could not get attrib location for aTextureCoord");
}
muMVPMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uMVPMatrix");
checkGlError("glGetUniformLocation uMVPMatrix");
if (muMVPMatrixHandle == -1) {
throw new RuntimeException("Could not get attrib location for uMVPMatrix");
}
muSTMatrixHandle = GLES20.glGetUniformLocation(mProgram, "uSTMatrix");
checkGlError("glGetUniformLocation uSTMatrix");
if (muSTMatrixHandle == -1) {
throw new RuntimeException("Could not get attrib location for uSTMatrix");
}
}
私はRecyclerView
が、私はそれがために使用して、位置に応じて、必要なフラグメントシェーダが含まれているRAWファイルからの読み込み、前記要素をクリックすると、このコードは、トリガー既存のプログラムを削除して新しいプログラムを作成します。私はMediaPlayer
がまだ動いている間にこれをやっています。私はこれを呼び出すとlogcatが私を与えた後
は、しかし、GLSurfaceViewはグリーン右のターン:
E/libEGL:なし現在のコンテキストでのOpenGL ES APIに呼び出します(スレッド毎に一度ログイン)
設定setEGLContextClientVersion(2)
ネットはsetRenderer() has already been called in this thread
などです。
私の質問は:
- 私はその場で
GLSurfaceView.Renderer
のプログラムを変更することはできますか? - できない場合は、レンダラー自身やレンダラーのフラグメントシェーダーを変更するのはどうですか?
- 上記が実現できない場合は、別のフラグメントシェーダーを使用して同様のレンダラーで
GLSurfaceView
を再作成する必要がありますか?