I came across AHardwareBuffer in Android. I wanted to make use of AHardwareBuffer to store textures so that I can use them on different threads where I don't have an OpenGL context. Currently, I'm doing the following:
- Generate a texture and bind it to
GL_TEXTURE_2D. - Create
EGLClientBufferandEGLImageKHRfrom it. Attach the EGLImage as texture target. - Generate an FBO and bind it to the texture using
glFramebufferTexture2D. - To draw the texture (say
tex), I'm rendering it onto theAHardwareBufferusing shaders
However, I wanted away so that I don't need to rerender it onto hardwarebuffer but instead directly store data of the texture onto hardwarebuffer.
I was thinking of using glCopyTexImage2d for doing this. Is this fine and would it work?
Also (a dumb question but I cannot get over it) if I attach my EGLImage which is from the Hardwarebuffer to GL_TEXTURE_2D and define the texture using glTexImage2D, would it not store the data of the texture which is a parameter of glTexImage2D into the hardwarebuffer?