我想在 Java 中渲染一个图像缓冲区(在这种情况下,NDK 不是一个选项)并通过 GL_TEXTURE_EXTERNAL_OES 将其传递给着色器.
glTexImage2D 不起作用,如 spec 中所述.但是函数 glEGLImageTargetTexture2DOES 只能通过 GLES11Ext 类使用,使用起来似乎有点不对。
无论如何,我试过了,它给了我GL_INVALID_OPERATION,这应该发生在以下情况下:
If the GL is unable to specify a texture object using the supplied eglImageOES (if, for example, refers to a multisampled eglImageOES), the error INVALID_OPERATION is generated.
遗憾的是,我不能从这个描述中得出结论,特别是因为 Android Java API 似乎没有让我访问 eglImageOES 函数。我也没有找到使用此函数的 Java 示例。
附上一个小例子:
// Bind the texture unit 0
GLES20.glActiveTexture( GLES20.GL_TEXTURE0 );
throwOnError( "glActiveTexture" );
GLES20.glBindTexture( GL_TEXTURE_EXTERNAL_OES, _samplerLocation );
throwOnError( "glBindTexture" );
// _output is ByteBuffer.allocateDirect(pixels * Integer.SIZE / Byte.SIZE).order(ByteOrder.nativeOrder()).asIntBuffer()
_output.rewind();
_output.limit( pixels );
GLES11Ext.glEGLImageTargetTexture2DOES( GL_TEXTURE_EXTERNAL_OES, _output );
throwOnError( "glEGLImageTargetTexture2DOES" ); // <-- throws
GLES20.glDrawArrays( GLES20.GL_TRIANGLE_STRIP, 0, 4 );
throwOnError( "glDrawArrays" );
以前有没有人这样做过或知道这是否可能?
编辑:
我查看了 glEGLImageTargetTexture2DOES 实现,看来我必须正确设置缓冲区。添加了那个,但仍然是同样的错误。
最佳答案
此页面中有一些评论可能会有所帮助: http://developer.android.com/reference/android/graphics/SurfaceTexture.html
关于java - GLES2.0 : Use GL_TEXTURE_EXTERNAL_OES via glEGLImageTargetTexture2DOES,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14102992/