Using libktx

#1

Hello. Today I decided to try the libktx library for my OpenGL ES 2.0 application. I downloaded the source and compiled it. But whenever I try to link the library to my application I get this error:
libktx_d.lib(etcunpack.obj) : error LNK2001: unresolved external symbol _decompressBlockDiffFlip

Am I missing something or is this a bug on the GLES2 version? By the way, I am using PowerVR emulator on Windows, could it be related to that?

#2

If you defined SUPPORT_SOFTWARE_ETC_UNPACK, then you need to add etcunpack.c to your project/lib.
Also if you are using GLES 2.0, then don’t forget to define KTX_OPENGL_ES2.

To use ETC1 compression you need to set GLEW_OES_compressed_ETC1_RGB8_texture (only if device supports it), here is my code:

void zwGLObjects::CheckTexFormats(void)
{
	GLint num = 0;

	GLEW_OES_compressed_ETC1_RGB8_texture = 0;

	glGetIntegerv(GL_NUM_COMPRESSED_TEXTURE_FORMATS, &num);
	if (num > 0)
	{
		GLint* formats = (GLint*)calloc(num, sizeof(GLint));

		glGetIntegerv(GL_COMPRESSED_TEXTURE_FORMATS, formats);

		for (int index = 0; index < num; index++)
		{
			switch(formats[index])
			{
			case GL_ETC1_RGB8_OES:
				GLEW_OES_compressed_ETC1_RGB8_texture = 1;

				break;
			}
		}

		free(formats);
	}
}

For ETC1 texture compression I’m using http://www.malideveloper.com/texture-co … n-tool.php (as feature list says “Improved ETC compression speed of up to 600x compared to ETCPack at same or better quality” :wink: )

#3

Undefining SUPPORT_SOFTWARE_ETC_UNPACK did the trick. Thanks a lot.