Sep 16, 2009

pack problem again


struct TGA_HEADER
{
unsigned char cbIDField;
unsigned char iColorMapType;
unsigned char iImageType;
//--1 byte padding

short ofsColorMap;
short cColorMap;
unsigned char cColorMapBits;
//--1 byte padding

short dX;
short dY;
short dWidth;
short dHeight;
unsigned char dColorDepth;
unsigned char descImage;
};

I have tried to make tga file yesterday and kept fail. When the image being dragged into directx texture tool, it alwayse told me something wrong in that file. But the header should be 18 bytes and the sum of all fields in the struct is 18 bytes, too. Finally, I started to check the pack issue as before. Then the problem emerged ! You can find a comment to mark the 1 byte padding in the code. To fix this only need 2 extra lines :

#include
struct TGA_HEADER
{....};
#include

No comments: