• Advertisement
Sign in to follow this  

D3DXCreateTextureFromFileInMemory()

This topic is 4614 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

HRESULT WINAPI D3DXCreateTextureFromFileInMemory( LPDIRECT3DDEVICE9 pDevice, LPCVOID pSrcData, UINT SrcDataSize, LPDIRECT3DTEXTURE9 *ppTexture ); how can i create pSrcData???????? does it need to be bmp,jpg... or i can create just some raw data??

Share this post


Link to post
Share on other sites
Advertisement
Yes, the data pointed to by pSrcData needs to be a file in .bmp, .dds, .dib, .hdr, .jpg, .pfm, .png, .ppm, or .tga format. That function doesn't work with raw data.

Share this post


Link to post
Share on other sites
Well, really you need to load a file into memory for it to work.

If you really can't load a file from disk then use the version that lets you load from a resource, or find some kind of tool that converts a binary file into C/C++ source code.

If you want to create a texture from raw RGBA data, then use the technique I outlined in this thread

http://www.gamedev.net/community/forums/topic.asp?topic_id=343090&whichpage=1�

Share this post


Link to post
Share on other sites
:))) i just asked u that in one topic up, but ill ask again here: how can i load a file in memory(jpg,bmp...)??

Share this post


Link to post
Share on other sites
If all you want to do is load a texture from file, then use D3DXCreateTextureFromFile, otherwise:

Open the file

Seek to the end of the file to get the file size

Seek back to the beginning of the file.

Create an array of unsigned chars big enough to hold the whole file, read the contents of the file into the array

Pass the pointer to the array as pSrcData.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement