1

メソッド「SwapChain.ResizeBuffers(...)」に問題があります。呼び出すたびにエラーが発生します...基本的に、私がやろうとしていることは次のとおりです。そのため、_RenderingWidth と _RenderingHeight の値を変更したときに、このメソッド (以下) を呼び出します...

    protected override void UpdateResolution()
    {
        if (_RenderTargetView != null) _RenderTargetView.Dispose();
        if (_BackBuffer != null) _BackBuffer.Dispose();

        _Device.OutputMerger.SetTargets((RenderTargetView) null);

        _SwapChain.ResizeBuffers(_SwapChain.Description.BufferCount, _RenderingWidth, _RenderingHeight, _SwapChain.Description.ModeDescription.Format, _SwapChain.Description.Flags);

        _BackBuffer = Texture2D.FromSwapChain<Texture2D>(_SwapChain, 0);
        _RenderTargetView = new RenderTargetView(_Device, _BackBuffer);

        _Device.OutputMerger.SetTargets(_RenderTargetView);
    }

それが私に与える唯一の情報は次のとおりです。

An unhandled exception of type 'SlimDX.DXGI.DXGIException' occurred in SlimDX.dll
Additional information: DXGI_ERROR_INVALID_CALL: The application has made an erroneous API call that it had enough information to avoid. This error is intended to denote that the application should be altered to avoid the error.

私の宣言:

    protected SlimDX.Direct3D10_1.Device1 _Device = null;
    protected SwapChain _SwapChain = null;

    protected Texture2D _BackBuffer = null;
    protected RenderTargetView _RenderTargetView = null;

[編集]私はそれを理解しました:

    var description = _SwapChain.Description;

    if (_RenderTargetView != null) _RenderTargetView.Dispose();
    if (_BackBuffer != null) _BackBuffer.Dispose();

    _SwapChain.Dispose();

    description.ModeDescription = new ModeDescription(_RenderingWidth, _RenderingHeight, new Rational(160, 1), Format.B8G8R8A8_UNorm);
    _SwapChain = new SwapChain(_Factory_DXGI, _Device, description);

    _BackBuffer = Texture2D.FromSwapChain<Texture2D>(_SwapChain, 0);
    _RenderTargetView = new RenderTargetView(_Device, _BackBuffer);

    _Device.OutputMerger.SetTargets(_RenderTargetView);

すべてを再起動しています...なぜこれを前に考えなかったのかわかりません!

4

0 に答える 0