views:

671

answers:

1

I am trying to use PVRTC images instead of PNG's. The problem is, that I am not able to map see them.

Here is my code:

glGenTextures(1, &bg1Texture);
glBindTexture(GL_TEXTURE_2D, bg1Texture);
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); 
glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);

NSString *path = [[NSBundle mainBundle] pathForResource:@"starfield_00" ofType:@"pvr"];
NSData *texData = [[NSData alloc] initWithContentsOfFile:path];

glCompressedTexImage2D(GL_TEXTURE_2D, 0, GL_COMPRESSED_RGBA_PVRTC_2BPPV1_IMG, 512, 512, 0, [texData length], [texData bytes]);

[texData release];

I use this command to create the compressed textures:

texturetool -e PVRTC --bits-per-pixel-2 -o starfield_00.pvr -f PVR starfield_00.png

glGetError() returns 1281 (failed to bind texture). However if i check with glIsTexture (), it returns true.

Any ideas? Oh and I use OpenGL ES on the iPhone.

+1  A: 

After i removed the -f PVR option from the encoding procedure, i was able to load the texture and display it with RGBA option. Interestingly this encoding command line was taken from one of Apple's example programs...

Istvan
the -f PVR flag tells the tool to add a header onto the PVRTC data that contains the image height and width and a couple of other things. If you use that flag, you need to parse and skip the header and just send the data after it to OpenGL.
David Maymudes