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

[.net] Free Device Texture Memory

Started by BlackDragon777 May 1, 2006 at 6:31 PM 1 replies 800+ views
Original Post
BlackDragon777
BlackDragon777
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;
                    graphicsDevice.SetTexture(0, mesh_Texture);
                    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!!!!!
nickwinters
nickwinters
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

Topic Locked

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

Sign in to reply to this topic.