예제 #1
0
        public void InvokeReset()
        {
            var handler = Lost;

            if (handler != null)
            {
                handler(this);
            }

            try
            {
                SetRenderTarget(null);

                if (_backBuffer != null)
                {
                    _backBuffer.Dispose();
                    _backBuffer = null;
                }

#if DEBUG_REFERENCES
                IEnumerable <ObjectReference> references = ObjectTracker.FindActiveObjects();

                foreach (var reference in references)
                {
                    if (reference.IsAlive)
                    {
                        Tracer.Warn(
                            "{0} reference still alive, if object is not managed, consider calling dispose when the device context is resetting.\n\n{0} Created at:\n{1}",
                            reference.Object.GetType(),
                            reference.StackTrace);
                    }
                }
#endif

                _device.Reset(PresentationParameters);
                _viewport = _device.Viewport;
            }
            catch (SharpDXException e)
            {
#if DEBUG
                string errorMessage = ErrorManager.GetErrorMessage(e.ResultCode.Code);

                Tracer.Error(errorMessage);
#endif
                Tracer.Error(e);
                throw;
            }

            handler = Reset;

            if (handler != null)
            {
                handler(this);
            }
        }