title: How do I clear a Direct2D render target to fully transparent
body: <p>I'm trying to <strong>draw semi-transparent rectangles on an invisible HWND</strong>. However, clearing the window with <code>ID2D1HwndRenderTarget::Clear</code> just makes the entire window black, so when I draw rectangles on top, they look semi-black.</p>
  <p>If I don't Clear() and don't draw, then the window is invisible, as it should be. Clear() is the culprit here; however if I don't use it then painting messes up pretty badly.</p>
  <p>Here's the code I'm using in my WindowProc:</p>
  <pre><code>case WM_PAINT:
      // Begin drawing
      pRenderTarget-&gt;BeginDraw();
      pRenderTarget-&gt;SetTransform(D2D1::Matrix3x2F::Identity());
  
      // Clear the window
      pRenderTarget-&gt;Clear();
  
      // Paint the panel and its children
      D2DSurface()-&gt;StartPainting();
      {
          D2DSurface()-&gt;PaintTraverse(panel);
      }
      D2DSurface()-&gt;FinishPainting();
  
      // Finish drawing
      HRESULT hr = plat-&gt;pRenderTarget-&gt;EndDraw();
  </code></pre>
  <p>Thanks in advance!</p>