# D3DXCreateTextureFromResource Problem

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

## Recommended Posts

I am using a .tga file which i want to embed into my executable (dll). I did the following in my .rc file
#define ID_TEXTURE_CIRCLE 106
ID_TEXTURE_CIRCLE	RT_RCDATA	"circle.tga"


The .rc file gets compiled successfully. Then i am doing the following in the source file
V(D3DXCreateTextureFromResource( m_pDevice, NULL, MAKEINTRESOURCE(ID_TEXTURE_CIRCLE), &m_pPointTexture));


it gives "D3DERR_INVALIDDATA" !!! I also tried
V(D3DXCreateTextureFromResource( m_pDevice, GetModuleHandle(NULL), MAKEINTRESOURCE(ID_TEXTURE_CIRCLE), &m_pPointTexture));


Still it gives it gives "D3DERR_INVALIDDATA" !!! Could someone please give me some idea how to include a tga file into the .rc file and make D3D load it from the resource.

##### Share on other sites
Try using the HINSTANCE that is passed by the system to your DLL's DLLMain() function.

##### Share on other sites
That's what i guessed too.. but for some reason, apparently, my DllMain doesn't get called at all !! NO i am not using Resource Only DLL and my system is as follows

I have main application A, and two DLLs B, and C

in A
----

And C is explicitly linked with B using export lib. So when B is loaded with LoadLibrary, C is automatically loaded. But the DllMain is not called !

Any idea. I have my resources in dll C.

##### Share on other sites
What does the signature for DllMain look like? If it's not correct, the linker won't think it's DllMain, so it won't be called.

GetModuleHandle(NULL) returns the HMODULE / HINSTANCE of the executable that loaded the DLL, not the DLL itself, so you need to use the DLL's HMODULE from DllMain.

Another thing you could try, is explicitly setting the entry point to something other than DllMain in the linker settings (Somewhere, I don't recall exacltly where)

1. 1
2. 2
3. 3
4. 4
Rutin
17
5. 5

• 11
• 37
• 12
• 12
• 11
• ### Forum Statistics

• Total Topics
631414
• Total Posts
2999953
×