Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I actually fought this problem a lot during last week - but I've got it all working! Here is a list of things you should know/do to make it all work:</p> <ul> <li>Check the surface requirements for a GetDC method to work here: <a href="http://msdn.microsoft.com/en-us/library/windows/desktop/ff471345(v=vs.85).aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/windows/desktop/ff471345(v=vs.85).aspx</a> </li> </ul> <blockquote> <p>Keep the following in mind when using this method:</p> <p>•You must create the surface by using the D3D11_RESOURCE_MISC_GDI_COMPATIBLE flag for a surface or by using the DXGI_SWAP_CHAIN_FLAG_GDI_COMPATIBLE flag for swap chains, otherwise this method fails.</p> <p>•You must release the device and call the IDXGISurface1::ReleaseDC method before you issue any new Direct3D commands.</p> <p>•This method fails if an outstanding DC has already been created by this method.</p> <p>•The format for the surface or swap chain must be DXGI_FORMAT_B8G8R8A8_UNORM_SRGB or DXGI_FORMAT_B8G8R8A8_UNORM.</p> <p>•On GetDC, the render target in the output merger of the Direct3D pipeline is unbound from the surface. You must call the ID3D11DeviceContext::OMSetRenderTargets method on the device prior to Direct3D rendering after GDI rendering.</p> <p>•Prior to resizing buffers you must release all outstanding DCs.</p> </blockquote> <ul> <li><p>If you're going to use it in the back buffer, remember to re-bind render target <strong>after</strong> you've called ReleaseDC. It is not neccessary to manually unbind RT before calling GetDC as this method does that for you.</p></li> <li><p>You can not use <strong>any</strong> Direct3D drawing between GetDC() and ReleaseDC() calls as the surface is excusively locked out by DXGI for GDI. However you can mix GDI and D3D rendering provided that you call GetDC()/ReleaseDC() every time you need to use GDI, before moving on to D3D.</p></li> <li><p>This last bit may sounds easy, but you'd be surprised how many developers fall into this issue - when you draw with GDI on the back buffer, remember that this is the <strong>back</strong> buffer, not a framebuffer, so in order to actually see what you've drawn, you have to re-bind RT to OM and call swapChain->Present() method so the backbuffer will become a framebuffer and its contents will be displayed on the screen.</p></li> </ul>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload