Beispiel #1
0
        // Disposer
        public void Dispose()
        {
            // Not already disposed?
            if (!isdisposed)
            {
                // Clean up
                foreach (ID3DResource res in resources)
                {
                    res.UnloadResource();
                }
                if (shaders != null)
                {
                    shaders.Dispose();
                }
                rendertarget = null;
                if (backbuffer != null)
                {
                    backbuffer.Dispose();
                }
                if (depthbuffer != null)
                {
                    depthbuffer.Dispose();
                }
                if (device != null)
                {
                    device.Dispose();
                }

                if (ObjectTable.Objects.Count > 1)                //mxd. Direct3D itself is not disposed while the editor is running
                {
                    //mxd. Get rid of any remaining D3D objects...
                    foreach (ComObject o in ObjectTable.Objects)
                    {
                        if (o is Direct3D)
                        {
                            continue;                                       // Don't dispose the device itself...
                        }
                        General.WriteLogLine("WARNING: D3D resource " + o
                                             + (o.Tag != null ? " (" + o.Tag + ")" : string.Empty) + " was not disposed properly!"
                                             + (o.CreationSource != null ? " Stack trace: " + o.CreationSource : string.Empty));
                        o.Dispose();
                    }

#if DEBUG
                    General.ShowWarningMessage("Some D3D resources were not disposed properly! See the event log for more details.",
                                               MessageBoxButtons.OK);
#endif
                }

                // Done
                isrendering = false;                 //mxd
                isdisposed  = true;
            }
        }
Beispiel #2
0
        // Disposer
        internal void Dispose()
        {
            // Not already disposed?
            if (!isdisposed)
            {
                // Clean up
                foreach (ID3DResource res in resources.Values)
                {
                    res.UnloadResource();
                }
                if (shaders != null)
                {
                    shaders.Dispose();
                }
                rendertarget = null;
                if (backbuffer != null)
                {
                    backbuffer.Dispose();
                }
                if (depthbuffer != null)
                {
                    depthbuffer.Dispose();
                }
                if (device != null)
                {
                    device.Dispose();
                }
                if (font != null)
                {
                    font.Dispose();
                }
                if (fonttexture != null)
                {
                    fonttexture.Dispose();
                }

                // Done
                isdisposed = true;
            }
        }