Forums | developer.brewmp.com Forums | developer.brewmp.com

Developer

Forums

Forums:

can anyone helps me debug this . when i did dbgprintf "width" and "height". the value is weird. Is my IFILE_READ and IFILE_SEEK functions used correctly ? please comment. I got the code from pocketpc and trying to port to brew.

bool Game:: LoadTexturex(const char *fileName, GLuint *id)
{

IFileMgr *m_pIFileMgr;
IFile* pFile;

if (ISHELL_CreateInstance(mShell, AEECLSID_FILEMGR, (void **)&m_pIFileMgr)
!= SUCCESS)
return EFAILED;
pFile = IFILEMGR_OpenFile(m_pIFileMgr, fileName, _OFM_READ);

GLubyte *pixels = NULL;

if(!pFile) return false;

int width = 0, height = 0;

byte headerLength = 0;
byte imageType = 0;
byte bits = 0;
int format= 0;
int lineWidth = 0;

IFILE_Read( pFile, &headerLength, sizeof(byte));

IFILE_Seek(pFile, _SEEK_CURRENT,0);

IFILE_Read( pFile, &imageType, sizeof(byte));

IFILE_Seek(pFile, _SEEK_CURRENT,9);

IFILE_Read( pFile, &width, sizeof(int));

IFILE_Read( pFile, &height, sizeof(int));

IFILE_Read( pFile, &bits, sizeof(byte));

IFILE_Seek(pFile, _SEEK_CURRENT,headerLength + 1);

if(imageType != 10)
{ DBGPRINTF(" ---WHAT IS THIS %d", bits);
if((bits == 8)||(bits == 24)||(bits == 32)) //added to support for LUMINANCE or RGBA textures
{
format = bits >> 3;
lineWidth = format * width;
pixels = new GLubyte[lineWidth * height];

for(int y = 0; y < height; y++)
{
GLubyte *line = &(pixels[lineWidth * y]);

IFILE_Read( pFile, &line, lineWidth);

if(format!= 1)
{
for(int i=0;i

Maybe there's a mismatch between the BREW byte order and the file's byte order.
-Erik

Maybe there's a mismatch between the BREW byte order and the file's byte order.
-Erik