From b51de073dae502459f304f05489e785db092dca7 Mon Sep 17 00:00:00 2001 From: Martin Gerhardy Date: Fri, 5 Jan 2018 17:05:36 +0100 Subject: [PATCH 1/3] Fixed warnings and removed unused methods and global vars --- src/nuklear_love.c | 27 ++------------------------- 1 file changed, 2 insertions(+), 25 deletions(-) diff --git a/src/nuklear_love.c b/src/nuklear_love.c index 7ee6353..7308f2e 100644 --- a/src/nuklear_love.c +++ b/src/nuklear_love.c @@ -45,7 +45,6 @@ static struct nk_user_font *fonts; static int font_count; static char *edit_buffer; static const char **combobox_items; -static struct nk_cursor cursors[NK_CURSOR_COUNT]; static float *floats; static int layout_ratio_count; @@ -363,28 +362,6 @@ static void nk_love_draw_rect_multi_color(int x, int y, unsigned int w, lua_pop(L, 2); } -static void nk_love_clear(struct nk_color col) -{ - lua_getglobal(L, "love"); - lua_getfield(L, -1, "graphics"); - lua_getfield(L, -1, "clear"); - lua_pushnumber(L, col.r); - lua_pushnumber(L, col.g); - lua_pushnumber(L, col.b); - lua_pushnumber(L, col.a); - lua_call(L, 4, 0); - lua_pop(L, 2); -} - -static void nk_love_blit() -{ - lua_getglobal(L, "love"); - lua_getfield(L, -1, "graphics"); - lua_getfield(L, -1, "present"); - lua_call(L, 0, 0); - lua_pop(L, 2); -} - static void nk_love_draw_image(int x, int y, unsigned int w, unsigned int h, struct nk_image image, struct nk_color color) { @@ -3437,12 +3414,12 @@ static int nk_love_input_is_mouse(int down) static int nk_love_input_is_mouse_pressed(lua_State *L) { - nk_love_input_is_mouse(nk_true); + return nk_love_input_is_mouse(nk_true); } static int nk_love_input_is_mouse_released(lua_State *L) { - nk_love_input_is_mouse(nk_false); + return nk_love_input_is_mouse(nk_false); } static int nk_love_input_was_hovered(lua_State *L) From d8234fcc1c0bf108a1ea23f70a14266e8cc2d71b Mon Sep 17 00:00:00 2001 From: James Nelson Date: Wed, 18 Apr 2018 14:23:09 -0600 Subject: [PATCH 2/3] Change color scale from 0 - 255 to 0 - 1.0 --- src/nuklear_love.c | 46 +++++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/src/nuklear_love.c b/src/nuklear_love.c index 7ee6353..e7e15b1 100644 --- a/src/nuklear_love.c +++ b/src/nuklear_love.c @@ -60,10 +60,10 @@ static void nk_love_configureGraphics(int line_thickness, struct nk_color col) lua_call(L, 1, 0); } lua_getfield(L, -1, "setColor"); - lua_pushnumber(L, col.r); - lua_pushnumber(L, col.g); - lua_pushnumber(L, col.b); - lua_pushnumber(L, col.a); + lua_pushnumber(L, col.r / 255.0); + lua_pushnumber(L, col.g / 255.0); + lua_pushnumber(L, col.b / 255.0); + lua_pushnumber(L, col.a / 255.0); lua_call(L, 4, 0); } @@ -77,10 +77,10 @@ static void nk_love_getGraphics(float *line_thickness, struct nk_color *color) lua_pop(L, 1); lua_getfield(L, -1, "getColor"); lua_call(L, 0, 4); - color->r = lua_tointeger(L, -4); - color->g = lua_tointeger(L, -3); - color->b = lua_tointeger(L, -2); - color->a = lua_tointeger(L, -1); + color->r = lua_tointeger(L, -4) * 255.0; + color->g = lua_tointeger(L, -3) * 255.0; + color->b = lua_tointeger(L, -2) * 255.0; + color->a = lua_tointeger(L, -1) * 255.0; lua_pop(L, 6); } @@ -255,10 +255,10 @@ static void nk_love_draw_text(int fontref, struct nk_color cbg, lua_getfield(L, -1, "graphics"); lua_getfield(L, -1, "setColor"); - lua_pushnumber(L, cbg.r); - lua_pushnumber(L, cbg.g); - lua_pushnumber(L, cbg.b); - lua_pushnumber(L, cbg.a); + lua_pushnumber(L, cbg.r / 255.0); + lua_pushnumber(L, cbg.g / 255.0); + lua_pushnumber(L, cbg.b / 255.0); + lua_pushnumber(L, cbg.a / 255.0); lua_call(L, 4, 0); lua_getfield(L, -1, "rectangle"); @@ -270,10 +270,10 @@ static void nk_love_draw_text(int fontref, struct nk_color cbg, lua_call(L, 5, 0); lua_getfield(L, -1, "setColor"); - lua_pushnumber(L, cfg.r); - lua_pushnumber(L, cfg.g); - lua_pushnumber(L, cfg.b); - lua_pushnumber(L, cfg.a); + lua_pushnumber(L, cfg.r / 255.0); + lua_pushnumber(L, cfg.g / 255.0); + lua_pushnumber(L, cfg.b / 255.0); + lua_pushnumber(L, cfg.a / 255.0); lua_call(L, 4, 0); lua_getfield(L, -1, "setFont"); @@ -318,9 +318,9 @@ static void nk_love_draw_rect_multi_color(int x, int y, unsigned int w, lua_pushstring(L, "all"); lua_call(L, 1, 0); lua_getfield(L, -1, "setColor"); - lua_pushnumber(L, 255); - lua_pushnumber(L, 255); - lua_pushnumber(L, 255); + lua_pushnumber(L, 1.0); + lua_pushnumber(L, 1.0); + lua_pushnumber(L, 1.0); lua_call(L, 3, 0); lua_getfield(L, -1, "setPointSize"); lua_pushnumber(L, 1); @@ -368,10 +368,10 @@ static void nk_love_clear(struct nk_color col) lua_getglobal(L, "love"); lua_getfield(L, -1, "graphics"); lua_getfield(L, -1, "clear"); - lua_pushnumber(L, col.r); - lua_pushnumber(L, col.g); - lua_pushnumber(L, col.b); - lua_pushnumber(L, col.a); + lua_pushnumber(L, col.r / 255.0); + lua_pushnumber(L, col.g / 255.0); + lua_pushnumber(L, col.b / 255.0); + lua_pushnumber(L, col.a / 255.0); lua_call(L, 4, 0); lua_pop(L, 2); } From 4d001728a0f3c01567a70f6b9842bd90cdb8b982 Mon Sep 17 00:00:00 2001 From: Kevin Harrison Date: Fri, 29 Jun 2018 15:32:06 -0400 Subject: [PATCH 3/3] Add proper build instructions to README.md --- README.md | 43 +++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 41 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 42b6010..8597fc5 100644 --- a/README.md +++ b/README.md @@ -75,14 +75,53 @@ end ## Building -Windows and Linux binaries are available for each [release](https://github.com/keharriso/love-nuklear/releases). +Windows binaries are available for each [release](https://github.com/keharriso/love-nuklear/releases). To build the library yourself, grab the code with: ```sh $ git clone --recursive git@github.com:keharriso/love-nuklear.git ``` -Compile with CMake (I recommend using the MinGW generator on Windows). You'll need to tell CMake where to find the LuaJIT headers and binaries. The end result is a native Lua module. +Next, you need to compile the code to a native Lua module. + +### Compiling with CMake on Linux + +1. First, ensure you have the `cmake` and `luajit` packages installed. +2. Create a new folder next to `love-nuklear` called `love-nuklear-build`. +3. Open a terminal inside `love-nuklear-build`. +4. Compile with +```sh +$ cmake ../love-nuklear +$ make +``` +5. Locate `nuklear.so` in the build folder. + +### Compiling with CMake and MinGW on Windows + +1. Install [CMake](https://cmake.org/download/) and [MinGW](http://mingw.org/) or [MinGW-w64](https://mingw-w64.org/doku.php). +2. Download the source code for [LuaJIT](http://luajit.org/download.html). +3. Open a command window inside the LuaJIT folder (the one that contains "README"). +4. Compile LuaJIT with +```sh +$ mingw32-make +``` +5. Remember the path to `lua51.dll` inside the LuaJIT `src` folder. +6. Run the CMake GUI. +7. Click "Browse Source" at the top right, then select the `love-nuklear` folder. +8. Enter a path for the build folder. It should be separate from the source folder. +9. Press "Configure" at the bottom. +10. Select "MinGW Makefiles" from the generator drop list, then click "Finish". +11. You should receive an error. This is normal. +12. Open the LUA tree by clicking the triangle on the left. +13. Replace "LUA_INCLUDE_DIR-NOTFOUND" with the path to the LuaJIT `src` folder. +14. Replace "LUA_LIBRARY-NOTFOUND" with the path to `lua51.dll` inside the LuaJIT `src` folder. +15. Click "Generate" at the bottom. +16. Open a command window inside the build folder. +17. Compile with +```sh +$ mingw32-make +``` +18. Locate `nuklear.dll` inside the build folder. ## Documentation