Loading ETC textures in OpenGL ES 2.0


I’m trying to load an ETC compressed texture and I’m not having luck with that format at the moment. I have not been able to find any related examples on how to load the texture once it’s been compressed by etcpack. Do you have to exclude the small header ( magic number and version ) and send the rest of the data down ?

I’m currently doing the compression in memory using the etcpack code. I modified the function compressImageFile to compress to a buffer. I’m then sending using that buffer to load into gl. So far all my textures have turned out with no data. Does anybody manage to get that tool to work ?

Dan. :frowning:

I am not familiar with the format etcpack produces, but yes, you need to exclude any header data and pass only the raw block data for each mip level to glCompressedTexImage2D. The data size for each mip level is 8 * (level width / 4, rounded up) * (level height / 4, rounded up). In case you are not using mipmaps make sure you set the minification filter to GL_LINEAR or GL_NEAREST, otherwise GL will treat your texture as incomplete.

Here is some code showing how to load ETC textures:

By the way, the PowerVR OpenGL ES SDK comes with a texture tool that can generate ETC compressed textures, and loader code for the resulting file format.


Thanks for your answer. I have downloaded the new OpenGL ES 2.0 SDK but due to time contraints I might not be able to integrate it in our development environment.

Following your answer I’m pretty sure I’m doing everything correctly but it still doesn’t seem to work either in Windows using your emulation or on the prototype board I’m developping for. This leaves me with a few questions :

  1. Ericsson’s tools website has a tool called etcpack. Does anyone know if the output of that tool is a valid ETC texture ?
  2. I’m using an old PowerVR SDK where the libGLESv2.dll contains the symbols for elg and gl. Does it correctly support ETC ?
  3. Ok if I understand you correctly, the content of the pkm file which is the output of the etcpack tool is like this :
    Magic number
    texture type
    texture size
    texture extended size
    texture data
    So I’m only supposed to load the texture data with the call to glCompressedTexImage2D. Correct ??



Well to answer my own questions :

  1. The tool works fine.
  2. This old SDK supports ETC.
  3. You have to discard everything except the texture data.

Problem fixed.