• Content count

  • Joined

  • Last visited

Community Reputation

102 Neutral

About Rizzmond

  • Rank
  1. I recently started learning D3D11 and have run into trouble initializing it. I'm getting a E_INVALIDARG when calling the CreateSwapChain function. Relevant code is as follows: [CODE] D3D_DRIVER_TYPE md3dDriverType = D3D_DRIVER_TYPE_HARDWARE; // driver type IDXGISwapChain * swap_chain; ID3D11Device* md3dDevice; UINT D3d_Device_Flags = D3d_Device_Flags | D3D11_CREATE_DEVICE_DEBUG; //device flags D3D_FEATURE_LEVEL featureLevel; ID3D11DeviceContext* md3dImmediateContext; HRESULT hr = D3D11CreateDevice( 0, // default adapter md3dDriverType, 0, // no software device D3d_Device_Flags, 0, 0, // default feature level array D3D11_SDK_VERSION, &md3dDevice, &featureLevel, &md3dImmediateContext); DXGI_SWAP_CHAIN_DESC swap_chain_desc; swap_chain_desc.BufferDesc.Width = client_width; // a value of 0 uses current window values swap_chain_desc.BufferDesc.Height = client_height; // a value of 0 uses current window values swap_chain_desc.BufferDesc.RefreshRate.Numerator = 60; swap_chain_desc.BufferDesc.RefreshRate.Denominator = 1; swap_chain_desc.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM; // display format swap_chain_desc.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED; //method the raster uses to create an image on a surface. swap_chain_desc.BufferDesc.Scaling = DXGI_MODE_SCALING_UNSPECIFIED; //how an image is stretched to fit a given monitor's resolution swap_chain_desc.SampleDesc.Count = 4; //4 sub pixels per sample swap_chain_desc.SampleDesc.Quality = m4xMsaaQuality; //msaa quality level swap_chain_desc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT; swap_chain_desc.BufferCount = 1; swap_chain_desc.OutputWindow = window_handle; swap_chain_desc.Windowed = true; swap_chain_desc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD; swap_chain_desc.Flags = 0; // retrieve IDXGIFactory instance used to create device IDXGIDevice* dxgiDevice = 0; check_for_fail(md3dDevice->QueryInterface(__uuidof(IDXGIDevice), (void**)&dxgiDevice)); IDXGIAdapter* dxgiAdapter = 0; check_for_fail(dxgiDevice->GetParent(__uuidof(IDXGIAdapter), (void**)&dxgiAdapter)); IDXGIFactory* dxgiFactory = 0; check_for_fail(dxgiAdapter->GetParent(__uuidof(IDXGIFactory), (void**)&dxgiFactory)); check_for_fail(dxgiFactory->CreateSwapChain(md3dDevice, &swap_chain_desc, &swap_chain)); [/CODE] I can't figure out why the parameters I passed are incorrect. In the remarks for the [url="http://msdn.microsoft.com/en-us/library/windows/desktop/ff476083%28v=vs.85%29.aspx"]CreateDeviceAndSwapChain function[/url]it says "If you set the pAdapter parameter to a non-NULL value and the DriverType parameter to the D3D_DRIVER_TYPE_HARDWARE value, D3D11CreateDeviceAndSwapChain returns an HRESULT of E_INVALIDARG." However, i'm using a null value for the pAdapter parameter (besides the fact i'm not even using that function). Otherwise, I haven't had any luck finding related information. Thanks in advance for help.