简体   繁体   English

两个非常奇怪的SlimDX DX11错误

[英]Two very strange SlimDX DX11 errors

I am in the final stages of porting some code into my framework. 我正处于将一些代码移植到我的框架中的最后阶段。

The latest problem is very similar to this one I posted recently ( Strange "The type arguments for method cannot be inferred from the usage." ), whereby text enclosed in '<' and '>' in the listing I am porting code is missing. 最新的问题与我最近发布的这个问题非常相似( 奇怪的是“方法的类型参数不能从用法中推断出来。” ),因此我在移植代码的列表中的'<'和'>'中包含的文本丢失了。

The latest offending line is: 最新的违规行是:

        using (var resource = SlimDX.Direct3D11.Resource.FromSwapChain(swapChain, 0))
            renderTarget = new SlimDX.Direct3D11.RenderTargetView(graphics, resource);

I get the following error from the compiler: 我从编译器得到以下错误:

The type arguments for method 'SlimDX.Direct3D10.Device.OpenSharedResource(System.IntPtr)' cannot be inferred from the usage. 无法从用法推断出方法'SlimDX.Direct3D10.Device.OpenSharedResource(System.IntPtr)'的类型参数。 Try specifying the type arguments explicitly. 尝试显式指定类型参数。

I tried to fix this myself by changing my code to: 我试图通过将我的代码更改为:

        using (var resource = SlimDX.Direct3D11.Resource.FromSwapChain<SlimDX.Direct3D11.Resource>(swapChain, 0))
            renderTarget = new SlimDX.Direct3D11.RenderTargetView(graphics, resource);

... but now I get an even stranger run-time error: ...但现在我得到一个更奇怪的运行时错误:

"Error: Method 'SlimDX.Direct3D11.Resource.FromPointerReflectionThunk' not found." “错误:找不到方法'SlimDX.Direct3D11.Resource.FromPointerReflectionThunk'。”

Initial research indicates I might have stumbled into something which is way above my head: http://www.gamedev.net/topic/542095-slimdx-need-help-from-nativemanaged-interop-expert/ 最初的研究表明,我可能偶然发现了一些超出我头脑的东西: http//www.gamedev.net/topic/542095-slimdx-need-help-from-nativemanaged-interop-expert/

All I am trying to do is port this code into my framework: http://www.aaronblog.us/?p=36 ... which is all about drawing text in SlimDX with DX11. 我所要做的就是将这段代码移植到我的框架中: http ://www.aaronblog.us/?p = 36 ...这是关于使用DX11在SlimDX中绘制文本的全部内容。

At some point I hope to have figured out how to genericise this code into my framework. 在某些时候,我希望已经弄清楚如何将这个代码泛化到我的框架中。 It is heavy going though. 虽然很重要。

I'm using SlimDX SDK (January 2012). 我正在使用SlimDX SDK(2012年1月)。

Look at the last post in the gamedev.net thread you referenced -- it says that you can fix the problem by specifying the type argument as Texture2D . 查看您引用的gamedev.net线程中的最后一篇文章 - 它表示您可以通过将类型参数指定为Texture2D来解决问题。

So you might try: 所以你可以试试:

using (var resource = SlimDX.Direct3D11.Resource.FromSwapChain<Texture2D>(swapChain, 0))
    renderTarget = new SlimDX.Direct3D11.RenderTargetView(graphics, resource);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM