Closed Jarodwr closed 3 years ago
To pass a bool*
you can use the following LuaJIT workaround:
-- create a bool array with 1 element, which you can use as a pointer to the allocated first element
local bool_p = ffi.new("bool[1]")
bool_p[0] = true
-- bool_p is the pointer, use bool_p[0] to dereference it.
Doesn't seem to be working.
local myTest
love.load = function()
love.window.setMode(1920, 1080)
imgui.love.Init() -- or imgui.love.Init("RGBA32") or imgui.love.Init("Alpha8")
myTest = ffi.new("bool[1]")
myTest[0] = false
end
love.draw = function()
-- example window
imgui.ShowDemoWindow()
imgui.Begin("Hello", myTest)
if imgui.Button("My Button") then
myTest[0] = false
end
imgui.End()
-- code to render imgui
love.graphics.setColor(1,1,1,1)
imgui.Render()
imgui.love.RenderDrawLists()
end
Sorry, it's working. I just got the structure wrong. This is the correct code:
local myTest
love.load = function()
love.window.setMode(1920, 1080)
imgui.love.Init() -- or imgui.love.Init("RGBA32") or imgui.love.Init("Alpha8")
myTest = ffi.new("bool[1]")
myTest[0] = true
end
love.draw = function()
-- example window
imgui.ShowDemoWindow()
if myTest[0] then --<-- the correct structure
imgui.Begin("Hello", myTest)
if imgui.Button("My Button") then
myTest[0] = false
end
imgui.End()
end
-- code to render imgui
love.graphics.setColor(1,1,1,1)
imgui.Render()
imgui.love.RenderDrawLists()
end
I'm trying to use igBegin and I'm not sure how to add a bool*