Roblox backend: optional SetBusyRenderRate (lower redraw rate while scrolling/resizing/moving)
This commit is contained in:
@@ -1 +1 @@
|
|||||||
[[12, "imgui.lua"], [13795, "imgui_demo.lua"], [14728, "imgui_demo_2.lua"], [17803, "imgui_demo_apps.lua"], [19062, "imgui_demo_tools.lua"], [20388, "imgui_demo_widgets.lua"], [22312, "imgui_docking.lua"], [25440, "imgui_dragdrop.lua"], [25732, "imgui_draw.lua"], [30979, "imgui_h.lua"], [33153, "imgui_impl_roblox.lua"], [34121, "imgui_impl_roblox_fonts.lua"], [40524, "imgui_internal.lua"], [43696, "imgui_tables.lua"], [48043, "imgui_tabs.lua"], [49210, "imgui_widgets.lua"], [57744, "imstb_rectpack.lua"], [58190, "imstb_textedit.lua"], [59431, "imstb_truetype.lua"], [61899, "imstd_minstdio.lua"]]
|
[[12, "imgui.lua"], [13795, "imgui_demo.lua"], [14728, "imgui_demo_2.lua"], [17803, "imgui_demo_apps.lua"], [19062, "imgui_demo_tools.lua"], [20388, "imgui_demo_widgets.lua"], [22312, "imgui_docking.lua"], [25440, "imgui_dragdrop.lua"], [25732, "imgui_draw.lua"], [30979, "imgui_h.lua"], [33153, "imgui_impl_roblox.lua"], [34140, "imgui_impl_roblox_fonts.lua"], [40543, "imgui_internal.lua"], [43715, "imgui_tables.lua"], [48062, "imgui_tabs.lua"], [49229, "imgui_widgets.lua"], [57763, "imstb_rectpack.lua"], [58209, "imstb_textedit.lua"], [59450, "imstb_truetype.lua"], [61918, "imstd_minstdio.lua"]]
|
||||||
+23
-3
@@ -33718,10 +33718,23 @@ function ImGui_ImplRoblox_RenderDrawData(draw_data)
|
|||||||
PE()
|
PE()
|
||||||
|
|
||||||
-- Render rate cap: textures are always updated (imgui expects it), tiles only at bd.RenderRate Hz
|
-- Render rate cap: textures are always updated (imgui expects it), tiles only at bd.RenderRate Hz
|
||||||
if bd.RenderRate > 0 then
|
-- Optional lower cap while scrolling / resizing / moving a window (SetBusyRenderRate, off by default)
|
||||||
|
local rate = bd.RenderRate
|
||||||
|
if bd.BusyRenderRate > 0 then
|
||||||
|
local g = ImGui.GetCurrentContext()
|
||||||
|
local busy = g.WheelingWindow ~= nil or g.MovingWindow ~= nil -- (io.MouseWheel is already cleared by EndFrame)
|
||||||
|
if not busy and g.ActiveId ~= 0 then
|
||||||
|
local w = g.ActiveIdWindow
|
||||||
|
local cur = g.MouseCursor -- ResizeAll..ResizeNWSE while a resize grip/border is held
|
||||||
|
busy = (cur >= ImGuiMouseCursor.ResizeAll and cur <= ImGuiMouseCursor.ResizeNWSE)
|
||||||
|
or (w ~= nil and (g.ActiveId == ImGui.GetWindowScrollbarID(w, ImGuiAxis.X) or g.ActiveId == ImGui.GetWindowScrollbarID(w, ImGuiAxis.Y)))
|
||||||
|
end
|
||||||
|
if busy and (rate <= 0 or bd.BusyRenderRate < rate) then rate = bd.BusyRenderRate end
|
||||||
|
end
|
||||||
|
if rate > 0 then
|
||||||
local now = os.clock()
|
local now = os.clock()
|
||||||
if now + 0.002 < bd.NextRender then PE(); return end
|
if now + 0.002 < bd.NextRender then PE(); return end
|
||||||
bd.NextRender = math.max(bd.NextRender + 1 / bd.RenderRate, now)
|
bd.NextRender = math.max(bd.NextRender + 1 / rate, now)
|
||||||
end
|
end
|
||||||
|
|
||||||
local sw, sh = floor(draw_data.DisplaySize.x), floor(draw_data.DisplaySize.y)
|
local sw, sh = floor(draw_data.DisplaySize.x), floor(draw_data.DisplaySize.y)
|
||||||
@@ -33980,7 +33993,7 @@ function ImGui_ImplRoblox_Init(parent, render_scale)
|
|||||||
local bd = {
|
local bd = {
|
||||||
Time = os.clock(), Gui = gui, Connections = {},
|
Time = os.clock(), Gui = gui, Connections = {},
|
||||||
Textures = {}, TextureCount = 0, MouseX = -1, MouseY = -1,
|
Textures = {}, TextureCount = 0, MouseX = -1, MouseY = -1,
|
||||||
Layers = {}, FrameNo = 0, Scale = render_scale or 1, TilesActive = false, RenderRate = 60, NextRender = 0, LastPrimCount = 0, ForceRedraw = true,
|
Layers = {}, FrameNo = 0, Scale = render_scale or 1, TilesActive = false, RenderRate = 60, BusyRenderRate = 0, NextRender = 0, LastPrimCount = 0, ForceRedraw = true,
|
||||||
}
|
}
|
||||||
io.BackendPlatformUserData = bd
|
io.BackendPlatformUserData = bd
|
||||||
|
|
||||||
@@ -34090,6 +34103,11 @@ function ImGui_ImplRoblox_SetRenderRate(hz)
|
|||||||
ImGui_ImplRoblox_GetBackendData().RenderRate = hz or 0
|
ImGui_ImplRoblox_GetBackendData().RenderRate = hz or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Optional: max tile redraws per second while scrolling, resizing or moving a window (0 = off, the default)
|
||||||
|
function ImGui_ImplRoblox_SetBusyRenderRate(hz)
|
||||||
|
ImGui_ImplRoblox_GetBackendData().BusyRenderRate = hz or 0
|
||||||
|
end
|
||||||
|
|
||||||
--- Toggle MicroProfiler labels (debug.profilebegin) for the backend
|
--- Toggle MicroProfiler labels (debug.profilebegin) for the backend
|
||||||
function ImGui_ImplRoblox_SetProfiling(enabled) profiling = enabled and true or false end
|
function ImGui_ImplRoblox_SetProfiling(enabled) profiling = enabled and true or false end
|
||||||
local function ImGui_ImplRoblox_IsProfiling() return profiling end
|
local function ImGui_ImplRoblox_IsProfiling() return profiling end
|
||||||
@@ -34110,6 +34128,7 @@ ImGui_ImplRoblox = {
|
|||||||
AddFile = ImGui_ImplRoblox_AddFile,
|
AddFile = ImGui_ImplRoblox_AddFile,
|
||||||
SetRenderScale = ImGui_ImplRoblox_SetRenderScale,
|
SetRenderScale = ImGui_ImplRoblox_SetRenderScale,
|
||||||
SetRenderRate = ImGui_ImplRoblox_SetRenderRate,
|
SetRenderRate = ImGui_ImplRoblox_SetRenderRate,
|
||||||
|
SetBusyRenderRate = ImGui_ImplRoblox_SetBusyRenderRate,
|
||||||
SetProfiling = ImGui_ImplRoblox_SetProfiling,
|
SetProfiling = ImGui_ImplRoblox_SetProfiling,
|
||||||
IsProfiling = ImGui_ImplRoblox_IsProfiling,
|
IsProfiling = ImGui_ImplRoblox_IsProfiling,
|
||||||
}
|
}
|
||||||
@@ -62511,6 +62530,7 @@ return {
|
|||||||
ImGui_ImplRoblox_Init = ImGui_ImplRoblox_Init,
|
ImGui_ImplRoblox_Init = ImGui_ImplRoblox_Init,
|
||||||
ImGui_ImplRoblox_NewFrame = ImGui_ImplRoblox_NewFrame,
|
ImGui_ImplRoblox_NewFrame = ImGui_ImplRoblox_NewFrame,
|
||||||
ImGui_ImplRoblox_RenderDrawData = ImGui_ImplRoblox_RenderDrawData,
|
ImGui_ImplRoblox_RenderDrawData = ImGui_ImplRoblox_RenderDrawData,
|
||||||
|
ImGui_ImplRoblox_SetBusyRenderRate = ImGui_ImplRoblox_SetBusyRenderRate,
|
||||||
ImGui_ImplRoblox_SetProfiling = ImGui_ImplRoblox_SetProfiling,
|
ImGui_ImplRoblox_SetProfiling = ImGui_ImplRoblox_SetProfiling,
|
||||||
ImGui_ImplRoblox_SetRenderRate = ImGui_ImplRoblox_SetRenderRate,
|
ImGui_ImplRoblox_SetRenderRate = ImGui_ImplRoblox_SetRenderRate,
|
||||||
ImGui_ImplRoblox_SetRenderScale = ImGui_ImplRoblox_SetRenderScale,
|
ImGui_ImplRoblox_SetRenderScale = ImGui_ImplRoblox_SetRenderScale,
|
||||||
|
|||||||
@@ -566,10 +566,23 @@ function ImGui_ImplRoblox_RenderDrawData(draw_data)
|
|||||||
PE()
|
PE()
|
||||||
|
|
||||||
-- Render rate cap: textures are always updated (imgui expects it), tiles only at bd.RenderRate Hz
|
-- Render rate cap: textures are always updated (imgui expects it), tiles only at bd.RenderRate Hz
|
||||||
if bd.RenderRate > 0 then
|
-- Optional lower cap while scrolling / resizing / moving a window (SetBusyRenderRate, off by default)
|
||||||
|
local rate = bd.RenderRate
|
||||||
|
if bd.BusyRenderRate > 0 then
|
||||||
|
local g = ImGui.GetCurrentContext()
|
||||||
|
local busy = g.WheelingWindow ~= nil or g.MovingWindow ~= nil -- (io.MouseWheel is already cleared by EndFrame)
|
||||||
|
if not busy and g.ActiveId ~= 0 then
|
||||||
|
local w = g.ActiveIdWindow
|
||||||
|
local cur = g.MouseCursor -- ResizeAll..ResizeNWSE while a resize grip/border is held
|
||||||
|
busy = (cur >= ImGuiMouseCursor.ResizeAll and cur <= ImGuiMouseCursor.ResizeNWSE)
|
||||||
|
or (w ~= nil and (g.ActiveId == ImGui.GetWindowScrollbarID(w, ImGuiAxis.X) or g.ActiveId == ImGui.GetWindowScrollbarID(w, ImGuiAxis.Y)))
|
||||||
|
end
|
||||||
|
if busy and (rate <= 0 or bd.BusyRenderRate < rate) then rate = bd.BusyRenderRate end
|
||||||
|
end
|
||||||
|
if rate > 0 then
|
||||||
local now = os.clock()
|
local now = os.clock()
|
||||||
if now + 0.002 < bd.NextRender then PE(); return end
|
if now + 0.002 < bd.NextRender then PE(); return end
|
||||||
bd.NextRender = math.max(bd.NextRender + 1 / bd.RenderRate, now)
|
bd.NextRender = math.max(bd.NextRender + 1 / rate, now)
|
||||||
end
|
end
|
||||||
|
|
||||||
local sw, sh = floor(draw_data.DisplaySize.x), floor(draw_data.DisplaySize.y)
|
local sw, sh = floor(draw_data.DisplaySize.x), floor(draw_data.DisplaySize.y)
|
||||||
@@ -828,7 +841,7 @@ function ImGui_ImplRoblox_Init(parent, render_scale)
|
|||||||
local bd = {
|
local bd = {
|
||||||
Time = os.clock(), Gui = gui, Connections = {},
|
Time = os.clock(), Gui = gui, Connections = {},
|
||||||
Textures = {}, TextureCount = 0, MouseX = -1, MouseY = -1,
|
Textures = {}, TextureCount = 0, MouseX = -1, MouseY = -1,
|
||||||
Layers = {}, FrameNo = 0, Scale = render_scale or 1, TilesActive = false, RenderRate = 60, NextRender = 0, LastPrimCount = 0, ForceRedraw = true,
|
Layers = {}, FrameNo = 0, Scale = render_scale or 1, TilesActive = false, RenderRate = 60, BusyRenderRate = 0, NextRender = 0, LastPrimCount = 0, ForceRedraw = true,
|
||||||
}
|
}
|
||||||
io.BackendPlatformUserData = bd
|
io.BackendPlatformUserData = bd
|
||||||
|
|
||||||
@@ -938,6 +951,11 @@ function ImGui_ImplRoblox_SetRenderRate(hz)
|
|||||||
ImGui_ImplRoblox_GetBackendData().RenderRate = hz or 0
|
ImGui_ImplRoblox_GetBackendData().RenderRate = hz or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Optional: max tile redraws per second while scrolling, resizing or moving a window (0 = off, the default)
|
||||||
|
function ImGui_ImplRoblox_SetBusyRenderRate(hz)
|
||||||
|
ImGui_ImplRoblox_GetBackendData().BusyRenderRate = hz or 0
|
||||||
|
end
|
||||||
|
|
||||||
--- Toggle MicroProfiler labels (debug.profilebegin) for the backend
|
--- Toggle MicroProfiler labels (debug.profilebegin) for the backend
|
||||||
function ImGui_ImplRoblox_SetProfiling(enabled) profiling = enabled and true or false end
|
function ImGui_ImplRoblox_SetProfiling(enabled) profiling = enabled and true or false end
|
||||||
local function ImGui_ImplRoblox_IsProfiling() return profiling end
|
local function ImGui_ImplRoblox_IsProfiling() return profiling end
|
||||||
@@ -958,6 +976,7 @@ ImGui_ImplRoblox = {
|
|||||||
AddFile = ImGui_ImplRoblox_AddFile,
|
AddFile = ImGui_ImplRoblox_AddFile,
|
||||||
SetRenderScale = ImGui_ImplRoblox_SetRenderScale,
|
SetRenderScale = ImGui_ImplRoblox_SetRenderScale,
|
||||||
SetRenderRate = ImGui_ImplRoblox_SetRenderRate,
|
SetRenderRate = ImGui_ImplRoblox_SetRenderRate,
|
||||||
|
SetBusyRenderRate = ImGui_ImplRoblox_SetBusyRenderRate,
|
||||||
SetProfiling = ImGui_ImplRoblox_SetProfiling,
|
SetProfiling = ImGui_ImplRoblox_SetProfiling,
|
||||||
IsProfiling = ImGui_ImplRoblox_IsProfiling,
|
IsProfiling = ImGui_ImplRoblox_IsProfiling,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -75,6 +75,7 @@ end
|
|||||||
|
|
||||||
ImGui_ImplRoblox.Init(nil, render_scale)
|
ImGui_ImplRoblox.Init(nil, render_scale)
|
||||||
ImGui_ImplRoblox.SetRenderRate(60) -- tile redraws per second; imgui logic + your code still run every frame
|
ImGui_ImplRoblox.SetRenderRate(60) -- tile redraws per second; imgui logic + your code still run every frame
|
||||||
|
-- ImGui_ImplRoblox.SetBusyRenderRate(30) -- optional: lower redraw rate while scrolling/resizing/moving windows
|
||||||
ImGui_ImplRoblox.SetProfiling(true) -- MicroProfiler (Ctrl+F6) labels; turn off when not profiling
|
ImGui_ImplRoblox.SetProfiling(true) -- MicroProfiler (Ctrl+F6) labels; turn off when not profiling
|
||||||
|
|
||||||
local function P(name) if ImGui_ImplRoblox.IsProfiling() then debug.profilebegin(name) end end
|
local function P(name) if ImGui_ImplRoblox.IsProfiling() then debug.profilebegin(name) end end
|
||||||
|
|||||||
Reference in New Issue
Block a user