1
0
mirror of https://github.com/ocornut/imgui.git synced 2024-11-28 09:30:56 +01:00

Update FAQ.md

This commit is contained in:
omar 2023-01-13 17:27:44 +01:00 committed by GitHub
parent ccf94e2e6e
commit 82fdd7018d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -178,7 +178,20 @@ Rectangles provided by Dear ImGui are defined as
`(x1=left,y1=top,x2=right,y2=bottom)` `(x1=left,y1=top,x2=right,y2=bottom)`
and **NOT** as and **NOT** as
`(x1,y1,width,height)`. `(x1,y1,width,height)`.
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. 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.
For example, the [DirectX11 backend](https://github.com/ocornut/imgui/blob/master/backends/imgui_impl_dx11.cpp) does this:
```cpp
// Project scissor/clipping rectangles into framebuffer space
ImVec2 clip_off = draw_data->DisplayPos;
ImVec2 clip_min(pcmd->ClipRect.x - clip_off.x, pcmd->ClipRect.y - clip_off.y);
ImVec2 clip_max(pcmd->ClipRect.z - clip_off.x, pcmd->ClipRect.w - clip_off.y);
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y)
continue;
// Apply scissor/clipping rectangle
const D3D11_RECT r = { (LONG)clip_min.x, (LONG)clip_min.y, (LONG)clip_max.x, (LONG)clip_max.y };
ctx->RSSetScissorRects(1, &r);
```
##### [Return to Index](#index) ##### [Return to Index](#index)