Jump to content
  • Advertisement
Sign in to follow this  
ganbree

Texture From File In Memory

This topic is 3915 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

Why does this constantly fail?
if(FAILED(D3DXCreateTextureFromFileInMemoryEx(
	pD3DDevice,
	Raw,
	Size,
	D3DX_DEFAULT,
	D3DX_DEFAULT,
	D3DX_DEFAULT,
	NULL,
	D3DFMT_A8R8G8B8,
	D3DPOOL_MANAGED,
	D3DX_DEFAULT, 
	D3DX_DEFAULT,
	D3DCOLOR_XRGB(255, 2, 255),
	&ImageInfo,
	NULL,
	&(Texture) )))
{
	// Always Fails
}

Raw and Size are straight out of an ifstream. The raw data is in the PNG format.

Share this post


Link to post
Share on other sites
Advertisement
Without seeing your file loading code it's really difficult to say. Common mistakes can include not opening the file in binary mode or not getting the size correctly. If it's not one of those problems, you'll probably need to post your code.

Share this post


Link to post
Share on other sites
I've worked out what the problem was...

I didn't call ResourceFile::LoadHeader(); and thus size was of an undefined length.

I think I should call that from ResourceFile::Open(); prevent future head aches.

Thank you.

Share this post


Link to post
Share on other sites
I hope you learned a lesson.
Never assume anything...
you must always check in the debugger what you actually pass to a function when it fails. You should have also looked at the return value instead of just using the FAILED macro on it. A HRESULT tells you what type of error happened.

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!