Login  Register

Re: PVRTC textures in JOGL2?

Posted by asambol on Oct 16, 2013; 1:04pm
URL: https://forum.jogamp.org/PVRTC-textures-in-JOGL2-tp4030250p4030268.html

Here's what I tried:

public class PVRTCTextureProvider implements TextureProvider {

	@Override
	public TextureData newTextureData(GLProfile glp, File file,
			int internalFormat, int pixelFormat, boolean mipmap,
			String fileSuffix) throws IOException {
		
		boolean compressed = true;
		mipmap = false;
		boolean mustFlipVertically = false;
		Flusher flusher = null;
//		internalFormat = 0x8C02; // GL_COMPRESSED_RGBA_PVRTC_4BPPV1_IMG
		internalFormat = 0x9138; // GL_COMPRESSED_RGBA_PVRTC_4BPPV2_IMG
		pixelFormat = GL.GL_RGBA;
		int pixelType = GL.GL_UNSIGNED_BYTE;
		int border = 0;
		int width = 512;
		int height = 512;
		
		if (!fileSuffix.equals("pvr")) {
			return null;
		}
		ByteBuffer buffer = getBytesFromFile(file); // file as bytes
		TextureData textureData = new TextureData(glp, internalFormat, width, height, border, pixelFormat, pixelType, mipmap, compressed, mustFlipVertically, buffer, flusher);
		return textureData;
	}
...
}

However, it doesn't work. I have tried all possible combinations for pixelType, pixelFormat and internalFormat.

On non PowerVR hardware I get transparent object, on PowerVR hardware I get a black square.

I guess the problem is that the PVRTC format is compressed 4bpp, and I'm using GL_UNSIGNED_BYTE. I also tried PVR RGBA8888 uncompressed format with no success.

Any hints?