Difference between revisions of "cimgui-love"
(→Other Languages) |
(→Links) |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
{{#set:Keyword=GUI}} | {{#set:Keyword=GUI}} | ||
{{#set:LOVE Min Version=11.3}} | {{#set:LOVE Min Version=11.3}} | ||
− | {{#set:LOVE Version=11. | + | {{#set:LOVE Version=11.4}} |
{{#set:Standalone_Lua_Module=No (LuaJIT FFI wrapper to cimgui shared library)}} | {{#set:Standalone_Lua_Module=No (LuaJIT FFI wrapper to cimgui shared library)}} | ||
[[Category:Libraries]] | [[Category:Libraries]] | ||
Line 11: | Line 11: | ||
The wrappers are generated automatically (like cimgui itself) and can be easily updated for new versions of Dear ImGui. | The wrappers are generated automatically (like cimgui itself) and can be easily updated for new versions of Dear ImGui. | ||
− | Currently based on version 1. | + | Currently based on version 1.90 (docking branch) of Dear ImGui and LÖVE 11.3. |
== Links == | == Links == | ||
− | *[https:// | + | *[https://codeberg.org/apicici/cimgui-love git repository] |
*[https://love2d.org/forums/viewtopic.php?f=5&t=91307 forum thread] | *[https://love2d.org/forums/viewtopic.php?f=5&t=91307 forum thread] | ||
− | *[https:// | + | *[https://codeberg.org/apicici/cimgui-love/releases pre-built binaries] |
== Example of usage == | == Example of usage == | ||
− | See [https:// | + | See [https://codeberg.org/apicici/cimgui-love/src/branch/master/README.md README on the git repository] for more detailed instructions. |
<source lang="lua"> | <source lang="lua"> | ||
Line 31: | Line 31: | ||
love.load = function() | love.load = function() | ||
− | imgui.Init() | + | imgui.love.Init() -- or imgui.love.Init("RGBA32") or imgui.love.Init("Alpha8") |
end | end | ||
Line 40: | Line 40: | ||
-- code to render imgui | -- code to render imgui | ||
imgui.Render() | imgui.Render() | ||
− | imgui.RenderDrawLists() | + | imgui.love.RenderDrawLists() |
end | end | ||
love.update = function(dt) | love.update = function(dt) | ||
− | imgui.Update(dt) | + | imgui.love.Update(dt) |
imgui.NewFrame() | imgui.NewFrame() | ||
end | end | ||
love.mousemoved = function(x, y, ...) | love.mousemoved = function(x, y, ...) | ||
− | imgui.MouseMoved(x, y) | + | imgui.love.MouseMoved(x, y) |
− | if not imgui.GetWantCaptureMouse() then | + | if not imgui.love.GetWantCaptureMouse() then |
-- your code here | -- your code here | ||
end | end | ||
Line 56: | Line 56: | ||
love.mousepressed = function(x, y, button, ...) | love.mousepressed = function(x, y, button, ...) | ||
− | imgui.MousePressed(button) | + | imgui.love.MousePressed(button) |
− | if not imgui.GetWantCaptureMouse() then | + | if not imgui.love.GetWantCaptureMouse() then |
-- your code here | -- your code here | ||
end | end | ||
Line 63: | Line 63: | ||
love.mousereleased = function(x, y, button, ...) | love.mousereleased = function(x, y, button, ...) | ||
− | imgui.MouseReleased(button) | + | imgui.love.MouseReleased(button) |
− | if not imgui.GetWantCaptureMouse() then | + | if not imgui.love.GetWantCaptureMouse() then |
-- your code here | -- your code here | ||
end | end | ||
Line 70: | Line 70: | ||
love.wheelmoved = function(x, y) | love.wheelmoved = function(x, y) | ||
− | imgui.WheelMoved(x, y) | + | imgui.love.WheelMoved(x, y) |
− | if not imgui.GetWantCaptureMouse() then | + | if not imgui.love.GetWantCaptureMouse() then |
-- your code here | -- your code here | ||
end | end | ||
Line 77: | Line 77: | ||
love.keypressed = function(key, ...) | love.keypressed = function(key, ...) | ||
− | imgui.KeyPressed(key) | + | imgui.love.KeyPressed(key) |
− | if not imgui.GetWantCaptureKeyboard() then | + | if not imgui.love.GetWantCaptureKeyboard() then |
-- your code here | -- your code here | ||
end | end | ||
Line 84: | Line 84: | ||
love.keyreleased = function(key, ...) | love.keyreleased = function(key, ...) | ||
− | imgui.KeyReleased(key) | + | imgui.love.KeyReleased(key) |
− | if not imgui.GetWantCaptureKeyboard() then | + | if not imgui.love.GetWantCaptureKeyboard() then |
-- your code here | -- your code here | ||
end | end | ||
Line 91: | Line 91: | ||
love.textinput = function(t) | love.textinput = function(t) | ||
− | imgui.TextInput(t) | + | imgui.love.TextInput(t) |
− | if | + | if imgui.love.GetWantCaptureKeyboard() then |
-- your code here | -- your code here | ||
end | end | ||
Line 98: | Line 98: | ||
love.quit = function() | love.quit = function() | ||
− | return imgui.Shutdown() | + | 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 | end | ||
</source> | </source> |
Latest revision as of 22:49, 9 December 2023
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