public bool Initialise(Device device, Texture2D renderTarget)
        {
            Debug.Assert(!_initialised);
            if (_initialising)
            {
                return(false);
            }

            _initialising = true;

            benchmarking.benchDevice = device;
            benchmarking.bench2D     = renderTarget;

            try
            {
                _device       = device;
                _renderTarget = renderTarget;
                try
                {
                    _deviceContext = ToDispose(new DeviceContext(_device));
                }
                catch (SharpDXException)
                {
                    _deviceContext = _device.ImmediateContext;
                }

                _renderTargetView = ToDispose(new RenderTargetView(_device, _renderTarget));

                //if (DeferredContext)
                //{
                //    ViewportF[] viewportf = { new ViewportF(0, 0, _renderTarget.Description.Width, _renderTarget.Description.Height, 0, 1) };
                //    _deviceContext.Rasterizer.SetViewports(viewportf);
                //    _deviceContext.OutputMerger.SetTargets(_renderTargetView);
                //}

                _spriteEngine = new DXSprite(_device, _deviceContext);
                if (!_spriteEngine.Initialize())
                {
                    return(false);
                }

                // Initialise any resources required for overlay elements
                IntialiseElementResources();

                _initialised = true;
                return(true);
            }
            finally
            {
                _initialising = false;
            }
        }
        public bool Initialise(Device device, Texture2D renderTarget)
        {
            Debug.Assert(!_initialised);
            if (_initialising)
            {
                return(false);
            }

            _initialising = true;

            try
            {
                _device       = device;
                _renderTarget = renderTarget;
                try
                {
                    // TODO: determine if any benefit to using deferred context here
                    _deviceContext = new DeviceContext(_device);
                }
                catch (SharpDXException)
                {
                    _deviceContext = _device.ImmediateContext;
                }

                _renderTargetView = new RenderTargetView(_device, _renderTarget);

                if (DeferredContext)
                {
                    //_deviceContext.Rasterizer.SetViewports(new ViewportF(0, 0, _renderTarget.Description.Width, _renderTarget.Description.Height, 0, 1));
                    _deviceContext.OutputMerger.SetTargets(_renderTargetView);
                }

                _spriteEngine = new DXSprite(_device, _deviceContext);
                if (!_spriteEngine.Initialize())
                {
                    return(false);
                }

                // Initialise any resources required for overlay elements
                IntialiseElementResources();

                _initialised = true;
                return(true);
            }
            finally
            {
                _initialising = false;
            }
        }
        public bool Initialise(Device device, Texture2D renderTarget)
        {
            Debug.Assert(!_initialised);
            if (_initialising)
                return false;

            _initialising = true;
            
            try
            {

                _device = device;
                _renderTarget = renderTarget;
                try
                {
                    // TODO: determine if any benefit to using deferred context here
                    _deviceContext = new DeviceContext(_device);
                }
                catch (SharpDXException)
                {
                    _deviceContext = _device.ImmediateContext;
                }

                _renderTargetView = new RenderTargetView(_device, _renderTarget);

                if (DeferredContext)
                {
                    _deviceContext.Rasterizer.SetViewports(new ViewportF(0, 0, _renderTarget.Description.Width, _renderTarget.Description.Height, 0, 1));
                    _deviceContext.OutputMerger.SetTargets(_renderTargetView);
                }

                _spriteEngine = new DXSprite(_device, _deviceContext);
                if (!_spriteEngine.Initialize())
                    return false;

                // Initialise any resources required for overlay elements
                IntialiseElementResources();

                _initialised = true;
                return true;
            }
            finally
            {
                _initialising = false;
            }
        }