D3DXCreateTextureFromResource Problem

Started by
2 comments, last by Evil Steve 16 years, 12 months ago
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.
Z
Advertisement
Try using the HINSTANCE that is passed by the system to your DLL's DLLMain() function.
www.gameprojects.com - Share Your Games and Other Projects
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
----
LoadLibrary(B)


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.


Z
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)

This topic is closed to new replies.

Advertisement