0

I want to compress already compressed images and pass the final double compressed data to glCompressedTexImage2D. For this I have followed below steps:

glGenTextures(1, textureID);
glBindTexture(GL_TEXTURE_2D, textureID);
glTexImage2D(GL_TEXTURE_2D, level, internalformat, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
glGetTexLevelParameteriv(GL_TEXTURE_2D, 0,GL_TEXTURE_COMPRESSED_IMAGE_SIZE,
&compressedSize );
if (compressedSize > 0){
/* call glCompressedTexImage2D to render this double compressed image.*/
}

But I am getting only 0 in compressedSize. Seems the data is not getting compressed.

1 Answers1

0

GL_TEXTURE_COMPRESSED_IMAGE_SIZE isn't part of the OpenGLES 2 spec (or even OpenGLES 3.0 or 3.1)

Columbo
  • 6,648
  • 4
  • 19
  • 30
  • I used GL_TEXTURE_WIDTH and GL_TEXTURE_HEIGHT to get texture width and height. But I get 0 in both the parameters. The point is, I want to reduce the texture of already compressed texture. Please let me know if you have any idea regarding this. – storm_trooper Jan 07 '17 at 08:22
  • 1
    I don't think what you want to do is possible. What compressed format are you hoping to use with glCompressedTexImage2D? All GLES2 Android devices support ETC1, and some also support ETC2, PVRTC, DXT or ASTC. These formats have predictable compression ratios (e.g. 2bpp, 4bpp, 8bpp). Ordinarily you would compress the textures offline, not at runtime. It's not clear what you mean by double compression - you could save some storage space by zlib deflating (or similar) the texture data. However, OpenGL has no concept of that so you can't pass double compressed data to glCompressedTexImage2D. – Columbo Jan 07 '17 at 09:51