Closed flamendless closed 2 years ago
Here is an example of how to use this new feature:
function love.load(args)
Slab.Initialize(args)
Slab.EnableStats(true) --important
end
function love.update(dt)
Slab.Update(dt)
show = Slab.BeginWindow("test", {Title = "Test"})
Slab.Text("test")
Slab.Text("test")
Slab.Text("test")
Slab.Text("test")
Slab.Text("test")
Slab.Button("test")
Slab.EndWindow()
end
local t = {}
function love.draw()
--this will be not included in the Slab stats
--any drawing called before Slab.draw call will not be included in the Slab stats
love.graphics.print("test0", 256, 120)
Slab.Draw()
--get the stats used by Slab if you want to do anything with it
--this will not include the printed "test0" earlier since it's outside of Slab (before Slab.Draw call)
local d = Slab.GetStats()
--draw more stuff (these are batched by love)
--drawings after Slab.Draw are also not included in Slab stats
love.graphics.print("test1", 256, 128)
love.graphics.print("test2", 256, 134)
love.graphics.print("test3", 256, 140)
love.graphics.print("test4", 256, 146)
--get the stats (this includes the Slab stats)
t = love.graphics.getStats(t)
--this will calculate the love stats (exclude Slab stats)
t = Slab.CalculateStats(t)
--draw to the screen to see the result
local i = 0
for k, v in pairs(t) do
love.graphics.print(k .. " = " .. v, 32, i * 32)
i = i + 1
end
end
This is useful for debugging, when users want to see the result of
love.graphics.getStats()
of their game without Slab stats mixing in the result (this happens when you draw the stats inside of a Slab window.Usage would be (i think):