I am starting with DirectX and use SlimDX. I try to set up a device and swap chain. when calling Device.CreateWithSwapChain(...) i get an Direct3D11Exception "E_INVALIDARG: An invalid parameter was passed to the returning function (-2147024809)". I have tried many combinations of settings and compared my code to a couple of other examples but I cannot see what is wrong. Here is my code:
...
// create the swap chain description
swapChainDescription = new SwapChainDescription();
// set to a single back buffer
swapChainDescription.BufferCount = 1;
// create the mode description for the back buffer
modeDescription = new ModeDescription();
// set refresh rate
refreshRate = new Rational();
refreshRate.Numerator = numerator;
refreshRate.Denominator = denominator;
modeDescription.RefreshRate = refreshRate;
// set the buffer size
modeDescription.Width = form.Width;
modeDescription.Height = form.Height;
// set the scan line ordering and scaling to unspecified
modeDescription.ScanlineOrdering = DisplayModeScanlineOrdering.Unspecified;
modeDescription.Scaling = DisplayModeScaling.Unspecified;
// set the mode description of the back buffer
swapChainDescription.ModeDescription = modeDescription;
// set the usage of the back buffer
swapChainDescription.Usage = Usage.RenderTargetOutput;
// set the handle for the window to render to
swapChainDescription.OutputHandle = form.Handle;
// turn multisampling off
sampleDescription = new SampleDescription();
sampleDescription.Count = 1;
sampleDescription.Quality = 0;
swapChainDescription.SampleDescription = sampleDescription;
// fullscreen or windowed
swapChainDescription.IsWindowed = !fullscreen;
// discard the back buffer contents after presenting
swapChainDescription.SwapEffect = SwapEffect.Discard;
// don't set the advanced flags
swapChainDescription.Flags = SwapChainFlags.None;
// create the swap chain, device and device context
FeatureLevel[] featureLevels = new FeatureLevel[] { FeatureLevel.Level_11_0 };
if (!Device.CreateWithSwapChain(DriverType.Hardware, DeviceCreationFlags.None, featureLevels, swapChainDescription, out device, out swapChain).IsSuccess)
{
MessageBox.Show("Cannot create a DirectX 11 device und swap chain", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
deviceContext = device.ImmediateContext;
...
with form being a SlimDX.Windows.RenderForm, numerator = 60, denominator = 1
I am pretty lost right now and hope someone can help me with this. Thanks in advance.






