Example #1
0
        /// <summary>
        /// Close and dispose all camera and DirectX stuff.
        /// </summary>
        public void CloseAll()
        {
            _bGraphIsBuilt = false;

            // close log file if needed
            try
            {
                CloseDirectShowLogFile();
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }

            // stop rendering
            if (DX.MediaControl != null)
            {
                try
                {
                    DX.MediaControl.StopWhenReady();
                    DX.MediaControl.Stop();
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex);
                }
            }

            if (_bHandlersAdded)
            {
                RemoveHandlers();
            }

            //FilterGraphTools.RemoveAllFilters(this.graphBuilder);

#if DEBUG
            if (_rot != null)
            {
                _rot.Dispose();
            }
#endif

            // Dispose Managed Direct3D objects
            if (_pSampleGrabberHelper != null)
            {
                _pSampleGrabberHelper.Dispose();
                _pSampleGrabberHelper = null;
            }

            DX.CloseInterfaces();

            _bMixerImageWasUsed = false;
            _bMixerEnabled = false;

#if USE_D3D
            _UseGDI = true;

            // Dispose Managed Direct3D objects
            if (_pDirect3DMixing != null)
            {
                _pDirect3DMixing.Dispose();
                _pDirect3DMixing = null;
            }
#endif
        }
Example #2
0
        private void InitializeDirect3DIfNeeded()
        {
            if (_pDirect3DMixing == null)
            {
                _pDirect3DMixing = new Direct3DMixing();
            }

            _pDirect3DMixing.InitializeIfNeeded(_HostingControl);

        }