Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 11 additions & 14 deletions .github/workflows/Tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ jobs:
build-ubuntu:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive
- name: Install Dependencies
run: sudo apt-get install libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev
run: |
sudo apt-get update
sudo apt-get install -y libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libxkbcommon-dev libxinerama-dev libxcursor-dev
- name: Configure
run: cmake -B build .
- name: Build
Expand All @@ -25,22 +27,17 @@ jobs:
fail-fast: false
max-parallel: 1
matrix:
compiler: [mingw-w64,msvc16]
compiler: [mingw-w64, msvc]
include:
- compiler: mingw-w64
PLATFORM_NAME: "MinGW Makefiles"
- compiler: msvc16
PLATFORM_NAME: "Visual Studio 16 2019"
platform_name: "MinGW Makefiles"
- compiler: msvc
platform_name: "Visual Studio 18 2026"
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
submodules: recursive

# Setup Visual Studio
- name: Setup MSBuild
uses: microsoft/setup-msbuild@v1.0.2
if: matrix.compiler == 'msvc16'

- name: Configure
run: cmake -G "${{ matrix.platform_name }}" -B build_${{ matrix.compiler }} .

Expand All @@ -51,6 +48,6 @@ jobs:
run: build_${{ matrix.compiler }}\bin\raylib-lua-sol.exe tests/raylib-lua-sol-tests.lua
if: matrix.compiler == 'mingw-w64'

- name: Test (msvc16)
- name: Test (msvc)
run: build_${{ matrix.compiler }}\bin\Release\raylib-lua-sol.exe tests/raylib-lua-sol-tests.lua
if: matrix.compiler == 'msvc16'
if: matrix.compiler == 'msvc'
16 changes: 15 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,15 @@
build
# CMake / compiler output
build
/build-*/
/build_*/
out/
cmake-build-*/
.vs/

CMakeCache.txt
CMakeFiles/
cmake_install.cmake
CTestTestfile.cmake
Testing/
compile_commands.json
CMakeUserPresets.json
13 changes: 8 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.11)
cmake_minimum_required(VERSION 3.25)
project (raylib-lua-sol
VERSION 0.2.2
VERSION 0.3.0
DESCRIPTION "Lua bindings for raylib"
HOMEPAGE_URL "https://github.com/RobLoach/raylib-lua-sol"
LANGUAGES C CXX)
Expand Down Expand Up @@ -34,11 +34,14 @@ add_subdirectory(include)

if (BUILD_BIN)
# raylib
find_package(raylib 3.0.0)
find_package(raylib 6.0 QUIET)
if (NOT raylib_FOUND)
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE) # don't build the supplied examples
set(BUILD_GAMES OFF CACHE BOOL "" FORCE) # or games
# raylib uses the same BUILD_EXAMPLES cache option; keep this project's value.
set(_RAYLIB_LUA_SOL_BUILD_EXAMPLES "${BUILD_EXAMPLES}")
set(BUILD_EXAMPLES OFF CACHE BOOL "" FORCE)
add_subdirectory(vendor/raylib)
set(BUILD_EXAMPLES "${_RAYLIB_LUA_SOL_BUILD_EXAMPLES}" CACHE BOOL "" FORCE)
unset(_RAYLIB_LUA_SOL_BUILD_EXAMPLES)
endif()

# Lua
Expand Down
9 changes: 8 additions & 1 deletion bin/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,19 @@
add_executable(raylib-lua-sol raylib-lua-sol.cpp)

target_compile_definitions(raylib-lua-sol PUBLIC -DLUA -DPHYSAC_NO_THREADS)
target_compile_definitions(raylib-lua-sol PUBLIC -DLUA)

set_target_properties(raylib-lua-sol PROPERTIES
CXX_STANDARD 17
CXX_EXTENSIONS OFF
)

# GCC 15+ diagnoses uninstantiated sol2 templates as errors (-Wtemplate-body).
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag(-Wno-template-body HAVE_WNO_TEMPLATE_BODY)
if (HAVE_WNO_TEMPLATE_BODY)
target_compile_options(raylib-lua-sol PRIVATE -Wno-template-body)
endif()

target_link_libraries(raylib-lua-sol
raylib-lua-sol-hpp
raylib
Expand Down
2 changes: 1 addition & 1 deletion bin/raylib-lua-sol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
* 3. This notice may not be removed or altered from any source distribution.
*
********************************************************************************************/
#inclde <limits>
#include <limits>
#include <iostream>
#include <string>

Expand Down
2 changes: 1 addition & 1 deletion examples/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Get the sources together
set(example_dirs audio core models shaders text textures)
set(example_dirs audio core models shaders shapes text textures)
set(example_sources)
set(example_resources)

Expand Down
4 changes: 2 additions & 2 deletions examples/audio/audio_raw_stream.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ InitWindow(screenWidth, screenHeight, "raylib [audio] example - raw audio stream
InitAudioDevice() -- Initialize audio device

-- Init raw audio stream (sample rate: 22050, sample size: 32bit-float, channels: 1-mono)
local stream = InitAudioStream(22050, 32, 1)
local stream = LoadAudioStream(22050, 32, 1)

-- Fill audio stream with some samples (sine wave)
local data = {}
Expand Down Expand Up @@ -89,7 +89,7 @@ end

-- De-Initialization
-------------------------------------------------------------------------------------------
CloseAudioStream(stream) -- Close raw audio stream and delete buffers from RAM
UnloadAudioStream(stream) -- Close raw audio stream and delete buffers from RAM

CloseAudioDevice() -- Close audio device (music streaming is automatically stopped)

Expand Down
3 changes: 1 addition & 2 deletions examples/core/core_3d_camera_first_person.lua
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ end

local playerPosition = Vector3(4.0, 2.0, 4.0) -- Define player position

SetCameraMode(camera, CAMERA_FIRST_PERSON) -- Set a first person camera mode

SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-------------------------------------------------------------------------------------------
Expand All @@ -43,7 +42,7 @@ SetTargetFPS(60) -- Set our game to run at 60
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
---------------------------------------------------------------------------------------
UpdateCamera(camera) -- Update camera
UpdateCamera(camera, CAMERA_FIRST_PERSON) -- Update camera
---------------------------------------------------------------------------------------

-- Draw
Expand Down
3 changes: 1 addition & 2 deletions examples/core/core_3d_camera_free.lua
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ camera.fovy = 45.0 -- Camera field-of-view Y

local cubePosition = Vector3(0.0, 0.0, 0.0)

SetCameraMode(camera, CAMERA_FREE) -- Set a free camera mode

SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-------------------------------------------------------------------------------------------
Expand All @@ -34,7 +33,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
---------------------------------------------------------------------------------------
UpdateCamera(camera) -- Update camera
UpdateCamera(camera, CAMERA_FREE) -- Update camera
---------------------------------------------------------------------------------------

-- Draw
Expand Down
9 changes: 4 additions & 5 deletions examples/core/core_3d_picking.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ local ray = Ray() -- Picking line ray

local collision = false

SetCameraMode(camera, CAMERA_FREE) -- Set a free camera mode

SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-------------------------------------------------------------------------------------------
Expand All @@ -39,16 +38,16 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
---------------------------------------------------------------------------------------
UpdateCamera(camera) -- Update camera
UpdateCamera(camera, CAMERA_FREE) -- Update camera

if (IsMouseButtonPressed(MOUSE_LEFT_BUTTON)) then
-- NOTE: This function is NOT WORKING properly!
ray = GetMouseRay(GetMousePosition(), camera)
ray = GetScreenToWorldRay(GetMousePosition(), camera)

-- Check collision between ray and box
collision = CheckCollisionRayBox(ray,
collision = GetRayCollisionBox(ray,
BoundingBox(Vector3(cubePosition.x - cubeSize.x/2, cubePosition.y - cubeSize.y/2, cubePosition.z - cubeSize.z/2),
Vector3(cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2)))
Vector3(cubePosition.x + cubeSize.x/2, cubePosition.y + cubeSize.y/2, cubePosition.z + cubeSize.z/2))).hit

--print("collision check:", collision)
end
Expand Down
4 changes: 1 addition & 3 deletions examples/core/core_drop_files.lua
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
---------------------------------------------------------------------------------------
if (IsFileDropped()) then
droppedFiles = GetDroppedFiles()
droppedFiles = LoadDroppedFiles()
count = #droppedFiles
end
---------------------------------------------------------------------------------------
Expand Down Expand Up @@ -60,7 +60,5 @@ end

-- De-Initialization
-------------------------------------------------------------------------------------------
ClearDroppedFiles() -- Clear internal buffers

CloseWindow() -- Close window and OpenGL context
-------------------------------------------------------------------------------------------
4 changes: 2 additions & 2 deletions examples/core/core_input_gamepad.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
if (IsGamepadAvailable(GAMEPAD.PLAYER1)) then
DrawText(string.format("GP1: %s", GetGamepadName(GAMEPAD.PLAYER1)), 10, 10, 10, BLACK)

if (IsGamepadName(GAMEPAD.PLAYER1, "Xbox 360 Controller")) then
if (GetGamepadName(GAMEPAD.PLAYER1) == "Xbox 360 Controller") then
DrawTexture(texXboxPad, 0, 0, DARKGRAY)

-- Draw buttons: xbox home
Expand Down Expand Up @@ -87,7 +87,7 @@ while not WindowShouldClose() do -- Detect window close button or ESC key

--DrawText(FormatText("Xbox axis LT: %02.02f", GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_LT)), 10, 40, 10, BLACK)
--DrawText(FormatText("Xbox axis RT: %02.02f", GetGamepadAxisMovement(GAMEPAD.PLAYER1, GAMEPAD.XBOX_AXIS_RT)), 10, 60, 10, BLACK)
elseif (IsGamepadName(GAMEPAD.PLAYER1, "PLAYSTATION(R)3 Controller")) then
elseif (GetGamepadName(GAMEPAD.PLAYER1) == "PLAYSTATION(R)3 Controller") then
DrawTexture(texPs3Pad, 0, 0, DARKGRAY)

-- Draw buttons: ps
Expand Down
16 changes: 8 additions & 8 deletions examples/core/core_storage_values.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,7 @@
--
-------------------------------------------------------------------------------------------

-- NOTE: Storage positions must start with 0, directly related to file memory layout
STORAGE_SCORE = 0
STORAGE_HISCORE = 1
local STORAGE_FILE = "storage.data"

-- Initialization
-------------------------------------------------------------------------------------------
Expand All @@ -38,12 +36,14 @@ while not WindowShouldClose() do -- Detect window close button or ESC key
end

if (IsKeyPressed(KEY_ENTER)) then
StorageSaveValue(STORAGE_SCORE, score)
StorageSaveValue(STORAGE_HISCORE, hiscore)
SaveFileText(STORAGE_FILE, string.format("%d\n%d", score, hiscore))
elseif (IsKeyPressed(KEY_SPACE)) then
-- NOTE: If requested position could not be found, value 0 is returned
score = StorageLoadValue(STORAGE_SCORE)
hiscore = StorageLoadValue(STORAGE_HISCORE)
if FileExists(STORAGE_FILE) then
local text = LoadFileText(STORAGE_FILE)
local loadedScore, loadedHiscore = string.match(text, "(%-?%d+)\n(%-?%d+)")
score = tonumber(loadedScore) or 0
hiscore = tonumber(loadedHiscore) or 0
end
end

framesCounter = framesCounter + 1
Expand Down
3 changes: 1 addition & 2 deletions examples/core/core_vr_simulator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ camera.fovy = 60.0 -- Camera field-of-view Y

local cubePosition = Vector3(0.0, 0.0, 0.0)

SetCameraMode(CAMERA_FIRST_PERSON); -- Set first person camera mode

SetTargetFPS(90) -- Set our game to run at 90 frames-per-second
----------------------------------------------------------------------------------------
Expand All @@ -41,7 +40,7 @@ SetTargetFPS(90) -- Set our game to run at 90 frames-per-seco
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
------------------------------------------------------------------------------------
UpdateCamera(camera); -- Update camera (simulator mode)
UpdateCamera(camera, CAMERA_FIRST_PERSON); -- Update camera (simulator mode)

if (IsKeyPressed(KEY_SPACE)) then ToggleVrMode() end -- Toggle VR mode
------------------------------------------------------------------------------------
Expand Down
3 changes: 1 addition & 2 deletions examples/core/core_world_screen.lua
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ local camera = Camera(Vector3(10.0, 10.0, 10.0), Vector3(), Vector3(0.0, 1.0, 0.

local cubePosition = Vector3()

SetCameraMode(camera, CAMERA_FREE) -- Set a free camera mode

SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
----------------------------------------------------------------------------------------
Expand All @@ -30,7 +29,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-per-
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
------------------------------------------------------------------------------------
UpdateCamera(camera) -- Update camera
UpdateCamera(camera, CAMERA_FREE) -- Update camera

-- Calculate cube screen space position (with a little offset to be in top)
local cubeScreenPosition = GetWorldToScreen(Vector3(cubePosition.x, cubePosition.y + 2.5, cubePosition.z), camera)
Expand Down
3 changes: 1 addition & 2 deletions examples/models/models_billboard.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ local camera = Camera(Vector3(5.0, 4.0, 5.0), Vector3(0.0, 2.0, 0.0), Vector3(0.
local bill = LoadTexture("resources/billboard.png") -- Our texture billboard
local billPosition = Vector3(0.0, 2.0, 0.0) -- Position where draw billboard

SetCameraMode(camera, CAMERA_ORBITAL) -- Set an orbital camera mode

SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-------------------------------------------------------------------------------------------
Expand All @@ -31,7 +30,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
---------------------------------------------------------------------------------------
UpdateCamera(camera) -- Update camera
UpdateCamera(camera, CAMERA_ORBITAL) -- Update camera
---------------------------------------------------------------------------------------

-- Draw
Expand Down
3 changes: 1 addition & 2 deletions examples/models/models_cubicmap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ local mapPosition = Vector3(-16.0, 0.0, -8.0) -- Set model position

UnloadImage(image) -- Unload cubesmap image from RAM, already uploaded to VRAM

SetCameraMode(camera, CAMERA_ORBITAL) -- Set an orbital camera mode

SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
-------------------------------------------------------------------------------------------
Expand All @@ -40,7 +39,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
---------------------------------------------------------------------------------------
UpdateCamera(camera) -- Update camera
UpdateCamera(camera, CAMERA_ORBITAL) -- Update camera
---------------------------------------------------------------------------------------

-- Draw
Expand Down
3 changes: 1 addition & 2 deletions examples/models/models_heightmap.lua
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ local mapPosition = Vector3(-8.0, 0.0, -8.0) -- Set model position (d

UnloadImage(image) -- Unload heightmap image from RAM, already uploaded to VRAM

SetCameraMode(camera, CAMERA_ORBITAL) -- Set an orbital camera mode

SetTargetFPS(60) -- Set our game to run at 60 frames-per-second
----------------------------------------------------------------------------------------
Expand All @@ -36,7 +35,7 @@ SetTargetFPS(60) -- Set our game to run at 60 frames-
while not WindowShouldClose() do -- Detect window close button or ESC key
-- Update
---------------------------------------------------------------------------------------
UpdateCamera(camera) -- Update camera
UpdateCamera(camera, CAMERA_ORBITAL) -- Update camera
---------------------------------------------------------------------------------------

-- Draw
Expand Down
Loading
Loading