From 262ef1c5df0717c944b37117ed4528e5ca923a6c Mon Sep 17 00:00:00 2001 From: 4DBug Date: Sat, 17 Oct 2026 06:05:39 -0500 Subject: [PATCH] example: demo window only --- README.md | 2 +- examples/roblox/main.client.luau | 49 ++------------------------------ 2 files changed, 3 insertions(+), 48 deletions(-) diff --git a/README.md b/README.md index d201ae4..5cc4292 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ ImGui.End() ImPlot.ShowDemoWindow(true) ``` -Full LocalScript: `examples/roblox/main.client.luau` (live scrolling sine wave + demo windows). +Full LocalScript: `examples/roblox/main.client.luau` (ImPlot demo window). ## API differences from C++ diff --git a/examples/roblox/main.client.luau b/examples/roblox/main.client.luau index 38456eb..8e562a4 100644 --- a/examples/roblox/main.client.luau +++ b/examples/roblox/main.client.luau @@ -1,4 +1,4 @@ --- Live sine wave (scrolling buffer) + ImPlot / ImGui demo windows. +-- ImPlot demo window. local RS = game:GetService("ReplicatedStorage") local RunService = game:GetService("RunService") local G = require(RS:WaitForChild("ImGui")) @@ -6,58 +6,13 @@ local ImPlot = require(RS:WaitForChild("ImPlot"))(G) require(RS:WaitForChild("ImPlotDemo"))(G, ImPlot) local ImGui = G.ImGui -local MaxPoints = 500 -local Xs, Ys = table.create(MaxPoints, 0), table.create(MaxPoints, 0) -local Count, Offset, Time = 0, 0, 0 -local Frequency = 1 -local ShowImPlotDemo, ShowImGuiDemo = true, false - -local function AddPoint(X, Y) - if Count < MaxPoints then - Count += 1 - Xs[Count], Ys[Count] = X, Y - else - Xs[Offset + 1], Ys[Offset + 1] = X, Y - Offset = (Offset + 1) % MaxPoints - end -end - -local StartClock = os.clock() - -local function RenderDemo() - Time = os.clock() - StartClock - AddPoint(Time, math.sin(Time * Frequency * 2 * math.pi)) - - ImGui.SetNextWindowSize(G.ImVec2(600, 400), G.ImGuiCond.FirstUseEver) - ImGui.Begin("Live Sine") - _, ShowImPlotDemo = ImGui.Checkbox("ImPlot Demo", ShowImPlotDemo) - ImGui.SameLine() - _, ShowImGuiDemo = ImGui.Checkbox("ImGui Demo", ShowImGuiDemo) - Frequency = ImGui.SliderFloat("Frequency", Frequency, 0.1, 5) - if ImPlot.BeginPlot("##Sine", G.ImVec2(-1, -1)) then - ImPlot.SetupAxisLimits(ImPlot.ImAxis.X1, Time - 10, Time, G.ImGuiCond.Always) - ImPlot.SetupAxisLimits(ImPlot.ImAxis.Y1, -1.1, 1.1) - -- ring buffer: Offset (0-based, in elements) via spec, as in the C++ ScrollingBuffer demo - ImPlot.PlotLine("sin", Xs, Ys, Count, { Offset = Offset }) - ImPlot.EndPlot() - end - ImGui.End() - - if ShowImPlotDemo then - ShowImPlotDemo = ImPlot.ShowDemoWindow(ShowImPlotDemo) - end - if ShowImGuiDemo then - ShowImGuiDemo = ImGui.ShowDemoWindow(ShowImGuiDemo) - end -end - ImGui.CreateContext() ImPlot.CreateContext() G.ImGui_ImplRoblox.Init() -- defaults to LocalPlayer.PlayerGui RunService.RenderStepped:Connect(function() G.ImGui_ImplRoblox.NewFrame() ImGui.NewFrame() - RenderDemo() + ImPlot.ShowDemoWindow() ImGui.Render() G.ImGui_ImplRoblox.RenderDrawData(ImGui.GetDrawData()) end)