Ejemplo n.º 1
0
        void reset()
        {
            if (offscreen == null)
            {
                return;
            }

            SharpDX.DataRectangle stream = offscreen.LockRectangle(LockFlags.ReadOnly);

            VideoFrame.copySurfaceToBuffer(stream.DataPointer,
                                           offscreen.Description.Width, offscreen.Description.Height, stream.Pitch, offscreenBuffer);

            offscreen.UnlockRectangle();

            releaseResources();

            D3D.PresentParameters[] presentParams = createPresentParams(windowed, owner);

            device.Reset(presentParams);

            aquireResources();

            stream = offscreen.LockRectangle(LockFlags.None);

            VideoFrame.copyBufferToSurface(offscreenBuffer, stream.DataPointer,
                                           offscreen.Description.Width, offscreen.Description.Height, stream.Pitch);

            offscreen.UnlockRectangle();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reset the _renderTarget so that we are sure it will have the correct presentation parameters (required to support working across changes to windowed/fullscreen or resolution changes)
        /// </summary>
        /// <param name="devicePtr"></param>
        /// <param name="presentParameters"></param>
        /// <returns></returns>
        int ResetHook(IntPtr devicePtr, ref PresentParameters presentParameters)
        {
            Device device = (Device)devicePtr;

            try
            {
                lock (_lockRenderTarget)
                {
                    if (_renderTarget != null)
                    {
                        _renderTarget.Dispose();
                        _renderTarget = null;
                    }
                }
                // EasyHook has already repatched the original Reset so calling it here will not cause an endless recursion to this function
                device.Reset(presentParameters);
                return(SharpDX.Result.Ok.Code);
            }
            catch (SharpDX.SharpDXException sde)
            {
                return(sde.ResultCode.Code);
            }
            catch (Exception e)
            {
                DebugMessage(e.ToString());
                return(SharpDX.Result.Ok.Code);
            }
        }