I am curious if it’s possible to load something from a file , store it in a buffer object, attach it to a texture object that is then bound to GL_TEXTURE_BUFFER , make some changes to it and then bind the same buffer object after the changes to a GL_TEXTURE_3D binding point.
I know that there are some OPENGL no-nos with assigning the same buffer object to different binding points. But the same buffer may be attached to multiple texture objects simultaneously with different format.
What I really want is a way to be able to modify/overwrite into a 3 dimensional data within a shader.
The only way it makes sense to me, is attaching a buffer object to a texture object bound to a GL_TEXTURE_BUFFER binding point, and then using glBindImageTexture to bind it to an image unit. Now i can modify an image3D uniform that refers to the image unit through imageStore() function and then hopefully later be able to bind the same buffer object that was used to a GL_TEXTURE_3D binding.
Is there a better was to do 3d modification inside a shader? And if not, can i go about doing this in the fashion above?
You can’t bind a buffer as a texture (other than GL_TEXTURE_BUFFER). Typically, the memory layout isn’t compatible (texture data is stored in a quadtree-like layout rather than in raster-scan order). You can bind the buffer to the GL_PIXEL_UNPACK_BUFFER target then copy the data with glTexSubImage3D.
If you bind GL_TEXTURE_BUFFER to an image unit, the shader has to access it via an imageBuffer uniform, not image3D. You would need to bind GL_TEXTURE_3D to an image unit to access it via an image3D uniform.