cimgui-love
cimgui-love
LÖVE module for Dear ImGui obtained by wrapping cimgui (programmatically generated C-api) using LuaJIT FFI.
The wrappers are generated automatically (like cimgui itself) and can be easily updated for new versions of Dear ImGui. Currently based on version 1.90 (docking branch) of Dear ImGui and LÖVE 11.3.
Links
Example of usage
See README on the git repository for more detailed instructions.
-- Make sure the shared library can be found through package.cpath before loading the module.
-- For example, if you put it in the LÖVE save directory, you could do something like this:
local lib_path = love.filesystem.getSaveDirectory() .. "/libraries"
local extension = jit.os == "Windows" and "dll" or jit.os == "Linux" and "so" or jit.os == "OSX" and "dylib"
package.cpath = string.format("%s;%s/?.%s", package.cpath, lib_path, extension)
local imgui = require "cimgui" -- cimgui is the folder containing the Lua module (the "src" folder in the github repository)
love.load = function()
imgui.love.Init() -- or imgui.love.Init("RGBA32") or imgui.love.Init("Alpha8")
end
love.draw = function()
-- example window
imgui.ShowDemoWindow()
-- code to render imgui
imgui.Render()
imgui.love.RenderDrawLists()
end
love.update = function(dt)
imgui.love.Update(dt)
imgui.NewFrame()
end
love.mousemoved = function(x, y, ...)
imgui.love.MouseMoved(x, y)
if not imgui.love.GetWantCaptureMouse() then
-- your code here
end
end
love.mousepressed = function(x, y, button, ...)
imgui.love.MousePressed(button)
if not imgui.love.GetWantCaptureMouse() then
-- your code here
end
end
love.mousereleased = function(x, y, button, ...)
imgui.love.MouseReleased(button)
if not imgui.love.GetWantCaptureMouse() then
-- your code here
end
end
love.wheelmoved = function(x, y)
imgui.love.WheelMoved(x, y)
if not imgui.love.GetWantCaptureMouse() then
-- your code here
end
end
love.keypressed = function(key, ...)
imgui.love.KeyPressed(key)
if not imgui.love.GetWantCaptureKeyboard() then
-- your code here
end
end
love.keyreleased = function(key, ...)
imgui.love.KeyReleased(key)
if not imgui.love.GetWantCaptureKeyboard() then
-- your code here
end
end
love.textinput = function(t)
imgui.love.TextInput(t)
if imgui.love.GetWantCaptureKeyboard() then
-- your code here
end
end
love.quit = function()
return imgui.love.Shutdown()
end
-- for gamepad support also add the following:
love.joystickadded = function(joystick)
imgui.love.JoystickAdded(joystick)
-- your code here
end
love.joystickremoved = function(joystick)
imgui.love.JoystickRemoved()
-- your code here
end
love.gamepadpressed = function(joystick, button)
imgui.love.GamepadPressed(button)
-- your code here
end
love.gamepadreleased = function(joystick, button)
imgui.love.GamepadReleased(button)
-- your code here
end
-- choose threshold for considering analog controllers active, defaults to 0 if unspecified
local threshold = 0.2
love.gamepadaxis = function(joystick, axis, value)
imgui.love.GamepadAxis(axis, value, threshold)
-- your code here
end
Other Languages
Dansk –
Deutsch –
English –
Español –
Français –
Indonesia –
Italiano –
Lietuviškai –
Magyar –
Nederlands –
Polski –
Português –
Română –
Slovenský –
Suomi –
Svenska –
Türkçe –
Česky –
Ελληνικά –
Български –
Русский –
Српски –
Українська –
עברית –
ไทย –
日本語 –
正體中文 –
简体中文 –
Tiếng Việt –
한국어
More info