I would like to render an image buffer in Java (NDK is no option in this case) and pass it to shaders via GL_TEXTURE_EXTERNAL_OES
.
我想用Java渲染图像缓冲区(在这种情况下NDK不是选项)并通过GL_TEXTURE_EXTERNAL_OES将其传递给着色器。
glTexImage2D
does not work, as mentioned in the spec. But the function glEGLImageTargetTexture2DOES
is only available via the GLES11Ext
class, which seems kind of wrong to use.
如规范中所述,glTexImage2D不起作用。但函数glEGLImageTargetTexture2DOES只能通过GLES11Ext类使用,这似乎有点不对。
Anyway, I tried and it gives me GL_INVALID_OPERATION
, which should happen if:
无论如何,我试过,它给了我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.
如果GL不能使用提供的eglImageOES指定纹理对象(例如,如果指的是多重采样的eglImageOES),则生成错误INVALID_OPERATION。
Sadly I cannot make heads or tails from this description, especially since the Android Java API doesn't seem to give me access to eglImageOES
functions. Neither have I found a Java example for the usage of this function.
遗憾的是,我不能从这个描述中做出正面或反面,特别是因为Android Java API似乎不能让我访问eglImageOES函数。我也没有找到使用此函数的Java示例。
Attached a small example:
附上一个小例子:
// 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" );
Did anyone do that before or know whether this is possible or not?
有没有人之前这样做或知道这是否可能?
EDIT:
I had a look at glEGLImageTargetTexture2DOES
implementation and it seems that I have to correctly setup the buffer. Added that, but still same error.
我看了一下glEGLImageTargetTexture2DOES实现,似乎我必须正确设置缓冲区。补充说,但仍然是同样的错误。
1 个解决方案
#1
0
There are some comments in this page which might help: http://developer.android.com/reference/android/graphics/SurfaceTexture.html
此页面中有一些评论可能有所帮助:http://developer.android.com/reference/android/graphics/SurfaceTexture.html
#1
0
There are some comments in this page which might help: http://developer.android.com/reference/android/graphics/SurfaceTexture.html
此页面中有一些评论可能有所帮助:http://developer.android.com/reference/android/graphics/SurfaceTexture.html