Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DXCreateTextureFromResource

Started by Black_Moon Aug 4, 2006 at 6:13 AM 6 replies 800+ views
Original Post
Black_Moon
Black_Moon
Does anybody knows how i can use (*.tga) file as a resource texture in my project? may be someone loaded texture from resources with D3DXCreateTextureFromResource(...)? Thanks.
Evil Steve
Evil Steve
You just need to add the TGA file as a RCDATA resource in your project. From the docs:
Quote:

Remarks

[snip]

The resource being loaded must be of type RT_BITMAP or RT_RCDATA. Resource type RT_RCDATA is used to load formats other than bitmaps (such as .tga, .jpg, and .dds).


How you add the resource to your project depends on the compiler.
Black_Moon
Black_Moon
i'm using vc++ 6.0 and dx 8.0
Evil Steve
Evil Steve
It's been a while since I used VC6, but I think you just need to right click on your workspace in the workspace window and select "Add new item", select resource script (.rc), and then goto the resource tab and add a new binary resource.

Someone who uses VC6 might be able to give a better explanation...
Black_Moon
Black_Moon
ok

D3DXCreateTextureFromResource( LPDIRECT3DDEVICE9 pDevice,
HMODULE hSrcModule,
LPCTSTR pSrcResource,
LPDIRECT3DTEXTURE9 *ppTexture
);

second parametr - hSrcModule - what value needs here?
Evil Steve
Evil Steve
Quote:
Original post by Black_Moon
second parametr - hSrcModule - what value needs here?

Quote:

hSrcModule
[in] Handle to the module where the resource is located, or NULL for module associated with the image the operating system used to create the current process.
So, either NULL or the HINSTANCE of your application.
S1CA
S1CA
Quote:
Original post by Black_Moon
ok

D3DXCreateTextureFromResource( LPDIRECT3DDEVICE9 pDevice,
HMODULE hSrcModule,
LPCTSTR pSrcResource,
LPDIRECT3DTEXTURE9 *ppTexture
);

second parametr - hSrcModule - what value needs here?



If the resource is in the same process (.EXE) as your call to D3DXCreateTextureFromResource(), then you can pass NULL for hSrcModule.

Otherwise if the resource is in a different place, use GetModuleHandle()
Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site
Black_Moon
Black_Moon
Thank you all!

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.