Jump to content
  • Advertisement
Sign in to follow this  
Kevin31

DX11 [SlimDX] Initialize Direct3D11

This topic is 3317 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, I'm trying to write a test application in SlimDX for DX11. This is my Initialization code:
        public void Run() {

            Result res = Device.CreateWithSwapChain(null, DriverType.Hardware, DeviceCreationFlags.SingleThreaded, SwapChainDesc, out Device, out SwapChain);
            if (res.IsFailure) {
                throw new Exception(res.Code + "/n" + res.Data);
            }

            DeviceContext = Device.ImmediateContext;


            Viewport Viewport = new Viewport();
            Viewport.X = 0;
            Viewport.Y = 0;
            Viewport.Width = Form.Width;
            Viewport.Height = Form.Height;
            Viewport.MinZ = 0f;
            Viewport.MaxZ = 1f;
            
            //Exception...
            Texture2D backbuffer = SwapChain.GetBuffer<Texture2D>(0);
            RenderTargetView = new RenderTargetView(Device, backbuffer);

            Application.Run(Form);
            Application.Idle += new EventHandler(Application_Idle);
        }


At Texture2D backbuffer = SwapChain.GetBuffer<Texture2D>(0); I get an exception: System.MissingMethodException was unhandled Message="Method 'SlimDX.Direct3D11.Texture2D.FromPointerReflectionThunk' not found." Source="mscorlib" StackTrace: at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams) at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args, CultureInfo culture) at SlimDX.DXGI.SwapChain.GetBuffer[T](Int32 buffer) at DX11_Test.Game.Run() in C:\Users\Kevin\Documents\Visual Studio 2008\Projects\SlimDX\DX11 Test\Game.cs:line 58 at DX11_Test.Program.Main() in C:\Users\Kevin\Documents\Visual Studio 2008\Projects\SlimDX\DX11 Test\Program.cs:line 21 at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException: I hope you can help, thanks in advance...

Share this post


Link to post
Share on other sites
Advertisement
I ran into this same issue when trying to write a quick D3D11 test app about 2 weeks ago.

I'm quite sure MikeP has already submitted a fix for this issue. Are you using the latest SVN revision?

Share this post


Link to post
Share on other sites
I'm sorry I don't know what a SVN revision is (embarrassing...), but I've installed SlimDX a few days ago (because I put win7 on my PC).

Share this post


Link to post
Share on other sites
Quote:
Original post by Kevin31
I'm sorry I don't know what a SVN revision is (embarrassing...), but I've installed SlimDX a few days ago (because I put win7 on my PC).


Did you download the last release? If so, you've not got a "cutting edge" copy of the code. When many projects do releases, it's at a specific milestone in the project, but in reality there are many smaller changes and updates to the code that go into the SubVersion (SVN) repository (Source control). They might not be as well-tested or as stable as the offical release, but it's almost certainly more up to date.

What sirob is suggesting that the issue you've seen may have been fixed already, but not be in the official release. To get the latest code, install Subversion (or use a GUI, like TortoiseSVN which is good on Windows) and go to the Google Code homepage for Slim DX here and get the latest code.

Share this post


Link to post
Share on other sites
I'm not familiar with SlimDX so i'm sorry if my answer doesn't even make sense...

Device.CreateWithSwapChain(null, -> DriverType.Hardware <-

How can you create a Device and a SwapChain in hardware since there's no hardware that supports direcx11 ( at least the d3d part... ) ?

Share this post


Link to post
Share on other sites
I don't know, but you're right...
The code runs without error/exception, I don't know why it works...
Strange...

Share this post


Link to post
Share on other sites
D3D 11 supports hardware all the way down to DX9 class. It will automatically create the highest feature level that it's able to. Direct3D11.Device exposes a FeatureLevel property you can use to check what feature level was actually created.

P.S. Keep in mind that our support for DX11 is still early beta and so hiccups are to be expected.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!