Skip to content

Commit

Permalink
adjust RdRenderer
Browse files Browse the repository at this point in the history
  • Loading branch information
pkdawson committed Nov 30, 2022
1 parent 5662f0e commit 152b9b1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions addons/imgui-godot/ImGuiGodot/InternalRdRenderer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,16 +166,18 @@ public void CloseViewport(Viewport vp)

public void RenderDrawData(Viewport vp, ImDrawDataPtr drawData)
{
if (drawData.CmdListsCount == 0)
return;

#if IMGUI_GODOT_DEV
RD.DrawCommandBeginLabel("ImGui", Colors.Purple);
#endif
RID fb = GetFramebuffer(vp);

int vertSize = Marshal.SizeOf<ImDrawVert>();

var window = (GodotImGuiWindow)GCHandle.FromIntPtr(drawData.OwnerViewport.PlatformHandle).Target;
Transform2D transform = window.Xform;
if (transform == Transform2D.Identity)
transform = Transform2D.Identity.Translated(window.GetWindowPos()).Inverse(); ;

_scale[0] = 2.0f / drawData.DisplaySize.X;
_scale[1] = 2.0f / drawData.DisplaySize.Y;

Expand Down Expand Up @@ -298,11 +300,13 @@ public void RenderDrawData(Viewport vp, ImDrawDataPtr drawData)
RD.DrawListBindIndexArray(dl, idxArray);
RD.DrawListBindVertexArray(dl, vtxArray);

RD.DrawListEnableScissor(dl, new Rect2(
var clipRect = new Rect2(
drawCmd.ClipRect.X,
drawCmd.ClipRect.Y,
drawCmd.ClipRect.Z - drawCmd.ClipRect.X,
drawCmd.ClipRect.W - drawCmd.ClipRect.Y));
drawCmd.ClipRect.W - drawCmd.ClipRect.Y);
clipRect.Position += transform.origin;
RD.DrawListEnableScissor(dl, clipRect);

RD.DrawListDraw(dl, true, 1);

Expand Down

0 comments on commit 152b9b1

Please sign in to comment.