XNA Creators Club Online
Page 1 of 1 (5 items)
Sort Posts: Previous Next

How to clear only region (like IDirect3DDevice9::Clear)?

Last post 7/17/2009 6:49 AM by Yossi Koren. 4 replies.
  • 7/16/2009 1:01 PM

    How to clear only region (like IDirect3DDevice9::Clear)?

    Hi

    In DirectX9 we could clear region by using IDirect3DDevice9::Clear function. for example:

    D3DRECT rec = {1,1,50,50};

    m_pIDirect3DDevice9->Clear(1, &rec, D3DCLEAR_TARGET, D3DCOLOR_ARGB(255,255,255,0),0 ,0);

    How can we do the same in DirectX 10 ?

    Thanks
    Yossi
  • 7/16/2009 4:26 PM In reply to

    Re: How to clear only region (like IDirect3DDevice9::Clear)?

    use the ID3D10Device::ClearRenderTargetView method, link: http://msdn.microsoft.com/en-us/library/bb173539(VS.85).aspx

    example,

    float color[4] = { 0.5f, 0.5f, 0.5f, 1.0f };
    pDevice->ClearRenderTargetView( pTargetView, color );

    (...)

    pSwapChain->Present( 0, 0 );
  • 7/16/2009 8:16 PM In reply to

    Re: How to clear only region (like IDirect3DDevice9::Clear)?

    It clears ALL the background
    I would like only a region of it.
  • 7/17/2009 1:06 AM In reply to

    Re: How to clear only region (like IDirect3DDevice9::Clear)?

    I believe the way D3D10 wants you to do it is to draw a screen-aligned quad to clear a portion of the render target. I don't even think that ClearRenderTargetView is going to apply here because first you'd have to create a render target view for the back buffer. A render target view can't be a plain surface, it has to be a resource (and surfaces aren't resources). So you'd have to do quite a bit of work in order to use ClearRenderTargetView. Its much simpler to just draw geometry to clear a portion of a render target.

  • 7/17/2009 6:49 AM In reply to

    Re: How to clear only region (like IDirect3DDevice9::Clear)?

    Thanks  :)
Page 1 of 1 (5 items) Previous Next