Jump to content
  • Advertisement
Sign in to follow this  
ryt

D3DXCreateTextureFromFileInMemory()

This topic is 4705 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
how can i create this pSrcData?? i wish to create it from code, not load it from disk

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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!