mirror of
https://github.com/keharriso/love-nuklear.git
synced 2025-09-10 16:17:47 -04:00
cmake | ||
example | ||
src | ||
.gitmodules | ||
CMakeLists.txt | ||
LICENSE | ||
README.md |
LÖVE-Nuklear
Nuklear module for the LÖVE game engine.
Provides a lightweight immediate mode GUI for LÖVE games.
Example
-- Simple UI example.
local nk = require 'nuklear'
function love.load()
nk.init()
end
local combo = {value = 1, items = {'A', 'B', 'C'}}
function love.update(dt)
nk.frameBegin()
if nk.windowBegin('Simple Example', 100, 100, 200, 160,
'border', 'title', 'movable') then
nk.layoutRow('dynamic', 30, 1)
nk.label('Hello, world!')
nk.layoutRow('dynamic', 30, 2)
nk.label('Combo box:')
if nk.combobox(combo, combo.items) then
print('Combo!', combo.items[combo.value])
end
nk.layoutRow('dynamic', 30, 3)
nk.label('Buttons:')
if nk.button('Sample') then
print('Sample!')
end
if nk.button('Button') then
print('Button!')
end
end
nk.windowEnd()
nk.frameEnd()
end
function love.draw()
nk.draw()
end
function love.keypressed(key, scancode, isrepeat)
nk.keypressed(key, scancode, isrepeat)
end
function love.keyreleased(key, scancode)
nk.keyreleased(key, scancode)
end
function love.mousepressed(x, y, button, istouch)
nk.mousepressed(x, y, button, istouch)
end
function love.mousereleased(x, y, button, istouch)
nk.mousereleased(x, y, button, istouch)
end
function love.mousemoved(x, y, dx, dy, istouch)
nk.mousemoved(x, y, dx, dy, istouch)
end
function love.textinput(text)
nk.textinput(text)
end
function love.wheelmoved(x, y)
nk.wheelmoved(x, y)
end
Building
Windows binaries are available for each release.
To build the library yourself, grab the code with:
$ git clone --recursive git@github.com:keharriso/love-nuklear.git
Next, you need to compile the code to a native Lua module.
Compiling with CMake on Linux
- First, ensure you have the
cmake
andluajit
packages installed. - Create a new folder next to
love-nuklear
calledlove-nuklear-build
. - Open a terminal inside
love-nuklear-build
. - Compile with
$ cmake ../love-nuklear
$ make
- Locate
nuklear.so
in the build folder.
Compiling with CMake and MinGW on Windows
- Install CMake and MinGW or MinGW-w64.
- Download the source code for LuaJIT.
- Open a command window inside the LuaJIT folder (the one that contains "README").
- Compile LuaJIT with
$ mingw32-make
- Remember the path to
lua51.dll
inside the LuaJITsrc
folder. - Run the CMake GUI.
- Click "Browse Source" at the top right, then select the
love-nuklear
folder. - Enter a path for the build folder. It should be separate from the source folder.
- Press "Configure" at the bottom.
- Select "MinGW Makefiles" from the generator drop list, then click "Finish".
- You should receive an error. This is normal.
- Open the LUA tree by clicking the triangle on the left.
- Replace "LUA_INCLUDE_DIR-NOTFOUND" with the path to the LuaJIT
src
folder. - Replace "LUA_LIBRARY-NOTFOUND" with the path to
lua51.dll
inside the LuaJITsrc
folder. - Click "Generate" at the bottom.
- Open a command window inside the build folder.
- Compile with
$ mingw32-make
- Locate
nuklear.dll
inside the build folder.
Documentation
A complete description of all functions and style properties, alongside additional examples, is available at the LÖVE-Nuklear wiki.
License
Copyright (c) 2016 Kevin Harrison, released under the MIT License (see LICENSE for details).