I'm trying to follow this post to play a video as a texture over an Object3D. Is it necessary to create my own shader?
In other OpenGL projects I already played a video as a texture, here I'm having problems.
I do these steps:
// create a new texture
int[] textureIdVector = new int[1];
GLES20.glGenTextures(1, textureIdVector, 0);
textureId = textureIdVector[0];
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
GLES20.glTexParameteri(GLES11Ext.GL_TEXTURE_EXTERNAL_OES, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
// create an external texture
Texture externalTexture = new Texture(32, 32);
externalTexture.setExternalId(textureId, GLES11Ext.GL_TEXTURE_EXTERNAL_OES);
TextureManager.getInstance().addTexture("video", externalTexture);
// create the SurfaceTexture, the Surface and the MediaPlayer
surfaceTexture = new SurfaceTexture(textureId);
Surface surface = new Surface(surfaceTexture);
mediaPlayer.setSurface(surface);
surfaceTexture.setOnFrameAvailableListener(new SurfaceTexture.OnFrameAvailableListener() {
@Override
public void onFrameAvailable(SurfaceTexture surfaceTexture) {
// in the onDrawFrame method I call "surfaceTexture.updateTexImage()"
updateVideoTexture = true;
}
});
// tv is my Object3D on which I want to apply the video texture
tv.setTexture("video");
mediaPlayer.setLooping(true);
mediaPlayer.start();
If I try with an image as texture it works good, since I don't have an external texture but just a jpct's Texture object. This way, instead, I see nothing. The video correctly starts, because I hear its sound but I can't see it over the object.
Another thing, when I create the SurfaceTexture passing the OpenGL's texture id I see this message in logs:
W/Adreno-EGL: <qeglDrvAPI_eglQueryContext:4370>: EGL_BAD_ATTRIBUTE
Can someone say where is the problem in all this code?