Search code examples
opengl-estextures

Segmentation fault with glCompressedTexImage2D


I'm running an OpenGL ES application on a device that supports the GL_OES_texture_compression_astc extension. I have a 3000x2000 pixel texture, and when I call glTexImage2D, everything runs fine.

To compress the image, I downloaded the ASTC encoder and executed the following command:

./astcenc.exe -c player.png player.astc 6x5 -medium

But when I use player.astc in glCompressedTexImage2D, the function causes a segmentation fault. Here's my code:

glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, tids[0]); glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_ASTC_6x5_KHR, 3000, 2000, 0, size, data); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glBindTexture(GL_TEXTURE_2D, 0);

I've checked size and data, and they appear to be fine. Is there anything I can do to fix the problem?


Solution

  • There is an example of ASTC texture usage in the Mali OpenGL ES SDK:

    http://malideveloper.arm.com/sample-code/astc-textures/