在 DirectX 10 中清除單個視口 (Clear single viewport in DirectX 10)


問題描述

在 DirectX 10 中清除單個視口 (Clear single viewport in DirectX 10)

I am preparing to start on a C++ DirectX 10 application that will consist of multiple "panels" to display different types of information.  I have had some success experimenting with multiple viewports on one RenderTargetView.  However, I cannot find a definitive answer regarding how to clear a single viewport at a time.  These panels (viewports) in my application will overlap in some areas, so I would like to be able to draw them from "bottom to top", clearing each viewport as I go so the drawing from lower panels doesn't show through on the higher ones.  In DirectX 9, it seems that there was a Clear() method of the device object that would clear only the currently set viewport.  DirectX 10 uses ClearRenderTargetView(), which clears the entire drawing area, and I cannot find any other option that is equivalent to the way DirectX 9 did it.

Is there a way in DirectX 10 to clear only a viewport/rectangle within the drawing area?  One person speculated that the only way may be to draw a quad in that space.  It seems that another possibility would be to have a seprate RenderTargetView for each panel, but I would like to avoid that as it requires other redundant resources, such as a separate depth/stencil buffers (unless that is a misunderstanding on my part).

Any help will be greatly appreciated!  Thanks!


參考解法

方法 1:

I would recommend using one render target per "viewport", and compositing them together using quads for the final view. I know of no way to scissor a clear in DX 10.

Also, according to the article here, "An array of render-target views may be passed into ID3D10Device::OMSetRenderTargets, however all of those render-target views will correspond to a single depth stencil view."

Hope this helps.

方法 2:

Could you not just create a shader together with the appropriate blendstate settings and a square mesh (or other shape of mesh) and use it to clear the area where you want to clear? I haven't tried this but I think it can be done.

(by Tim CoolmanAniKarl Hansson)

參考文件

  1. Clear single viewport in DirectX 10 (CC BY-SA 3.0/4.0)

#directx-10 #viewport #directx






相關問題

D3D10 (DirectX10) 全屏性能問題 (D3D10 (DirectX10) fullscreen performance issue)

directx10 中的精靈和紋理過濾 (Sprites in directx10 and texture filtering)

Firemonkey 中的 DirectX10 支持(非 10.1) (DirectX10 support in Firemonkey (not 10.1))

錯誤 LNK2019 Directx10 VC++2010 (Error LNK2019 Directx10 VC++2010)

管理 HLSL 效果 (Managing HLSL effects)

D3DX10CreateTextureFromFile 返回未知錯誤 (D3DX10CreateTextureFromFile returns unknown error)

使用 HLSL 變量分配 struct C++ (Assign struct C++ with HLSL variable)

ID3DX10Mesh::CloneMesh (ID3DX10Mesh::CloneMesh)

在 DirectX 10 中清除單個視口 (Clear single viewport in DirectX 10)

Visual c++ DirectX 編譯錯誤 (Visual c++ DirectX compilation error)

將 ID3D11Texture2D 轉換為內存緩衝區 (Convert ID3D11Texture2D into a memory buffer)

DirectX 10.1 / C++:如何通過 ID3D10Resource* 紋理在精靈上渲染文本? (DirectX 10.1 / C++: How to render text on sprite over ID3D10Resource* textures?)







留言討論