我想在Java中渲染一个图像缓冲区(在这种情况下NDK不是选项)并通过GL_TEXTURE_EXTERNAL_OES
.
glTexImage2D
不起作用,如规范中所述。但是该功能glEGLImageTargetTexture2DOES
只能通过GLES11Ext
类使用,这似乎有点错误。
无论如何,我试过了,它给了我GL_INVALID_OPERATION
,如果:
如果 GL 无法使用提供的 eglImageOES 指定纹理对象(例如,如果引用多重采样 eglImageOES),则会生成错误 INVALID_OPERATION。
遗憾的是,我无法从这个描述中得出正面或反面,特别是因为 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
实现,看来我必须正确设置缓冲区。补充说,但仍然是同样的错误。