Sign in to follow this  

Direct3d 9 removing materials and textures

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

In Direct3d 9, after you set a material or a texture and you draw what you need to, how do you remove the materials and textures so that you can draw something simple like line primitives? Since there is a SetMaterial function, is there a similar method for removing the material?

Share this post


Link to post
Share on other sites
Quote:
Original post by Buckeye
Just use NULL for the material and texture you set in the device.

E.g., dev->SetMaterial(NULL);

That worked for the texture. For the material it gave an unhandled exception.

Any ideas how to handle this? It seems pointless to create a new material just to draw my line primitive. Would it be better to just turn lighting off when drawing the lines and then turn it back on after?

On a side note, this makes me wonder when and where I should be resetting materials and textures after they have been used. Any thoughts? It seems like it could be redundant or useless most of the time, but could cause issues like I am having if not taken care of.

Share this post


Link to post
Share on other sites
Quote:
For the material it gave an unhandled exception.

Oops. Sorry about that. [embarrass]
Quote:
It seems pointless to create a new material just to draw my line primitive. Would it be better to just turn lighting off when drawing the lines and then turn it back on after?

You can certainly do that. I wouldn't say it's better, if it doesn't do what you want it to. Why do you say its pointless to create a material to draw your lines? You only have to create it once.
Quote:
when and where I should be resetting materials and textures after they have been used ... It seems like it could be redundant or useless most of the time

Can you explain a little more about what your concern is? Are you concerned about performance? You should set materials and texures whenever you need to, to render what you want to see. If the material or texture doesn't need to be changed, or it's "useless" (don't know what that means).. don't change it.

Share this post


Link to post
Share on other sites
Quote:
Why do you say its pointless to create a material to draw your lines? You only have to create it once.

But if I have 10 different color lines to draw then I would have to make 10 materials, but they would all be unnecessary if I could just set the material to null or do something similar.

Share this post


Link to post
Share on other sites

This topic is 2658 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this