【问题标题】:SharpDX.DXGI - DXGI_ERROR_INVALID_CALLSharpDX.DXGI - DXGI_ERROR_INVALID_CALL
【发布时间】:2017-04-26 18:27:24
【问题描述】:

我已经搜索了很多解决方案,但我找不到它。 这是我的代码:

namespace MySharpDXGame
{
 public class Game
 {

    public static void Main()
    {
        Game game = new Game();
        game.InitializeGraphics();
        RenderLoop.Run(game.MainForm, game.RenderCallback);
    }

    private RenderForm MainForm;

    private const int Width = 1280;
    private const int Height = 720;

    private D11.Device device;
    private D11.DeviceContext context;
    private SwapChain chain;

    private D11.RenderTargetView rendtargview;

    public Game()
    {
        MainForm = new RenderForm("Simple Render")
        {
            ClientSize = new System.Drawing.Size(Width, Height),
            AllowUserResizing = true  
        };

    }

    private void RenderCallback()
    {
        Draw();
    }

    public void InitializeGraphics()
    {
        ModeDescription modesc = new ModeDescription(Width, Height, new Rational(60, 1), Format.R8G8B8A8_UNorm);
        SwapChainDescription chaindesk = new SwapChainDescription()
        {
            ModeDescription = modesc,
            SampleDescription = new SampleDescription(1, 0),
            Usage = Usage.RenderTargetOutput,
            BufferCount = 1,
            OutputHandle = MainForm.Handle,
            IsWindowed = true
        };

        D11.Device.CreateWithSwapChain(DriverType.Hardware, D11.DeviceCreationFlags.None, chaindesk, out device, out chain);
        context = device.ImmediateContext;
        rendtargview = new D11.RenderTargetView(device, chain.GetBackBuffer<D11.Texture2D>(0));
        System.Windows.Forms.MessageBox.Show("created!");
    }

    private void Draw()
    {
        context.OutputMerger.SetRenderTargets(rendtargview);
        context.ClearRenderTargetView(rendtargview, new Scolor(32, 103, 178, 255));
    }
}
}

异常在行抛出

D11.Device.CreateWithSwapChain(DriverType.Hardware, D11.DeviceCreationFlags.None, chaindesk, out device, out chain);

我已于 2010 年 6 月安装了 DirectX SDK。我的计算机在 Windows 7 SP1 上运行。我在 Visual Studio Community 2017 中做这个项目。SharpDX 库是从 NuGet 下载的。 这是异常的完整日志:

SharpDX.SharpDXException: "HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], Message: Unknown"

【问题讨论】:

    标签: exception directx-11 sharpdx


    【解决方案1】:

    尝试使用 Debug DeviceCreationFlags。这应该可以帮助您找到问题所在。另外我只能推荐来自robydx的sharpdx教程:

    Tutorials

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多