Search code examples
c#directxslimdxdirectx-11

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. 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."

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/

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.

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).


Solution

  • 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.

    So you might try:

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