Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: reading back compressed texture array.

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2012

    Question reading back compressed texture array.

    Hello I am loading set of textures and create texture array from them in compressed format. This works fine because I see my shaders are working.
    But later I decided to use compressed data from the beginning, so I want to read my texture array back and write it to hdd, so I can later load it as compressed data.

    I was trying to use glGetCompressedTexImage, but there is no GL_TEXTURE_2D_ARRAY allowed as "target" for this function (I do not see it in documentation), so I am not sure if I can use it at all?
    Or should I create separate 2d textures and save them instead?

    Just to try out something I did like this:

    Code :
            glBindTexture(GL_TEXTURE_2D_ARRAY, tex );
            GLint csize, is_comp;
            GLint lod = 0;
            glGetTexLevelParameteriv( ptex->m_Type, lod, GL_TEXTURE_COMPRESSED_IMAGE_SIZE, &csize);
            glGetTexLevelParameteriv( ptex->m_Type, lod, GL_TEXTURE_COMPRESSED, &is_comp);
    	GLvoid* pdata = new unsigned char[csize];
    	glGetCompressedTexImage(GL_TEXTURE_2D_ARRAY, lod, pdata);
            glBindTexture(GL_TEXTURE_2D_ARRAY, 0 );

    But I have error "Invalid operation" after glGetCompressedTexImage.
    Passing GL_TEXTURE_3D instead of GL_TEXTURE_2D_ARRAY to glGetCompressedTexImage also did not help

    Any suggestions how that could be done?


    UPDATE: problem solved, it was me, who forgot to glBindTexture(GL_TEXTURE_2D_ARRAY, tex ) in actual code, but put it in this test code :-)
    However I still cannot understand how it works, because there is no GL_TEXTURE_2D_ARRAY present in documentation for "target" of glGetCompressedTexImage
    Last edited by alariq; 10-16-2013 at 08:13 AM. Reason: problem solved

  2. #2
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    What documentation are you looking at?

    Starting with the GL3.0 spec it seems documented well enough:
    The command
    void GetCompressedTexImage(enum target, int lod, void *img );
    is used to obtain texture images stored in compressed form. The parameters target, lod, and img are interpreted in the same manner as in GetTexImage.

    The command
    void GetTexImage(enum tex, int lod, enum format, enum type, void *img );
    is used to obtain texture images. ... TEXTURE_1D, TEXTURE_2D,TEXTURE_3D, TEXTURE_1D_ARRAY, and TEXTURE_2D_ARRAY indicate ...

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2012
    arekkusu, you are right I noticed this also. But, at the same, time if you look at description of valid targets for glGetCompressedTexImage you'll see that TEXTURE_2D_ARRAY is not listed.
    "interpreted in the same manner"
    does not necessarily mean that same targets are allowed. So I think there is ambiguity.

Posting Permissions

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