Git Product home page Git Product logo

raylib-lua-sol's Introduction

raylib-lua-sol Logo

raylib-lua-sol

Lua bindings for raylib, a simple and easy-to-use library to enjoy videogames programming, with sol (www.raylib.com)

raylib-lua-sol bindings are self-contained in a header-only file: raylib-lua-sol.hpp. Just include that file in your project to allow loading and execution of raylib code written in Lua and Sol.

raylib-lua-sol could be useful for prototyping, tools development, graphic applications, embedded systems and education.

Ready to learn? Check out the code examples!

Example

local screenWidth = 800
local screenHeight = 450

InitWindow(screenWidth, screenHeight, "raylib [core] example - basic window")

SetTargetFPS(60)

while not WindowShouldClose() do
    BeginDrawing()
        ClearBackground(RAYWHITE)
        DrawText("Congrats! You created your first window!", 190, 200, 20, LIGHTGRAY)
    EndDrawing()
end
CloseWindow()

CLI

A raylib-lua-sol CLI launcher is provided. This launcher allows you to run raylib lua programs from command line, or just with drag & drop of .lua files into raylib-lua-sol.exe.

Note that launcher can also be compiled for other platforms, just need to link with Lua, raylib and sol libraries. For more details, just check comments on sources.

bin/raylib-lua-sol examples/core_basic_window.lua

Prebuild On Windows

Require:

Prebuild On GNU Linux

sudo apt install build-essential git cmake

Unbuntu

sudo apt install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev

Fedora

sudo dnf install alsa-lib-devel mesa-libGL-devel libX11-devel libXrandr-devel libXi-devel libXcursor-devel libXinerama-devel

Build

raylib-lua-sol uses cmake as a primary development target. Would appreciate adding more project templates, however.

git clone https://github.com/RobLoach/raylib-lua-sol.git
cd raylib-lua-sol
git submodule update --init
cmake -B build .
cmake --build build --config Release

Development

To run tests, use make test...

cd build
make test

License

raylib-lua-sol is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check LICENSE for further details.

Copyright (c) 2019 Rob Loach (@RobLoach)

raylib-lua-sol's People

Contributors

devmanso avatar nayaku avatar robloach avatar tornadocookie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

raylib-lua-sol's Issues

Lua Module

Have as a Lua module.

r = require "raylib"

mac os compiling error

I started to compile on mac OS (el Capitan), and everything was going well until i ran cmake --build build.
It got to about %50 done, then it threw this error:

/Users/user/raylib-lua-sol/vendor/raylib/src/external/glfw/src/nsgl_context.h:38:10: fatal error:
'stdatomic.h' file not found
#include <stdatomic.h>
^
1 error generated.

How can i fix this?

Lua Documentation

Build automated documentation around the Lua API. While it's the same as the C API, would be nice to list the functions and stuffs.

make: *** [Makefile:101: all] Error 2

archkubi@ThisIsMyKingdomCome ~/D/raylib-lua-sol (master)> cmake -B build .
-- The C compiler identification is GNU 13.2.1
-- The CXX compiler identification is GNU 13.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found raylib: /usr/lib/libraylib.so (Required is at least version "3.0.0") 
-- Configuring done (6.5s)
-- Generating done (0.1s)
-- Build files have been written to: /home/archkubi/Downloads/raylib-lua-sol/build
archkubi@ThisIsMyKingdomCome ~/D/raylib-lua-sol (master)> cmake --build ./build --config Release
[  2%] Building C object CMakeFiles/lua.dir/vendor/lua/lapi.c.o
[  5%] Building C object CMakeFiles/lua.dir/vendor/lua/lcode.c.o
[  8%] Building C object CMakeFiles/lua.dir/vendor/lua/lctype.c.o
[ 11%] Building C object CMakeFiles/lua.dir/vendor/lua/ldebug.c.o
[ 14%] Building C object CMakeFiles/lua.dir/vendor/lua/ldo.c.o
[ 17%] Building C object CMakeFiles/lua.dir/vendor/lua/ldump.c.o
[ 20%] Building C object CMakeFiles/lua.dir/vendor/lua/lfunc.c.o
[ 22%] Building C object CMakeFiles/lua.dir/vendor/lua/lgc.c.o
[ 25%] Building C object CMakeFiles/lua.dir/vendor/lua/llex.c.o
[ 28%] Building C object CMakeFiles/lua.dir/vendor/lua/lmem.c.o
[ 31%] Building C object CMakeFiles/lua.dir/vendor/lua/lobject.c.o
[ 34%] Building C object CMakeFiles/lua.dir/vendor/lua/lopcodes.c.o
[ 37%] Building C object CMakeFiles/lua.dir/vendor/lua/lparser.c.o
[ 40%] Building C object CMakeFiles/lua.dir/vendor/lua/lstate.c.o
[ 42%] Building C object CMakeFiles/lua.dir/vendor/lua/lstring.c.o
[ 45%] Building C object CMakeFiles/lua.dir/vendor/lua/ltable.c.o
[ 48%] Building C object CMakeFiles/lua.dir/vendor/lua/ltm.c.o
[ 51%] Building C object CMakeFiles/lua.dir/vendor/lua/lundump.c.o
[ 54%] Building C object CMakeFiles/lua.dir/vendor/lua/lvm.c.o
[ 57%] Building C object CMakeFiles/lua.dir/vendor/lua/lzio.c.o
[ 60%] Building C object CMakeFiles/lua.dir/vendor/lua/lauxlib.c.o
[ 62%] Building C object CMakeFiles/lua.dir/vendor/lua/lbaselib.c.o
[ 65%] Building C object CMakeFiles/lua.dir/vendor/lua/lcorolib.c.o
[ 68%] Building C object CMakeFiles/lua.dir/vendor/lua/ldblib.c.o
[ 71%] Building C object CMakeFiles/lua.dir/vendor/lua/liolib.c.o
[ 74%] Building C object CMakeFiles/lua.dir/vendor/lua/lmathlib.c.o
[ 77%] Building C object CMakeFiles/lua.dir/vendor/lua/loslib.c.o
[ 80%] Building C object CMakeFiles/lua.dir/vendor/lua/lstrlib.c.o
[ 82%] Building C object CMakeFiles/lua.dir/vendor/lua/ltablib.c.o
[ 85%] Building C object CMakeFiles/lua.dir/vendor/lua/lutf8lib.c.o
[ 88%] Building C object CMakeFiles/lua.dir/vendor/lua/loadlib.c.o
[ 91%] Building C object CMakeFiles/lua.dir/vendor/lua/linit.c.o
[ 94%] Linking C static library liblua.a
[ 94%] Built target lua
[ 97%] Building CXX object bin/CMakeFiles/raylib-lua-sol.dir/raylib-lua-sol.cpp.o
In file included from /home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack.hpp:28,
                 from /home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/sol.hpp:50,
                 from /home/archkubi/Downloads/raylib-lua-sol/bin/raylib-lua-sol.cpp:54:
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp: In function ‘void sol::detail::align_one(std::size_t, std::size_t, void*&)’:
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:88:51: error: ‘numeric_limits’ is not a member of ‘std’
   88 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                   ^~~~~~~~~~~~~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:88:77: error: expected primary-expression before ‘>’ token
   88 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                             ^
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:88:80: error: ‘::max’ has not been declared; did you mean ‘std::max’?
   88 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                                ^~~
      |                                                                                std::max
In file included from /usr/include/c++/13.2.1/functional:67,
                 from /home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/string_view.hpp:31,
                 from /home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/traits.hpp:31,
                 from /home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/forward_detail.hpp:29,
                 from /home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/sol.hpp:48:
/usr/include/c++/13.2.1/bits/stl_algo.h:5805:5: note: ‘std::max’ declared here
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp: In function ‘void* sol::detail::align_usertype_pointer(void*)’:
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:111:51: error: ‘numeric_limits’ is not a member of ‘std’
  111 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                   ^~~~~~~~~~~~~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:111:77: error: expected primary-expression before ‘>’ token
  111 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                             ^
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:111:80: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  111 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                                ^~~
      |                                                                                std::max
/usr/include/c++/13.2.1/bits/stl_algo.h:5805:5: note: ‘std::max’ declared here
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp: In function ‘void* sol::detail::align_usertype_unique_destructor(void*)’:
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:133:51: error: ‘numeric_limits’ is not a member of ‘std’
  133 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                   ^~~~~~~~~~~~~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:133:77: error: expected primary-expression before ‘>’ token
  133 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                             ^
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:133:80: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  133 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                                ^~~
      |                                                                                std::max
/usr/include/c++/13.2.1/bits/stl_algo.h:5805:5: note: ‘std::max’ declared here
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp: In function ‘void* sol::detail::align_usertype_unique_tag(void*)’:
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:155:51: error: ‘numeric_limits’ is not a member of ‘std’
  155 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                   ^~~~~~~~~~~~~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:155:77: error: expected primary-expression before ‘>’ token
  155 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                             ^
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:155:80: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  155 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                                ^~~
      |                                                                                std::max
/usr/include/c++/13.2.1/bits/stl_algo.h:5805:5: note: ‘std::max’ declared here
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp: In function ‘void* sol::detail::align_usertype_unique(void*)’:
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:178:51: error: ‘numeric_limits’ is not a member of ‘std’
  178 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                   ^~~~~~~~~~~~~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:178:77: error: expected primary-expression before ‘>’ token
  178 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                             ^
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:178:80: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  178 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                                ^~~
      |                                                                                std::max
/usr/include/c++/13.2.1/bits/stl_algo.h:5805:5: note: ‘std::max’ declared here
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp: In function ‘void* sol::detail::align_user(void*)’:
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:195:51: error: ‘numeric_limits’ is not a member of ‘std’
  195 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                   ^~~~~~~~~~~~~~
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:195:77: error: expected primary-expression before ‘>’ token
  195 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                             ^
/home/archkubi/Downloads/raylib-lua-sol/bin/../vendor/sol2/include/sol/stack_core.hpp:195:80: error: ‘::max’ has not been declared; did you mean ‘std::max’?
  195 |                         std::size_t space = (std::numeric_limits<std::size_t>::max)();
      |                                                                                ^~~
      |                                                                                std::max
/usr/include/c++/13.2.1/bits/stl_algo.h:5805:5: note: ‘std::max’ declared here
 5805 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
make[2]: *** [bin/CMakeFiles/raylib-lua-sol.dir/build.make:76: bin/CMakeFiles/raylib-lua-sol.dir/raylib-lua-sol.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:936: bin/CMakeFiles/raylib-lua-sol.dir/all] Error 2
make: *** [Makefile:101: all] Error 2


Does not compile

It fails compiling under Ubuntu 20 with

[ 94%] Built target lua
[ 97%] Linking CXX executable raylib-lua-sol
/usr/bin/ld: ../liblua.a(loslib.c.o): in function `os_tmpname':
loslib.c:(.text+0x18b): warning: the use of `tmpnam' is dangerous, better use `mkstemp'
/usr/bin/ld: CMakeFiles/raylib-lua-sol.dir/raylib-lua-sol.cpp.o: in function `raylib_lua_sol_rlgl(sol::state&)':
raylib-lua-sol.cpp:(.text+0xce9): undefined reference to `rlUnproject'
/usr/bin/ld: CMakeFiles/raylib-lua-sol.dir/raylib-lua-sol.cpp.o: in function `raylib_lua_sol_functions(sol::state&)':
raylib-lua-sol.cpp:(.text+0xa867): undefined reference to `LoadImageEx'
/usr/bin/ld: raylib-lua-sol.cpp:(.text+0xadb0): undefined reference to `ImageExtractPalette'
/usr/bin/ld: raylib-lua-sol.cpp:(.text+0xc799): undefined reference to `SetMusicLoopCount'
collect2: error: ld returned 1 exit status
make[2]: *** [bin/CMakeFiles/raylib-lua-sol.dir/build.make:86: bin/raylib-lua-sol] Error 1
make[1]: *** [CMakeFiles/Makefile2:970: bin/CMakeFiles/raylib-lua-sol.dir/all] Error 2

I then took out ImageExtraPalette and SetMusicLoopCount from include/raylib-lua-sol.hpp but the rlUnproject and LoadImageEx undefied references stay.

CMAKE_MODULE_PATH append not set

Your CMakeLists.txt has an error.
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
to
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
I am using addon for easy to setup by using FetchContent.

Add TextFormat

// TODO: Add TextFormat
  //RAYLIB_LUA_SOL_ADD_FUNCTION(TextFormat);

fatal error C1060

ryzen 5700g + 32GRam + 1TSSD use Vs2017 compile this project hint error fatal error C1060 compiler is out of heap space.

CMake files do not automatically download the libraries when ran

Hi,

The files FindSol.cmake and FindRaylib.cmake do not automatically download the libraries on OS X 10.15.1.

If you change the flag QUIET to VERBOSE it fails but then carries on to download and building steps:


find_package(sol 3.0 VERBOSE)
if (NOT sol_FOUND)
  include(FetchContent)
  FetchContent_Declare(
    sol
    GIT_REPOSITORY https://github.com/ThePhD/sol2.git
    GIT_TAG 6d4a5d3ef66d605c54093edb673c14e373969a08
  )
  FetchContent_GetProperties(sol)
  if (NOT sol_POPULATED) # Have we downloaded sol2 yet?
    set(FETCHCONTENT_QUIET NO)
    FetchContent_Populate(sol)
    add_subdirectory(${sol_SOURCE_DIR} ${sol_BINARY_DIR})
    set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" "${sol_SOURCE_DIR}/cmake" "${sol_SOURCE_DIR}/cmake/Modules")
  endif()
endif()

The verbose flag is not valid so it carries on, i installed raylib view brew but it didn't find the libraries in the first place.

Function TraceLog

Add TraceLog wrappers....

  //RAYLIB_LUA_SOL_ADD_FUNCTION(SetTraceLogCallback);
  // TODO: Add TraceLog
  //RAYLIB_LUA_SOL_ADD_FUNCTION(TraceLog);

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.