首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >SharpDX.DXGI - DXGI_ERROR_INVALID_CALL

SharpDX.DXGI - DXGI_ERROR_INVALID_CALL
EN

Stack Overflow用户
提问于 2017-04-23 13:19:20
回答 1查看 390关注 0票数 0

我已经寻找了很多次解决方案,但是我没有找到它。下面是我的代码:

代码语言:javascript
复制
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));
    }
}
}

异常在第行抛出

代码语言:javascript
复制
D11.Device.CreateWithSwapChain(DriverType.Hardware, D11.DeviceCreationFlags.None, chaindesk, out device, out chain);

我已经在2010年6月安装了DirectX软件开发工具包。我的电脑运行的是Windows7 SP1。我正在Visual Studio社区2017中做这个项目。从NuGet下载了SharpDX库。以下是异常的完整日志:

代码语言:javascript
复制
SharpDX.SharpDXException: "HRESULT: [0x887A0001], Module: [SharpDX.DXGI], ApiCode: [DXGI_ERROR_INVALID_CALL/InvalidCall], Message: Unknown"
EN

回答 1

Stack Overflow用户

发布于 2017-04-26 18:27:25

尝试使用调试DeviceCreationFlags。这将帮助您找到问题所在。另外,我只能推荐来自robydx的sharpdx教程:

Tutorials

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/43567688

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档