Original Post
hey guys yet another question, I''m trying to write a function that reads a file or resource bitmap and copies it to an image surface, i have the file part working, but i''m having trouble getting the resource file part to load. I''m using the D3DX functions. I not sure how to refer to the resource and also how to i get the dimensions of the resource, thanks:
int cSurface::CreateImageSurface(char * filename, cDirectX * directX, int location)
{
HRESULT result;
fstream BitmapInfo;
BitmapInfo.open (filename, ios::binary | ios::in);
if (BitmapInfo.is_open ())
{
/* Ignore 18 bytes */ <---only works for file mode
BitmapInfo.seekg (18, ios::cur);
/* Get width and height of bitmap */
BitmapInfo.read ((char *)&Width, sizeof (int));
BitmapInfo.read ((char *)&Height, sizeof (int));
}
result = directX->g_pd3dDevice->CreateOffscreenPlainSurface(Width, Height,
directX->d3dpp.BackBufferFormat, D3DPOOL_DEFAULT,&Surface,NULL);
if(FAILED(result)) return 0;
if(location) /*load from file*/
result = D3DXLoadSurfaceFromFile(Surface, NULL, NULL, filename, NULL,D3DX_DEFAULT,0,NULL);
else /*load from resource*/
result = D3DXLoadSurfaceFromResource <--- not working
(Surface,NULL,NULL,NULL,filename,NULL,D3DX_DEFAULT,0,NULL);
if(FAILED(result)) return 0;
return 1;
}