title: how to fix problem with swap chain creation
body: <p>im learning directx im working on initializing direct3d in my application and all of my HRESULTS are returning S_OK which is a success return code except the last one which involved swap chain creation i have the debug layer enabled so im getting a warning error in the Output Log that says 'OurDevice' could be 0... (OurDevice is the pointer name to my ID3D11Device).. after many hours of scanning through Microsoft Docs and checking and rechecking all my code i cant seem to find out the issue does anyone have a clue ? </p>
  
  <pre><code>#include "dx3dmanager.h"
  #include "Core.h"
  #include &lt;Windows.h&gt;
  #include &lt;d3d11.h&gt;
  #include &lt;d3d11_1.h&gt;
  #include &lt;d3d11_2.h&gt;
  #include &lt;DirectXMath.h&gt;
  #include &lt;dxgi.h&gt;
  
  
  dx3dmanager::dx3dmanager()
  {
  }
  
  
  dx3dmanager::~dx3dmanager()
  {
  }
  
  // this method intitializes the Direct3d version 11 API this 
  initialization method is subject to change with new versions /*
  
  void dx3dmanager::initialize3d(HWND MainWindow)
  
  {
      // declarations for Direct3D feature levels ours will include 
  versions 11-12 unless changed /*
      //declarations for our device(GPU) and device context /*
      UINT creationflags = D3D11_CREATE_DEVICE_DEBUG;
  
      ID3D11Device* OurDevice;
  
      ID3D11DeviceContext* IDeviceContext;
  
      D3D_FEATURE_LEVEL featurelevels[2] =
      {
          D3D_FEATURE_LEVEL_11_0,
          D3D_FEATURE_LEVEL_11_1
  
      };
  
      HRESULT CreateDev;
  
  
      switch (CreateDev) {
      case S_OK: {
  
          MessageBeep(0xFFFFFFFF);
  
      }
  
      }
  
  
       // checks multisampling quality 
  
    HRESULT checkmxquality;
  
      UINT m4xMsaaQuality;
      DXGI_FORMAT dxgi_format = DXGI_FORMAT_R8G8B8A8_UNORM;
      checkmxquality = OurDevice-&gt;CheckMultisampleQualityLevels(dxgi_format, 4, &amp;m4xMsaaQuality);
      assert(m4xMsaaQuality &gt; 0);
  
      switch (checkmxquality) {
  
      case S_OK: {
  
          MessageBeep(0xFFFFFFFF);
  
      }
                    break;
      }
      // descriptions for rendering structs IE:  sampling, format, and swap 
  chain /*
      DXGI_SAMPLE_DESC sampdesc;
      sampdesc.Count = 1;
      sampdesc.Quality = 0;
  
      DXGI_MODE_DESC1 dxmode;
      dxmode.Width = 125;
      dxmode.Height = 125;
      dxmode.Format = dxgi_format;
      dxmode.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
      dxmode.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
      dxmode.RefreshRate.Numerator = 60;
      dxmode.RefreshRate.Denominator = 1;
      dxmode.Stereo = false;
  
      DXGI_SWAP_CHAIN_DESC1 chaindesc;
      chaindesc.Width = 0;
      chaindesc.Height = 0;
      chaindesc.Format = dxgi_format;
      chaindesc.Stereo = false;
      chaindesc.SampleDesc = sampdesc;
      chaindesc.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
      chaindesc.BufferCount = 3;
      chaindesc.SwapEffect = DXGI_SWAP_EFFECT_DISCARD;
      chaindesc.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH| 
  DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE| DXGI_SWAP_CHAIN_FLAG_DISPLAY_ONLY;
      chaindesc.AlphaMode = DXGI_ALPHA_MODE_UNSPECIFIED;
      chaindesc.Scaling = DXGI_SCALING_STRETCH;
      //------------------------------------------------------------------- 
  </code></pre>
  
  <p>-------------------------------/*</p>
  
  <pre><code>    // this is our DXGI interface (DXGI is not a part of direct3d it is a 
  seperate API (COM) /* 
      IDXGIDevice* dxgiDevice = nullptr;
      CreateDev = OurDevice-&gt;QueryInterface(__uuidof(IDXGIDevice), 
  (void**)&amp; dxgiDevice);
      if (SUCCEEDED(CreateDev)) {
  
      MessageBeep(0xFFFFFFFF);
      }
      IDXGIAdapter* dxgiadapter = nullptr;
      CreateDev = dxgiDevice-&gt;GetParent(__uuidof(IDXGIAdapter), (void**)&amp; 
  dxgiadapter);
      if (SUCCEEDED(CreateDev)) {
  
          MessageBeep(0xFFFFFFFF);
      }
      IDXGIFactory2* factory;
      CreateDev = dxgiadapter-&gt;GetParent(__uuidof(IDXGIFactory), (void**)&amp; 
  factory);
      if (SUCCEEDED(CreateDev)) {
  
          MessageBeep(0xFFFFFFFF);
      }
      IDXGISwapChain1* mSwapChain;
      CreateDev = factory-&gt;CreateSwapChainForHwnd(OurDevice, MainWindow, 
  &amp;chaindesc, NULL, NULL, &amp;mSwapChain);
  
      if (FAILED(CreateDev)) {
  
          MessageBeep(0xFFFFFFFF);
      }
  
  
      //------------------------------------------------------------------- 
      -------------------------------/*
  </code></pre>