Sign in to follow this  
BlackDragon777

[.net] Free Device Texture Memory

Recommended Posts

Hello. I am writing a program that lets you view mesh files. I let the user choose a mesh and a texture respectively. However, sometimes I don't want to draw a texture onto a mesh. It seems though that if I load a mesh with a texture, the device remembers that texture and draws it on mesh I load. My code for drawing the mesh looks like,
 if (bTextured == true)
            {
                for (int i = 0; i < mesh_Material.Length; i++)
                {
                    graphicsDevice.Material = mesh_Material[i];
                    graphicsDevice.SetTexture(0, mesh_Texture[i]);
                    mesh_Object.DrawSubset(0);
                }
            }
            else
            {
                    mesh_Object.DrawSubset(0);
            }
Even though I am not trying to draw the texture if bTextured == false, the texture is still drawn on top of the mesh. Is there a way that I can free the device texture memory? I have tried setting the mesh_Material and mesh_Texture to null so that C#'s gc would delete it for me but that doesn't work. Any ideas? Thanks in Advance! GOD Bless you Always!!!!!

Share this post


Link to post
Share on other sites
Off the top of my head, try something like. I haven't tried it in C#, but that's how I used to do it in C++. Most of the calls are pretty similar between the two.

graphicsDevice.SetTexture(0, null);

-Nick

Share this post


Link to post
Share on other sites

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