I'm working with the Rendering Plugin sample for Unity.
Unity calls into the plugin and hands it a texture pointer, which is an OpenGL texture name (SetTextureFromUnity function for reference). I have another texture I'm creating and managing in my plugin. I would like to somehow get Unity's texture reference to use my texture instead of the one it hands to me.
Is it possible to make the Unity texture just point to my texture? I'm super rough with low level OpenGL.
Alternatively: is it possible to create a Texture2D from an openGL texture that already exists? Then I could just create my own texture and hand it back to unity to wrap with a Texture2D.
I know I could copy data from my texture to the Unity texture, but that's incredibly slow and inefficient when the data for both is already on the GPU. I am looking into FBO copies but all of this seems like overkill when I just want pointer A to point to the same thing that pointer B is pointing to (in theory any way)...
Texture2D.GetNativeTexturePtr()to pass the pointer to the texture into the plugin during one of the render methods (OnPreRender()and such). The plugin then takes this pointer and usesGLES20.glBindTexture(GLES20.GL_TEXTURE_2D, <texture pointer>)andGLUtils.texImage2D(GLES20.GL_TEXTURE_2D, 0, bitmap, 0);to load thebitmapinto the texture. However its not working currently. - sh3rifme