Skip to main content
gamedev.net
🔒 Locked

Texture Name

Started by Prads Sep 12, 2010 at 7:20 AM 7 replies 1.6k views
Original Post
Prads
Prads
Hi,
I am using DX 9. I am trying to get texture name from IDirect3DTexture9 and compare it with another string. Here's what I did:

wcscmp(myTex->Name, L"body.jpg");


But it gives access violation error. Can anyone tell me the right way to do it? Thanks!
My first 3D game: Click Here
monkeyboi
monkeyboi
I m not very sure but hava a try
string temp = myTex->Name
then wcscmp(temp,"body.jpg")
Ibasa
Ibasa
IDirect3DTexture9 doesn't define a member called 'Name'.
Double check what interface your using.

--Edit correction--
It only defines Name if D3D_DEBUG_INFO is defined.
Check that Name is not null, before calling wcscmp. Also why are using debug info?
snake5
snake5
Isn't the "Name" variable available only when using D3D_DEBUG_INFO?
Anyway, you need to store the name yourself. That's the safest way. Direct3D doesn't care about texture names anyway.
Prads
Prads
Only if I use D3D_DEBUG_INFO? It's no use then. There's is absolutely no way to know texture name? :(

Edit: I am using D3D_DEBUG_INFO because my game is still in development phase.
My first 3D game: Click Here
Ibasa
Ibasa
Keep in mind that texture does not necessarily mean an image from disk. You can create a texture using a webcam, or video file, or fractals/procedural. Name doesn't make sense all the time.

If you tell us what your actully trying to do we might be able to suggest a better way.
marius1930
marius1930
struct Texture {    IDirect3DTexture9* tex;    std::wstring name;};
snake5
snake5
Quote:
There's is absolutely no way to know texture name?

When you load a texture, you know its name. You can just make a wrapper class that stores the texture and its name together. Or you could map textures to their names with a map(dictionary) data structure. It depends on what you need.
Prads
Prads
I am trying to make rear light of a car glow when user press the down (break) button. Here's what I thought I would do, I have a material called "rearLight".

rearLight.Ambient = D3DXCOLOR(0.5f, 0, 0, 1.0f);rearLight.Diffuse = D3DXCOLOR(0.5f, 0, 0, 1.0f);rearLight.Specular = D3DXCOLOR(0, 0, 0, 1.0f);rearLight.Emmisive = D3DXCOLOR(0, 0, 0, 1.0f);rearLight.Power = 5.0f;


Texture of the rear light of the car is kept in "rearlight.jpg". Now when user presses the down button, I would change the Ambient, Diffuse and Emissive property of the "rearLight" to:

rearLight.Ambient = D3DXCOLOR(1.0f, 0, 0, 1.0f);rearLight.Diffuse = D3DXCOLOR(1.0f, 0, 0, 1.0f);rearLight.Emmisive = D3DXCOLOR(1.0f, 0, 0, 1.0f);


and when user releases the down button I change it back to previous property. And when rendering the car I would render the rear light subset with texture "rearlight.jpg" and material "rearLight". For knowing if the subset is of rear light, I would compare the name of texture with "rearlight.jpg".


Now that above method won't work, here's what I'll do:
Instead of keeping the texture name in a string, I am thinking about putting the subset id of the rear light in a integer variable and when I render that subset I will set the "rearLight" material. This method will work. But if you have better suggestion, please post it.


P.S. I finished writing the code and it works nicely. Thanks everyone but if you have better solution, please post it. :D
My first 3D game: Click Here

Topic Locked

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

Sign in to reply to this topic.