Archived

This topic is now archived and is closed to further replies.

SikCiv

D3DXTextureFromFileInMem problem

Recommended Posts

SikCiv    122
When I read a BMP file straight into memory (the whole file) and parse the allocated memory pointer and filesize to D3DXCreateTextureFromFileInMemoryEx() it returns D3DERR_INVALIDCALL, why does it fail (the code is below)? When I load a BMP File using D3DXCreateTextureFromFileEx() and the same params it works fine. The SDK docs usage: HRESULT D3DXCreateTextureFromFileInMemoryEx( LPDIRECT3DDEVICE8 pDevice, LPCVOID pSrcData, UINT SrcData, UINT Width, UINT Height, UINT MipLevels, DWORD Usage, D3DFORMAT Format, D3DPOOL Pool, DWORD Filter, DWORD MipFilter, D3DCOLOR ColorKey, D3DXIMAGE_INFO* pSrcInfo PALETTEENTRY* pPalette, LPDIRECT3DTEXTURE8* ppTexture ); LPCVOID pSrcData; DWORD nFileSize; FILE *fp; etc....
  

    // Create the texture using D3DX

    hr = D3DXCreateTextureFromFileInMemoryEx( g_pd3dDevice, 
                                              pSrcData, 
					      nFileSize,
                                              D3DX_DEFAULT, 
					      D3DX_DEFAULT, 
					      1, 
					      0, 
					      g_d3dfmtTexture,
                                              D3DPOOL_MANAGED, 
					      D3DX_FILTER_NONE,
                                              D3DX_FILTER_NONE,
                                              0xFF000000, 
					      pImageInfo, 
					      NULL, 
					      &ppTexture );
    
    // hr returns D3DERR_INVALIDCALL



      

  Game Download  ZeroOne Realm

Share this post


Link to post
Share on other sites
El Duderino    122
SikCiv,

"Remarks :
This method is designed to be used for loading image files stored as RT_RCDATA, which is an application-defined resource (raw data). Otherwise, this method will fail."

- from the help.

It seems (from doing a little research into RT_RCDATA) that the function is for loading image files embedded into the .exe as a resource, not for creating a texture from a pre-loaded file image

EDIT - but this can't be right. Surely D3DXCreateTextureFromResourceEx is the function for this ...

El Duderino





Edited by - El Duderino on June 29, 2001 1:35:56 PM

Share this post


Link to post
Share on other sites
SikCiv    122
I found out what the problem was, for some reason the pointer to the file data wasnt parsing into my Texture loading function properly, possibly something to do with the type of pointer (*unsigned char vs *void).

And since it works now im guessing (well pretty sure) RT_RCDATA is a whole file in memory and not a resource in the exe.

  Game Download  ZeroOne Realm

Share this post


Link to post
Share on other sites