Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: GL_TEXTURE_BUFFER versus GL_TEXTURE_3D

  1. #1
    Intern Contributor
    Join Date
    Oct 2012
    Posts
    52

    GL_TEXTURE_BUFFER versus GL_TEXTURE_3D

    HI


    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?

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    495
    Quote Originally Posted by driver View Post
    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.
    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.

    Quote Originally Posted by driver View Post
    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.
    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.

    Quote Originally Posted by driver View Post
    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?
    Why are you trying to use GL_TEXTURE_BUFFER?

  3. #3
    Intern Contributor
    Join Date
    Oct 2012
    Posts
    52
    you are right. I don't need to use GL_TEXTURE_BUFFER per se. Somehow I thought that image3D would work with the GL_TEXTURE_BUFFER binding.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •