Trying to save cube maps to file I’ve written this code:
Procedure tCubeTexture.SaveTextureInInternalFormat(Stream:tStream);
Var Compressed:Lint;
CompInfo:tCompressionInfo;
CompressedImage:Pointer;
I:Longint;
Begin
Bind(GL_TEXTURE0);
glPixelStorei(GL_UNPACK_ALIGNMENT,1);
// preserve sizes of all compressed faces
For I:=0 To 5 Do Begin
CompInfo.CompressedSizes[i]:=Image.Width*Image.Height*3;
End;
// write headers
Stream.BlockWrite(Image, SizeOf(Image));
Stream.BlockWrite(CompInfo, SizeOf(CompInfo));
// write images
For I:=0 To 5 Do Begin
GetMem(CompressedImage, CompInfo.CompressedSizes[i]);
glGetTexImage(CubeTarget[i], 0, GL_RGB, GL_UNSIGNED_BYTE, CompressedImage);
glFinish();
Stream.BlockWrite(CompressedImage^, CompInfo.CompressedSizes[i]);
FreeMem(CompressedImage);
End;
End;
Then I use Photoshop to load the resulting file in a RAW format (Header+512*3072). The result is wrong: i have the same image on all 6 faces of cube map. What might be the problem ?