Skip to content

Commit 82fdd70

Browse files
authored
Update FAQ.md
1 parent ccf94e2 commit 82fdd70

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

docs/FAQ.md

+15-2
Original file line numberDiff line numberDiff line change
@@ -178,8 +178,21 @@ Rectangles provided by Dear ImGui are defined as
178178
`(x1=left,y1=top,x2=right,y2=bottom)`
179179
and **NOT** as
180180
`(x1,y1,width,height)`.
181-
Refer to rendering backends in the [examples/](https://github.com/ocornut/imgui/tree/master/examples) folder for references of how to handle the `ClipRect` field.
182-
181+
Refer to rendering backends in the [backends/](https://github.com/ocornut/imgui/tree/master/backends) folder for references of how to handle the `ClipRect` field.
182+
For example, the [DirectX11 backend](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp) does this:
183+
```cpp
184+
// Project scissor/clipping rectangles into framebuffer space
185+
ImVec2 clip_off = draw_data->DisplayPos;
186+
ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y);
187+
ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y);
188+
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
189+
continue;
190+
191+
// Apply scissor/clipping rectangle
192+
const D3D11_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, (LONG)clip_max.y };
193+
ctx->RSSetScissorRects(1, &r);
194+
```
195+
183196
##### [Return to Index](#index)
184197

185198
---

0 commit comments

Comments
 (0)