|
|
@ -329,7 +329,9 @@ static void ImGui_ImplWGPU_SetupRenderState(ImDrawData* draw_data, WGPURenderPas |
|
|
|
void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder pass_encoder) |
|
|
|
{ |
|
|
|
// Avoid rendering when minimized
|
|
|
|
if (draw_data->DisplaySize.x <= 0.0f || draw_data->DisplaySize.y <= 0.0f) |
|
|
|
int fb_width = (int)(draw_data->DisplaySize.x * draw_data->FramebufferScale.x); |
|
|
|
int fb_height = (int)(draw_data->DisplaySize.y * draw_data->FramebufferScale.y); |
|
|
|
if (fb_width <= 0 || fb_height <= 0 || draw_data->CmdListsCount == 0) |
|
|
|
return; |
|
|
|
|
|
|
|
// FIXME: Assuming that this only gets called once per frame!
|
|
|
@ -448,6 +450,12 @@ void ImGui_ImplWGPU_RenderDrawData(ImDrawData* draw_data, WGPURenderPassEncoder |
|
|
|
// Project scissor/clipping rectangles into framebuffer space
|
|
|
|
ImVec2 clip_min((pcmd->ClipRect.x - clip_off.x) * clip_scale.x, (pcmd->ClipRect.y - clip_off.y) * clip_scale.y); |
|
|
|
ImVec2 clip_max((pcmd->ClipRect.z - clip_off.x) * clip_scale.x, (pcmd->ClipRect.w - clip_off.y) * clip_scale.y); |
|
|
|
|
|
|
|
// Clamp to viewport as wgpuRenderPassEncoderSetScissorRect() won't accept values that are off bounds
|
|
|
|
if (clip_min.x < 0.0f) { clip_min.x = 0.0f; } |
|
|
|
if (clip_min.y < 0.0f) { clip_min.y = 0.0f; } |
|
|
|
if (clip_max.x > fb_width) { clip_max.x = (float)fb_width; } |
|
|
|
if (clip_max.y > fb_height) { clip_max.y = (float)fb_height; } |
|
|
|
if (clip_max.x <= clip_min.x || clip_max.y <= clip_min.y) |
|
|
|
continue; |
|
|
|
|
|
|
|