Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implament Lua as a scripting language #14

Merged
merged 36 commits into from
Jan 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
7835d39
implament Lua
arozx Jan 23, 2025
a7accaf
chore: update actions build dependancies
arozx Jan 23, 2025
b88e651
load lua init script from file
arozx Jan 23, 2025
e99b442
setup tools for autcomplete with lua vscode extension
arozx Jan 23, 2025
ddb0312
bug: fix profiler json output
arozx Jan 23, 2025
2b44567
add logging for trace and warnings to lua bindings
arozx Jan 23, 2025
bbf17b0
add camera controls
arozx Jan 23, 2025
6e596c6
add render controls
arozx Jan 23, 2025
15ca8cb
adds camera controls
arozx Jan 23, 2025
16ecd38
add window controls
arozx Jan 24, 2025
4b1b674
update lua build files on run
arozx Jan 24, 2025
aac8d1b
Add Visual Studio build files
arozx Jan 24, 2025
b4f2e56
add console for Live Lua execution
arozx Jan 25, 2025
1ed979e
remove duplicate <sstream> include
arozx Jan 25, 2025
e268c84
add colours to log messages
arozx Jan 26, 2025
5302416
fix fatal logs
arozx Jan 27, 2025
f8c383a
move objects into scenes
arozx Jan 28, 2025
1960b0a
workspace stuff
arozx Jan 28, 2025
2158b3e
📝 Add docstrings to `Lua`
coderabbitai[bot] Jan 28, 2025
3b9341c
add error messages when missing cmake dependancies
arozx Jan 28, 2025
d670ba8
fixes windows console ouput colours
arozx Jan 28, 2025
ccc17cd
remove redudant render method (draw has the same functionality)
arozx Jan 28, 2025
c9ecaf6
remove comments from external files
arozx Jan 28, 2025
934f9ca
Merge pull request #15 from arozx/coderabbitai/docstrings/1960b0a
arozx Jan 28, 2025
fc71fd7
Merge branch 'Lua' of https://github.com/arozx/voxels into Lua
arozx Jan 28, 2025
bd3e2d1
remove redundant object tranfom call
arozx Jan 28, 2025
a70e1bd
fix object transform
arozx Jan 28, 2025
3f6b762
add copy semantics and docs
arozx Jan 28, 2025
64a4ed3
add sanitsiation to path creation
arozx Jan 28, 2025
65a19c2
make copyScript more robust
arozx Jan 28, 2025
7a87d6c
make thread safe
arozx Jan 28, 2025
fe8a5c5
add error handeling to folder creation
arozx Jan 28, 2025
0eea1a7
protect against path traversal
arozx Jan 28, 2025
5e7e22d
prevent memory errors from large filesize
arozx Jan 28, 2025
35f9535
update sandbox terminal
arozx Jan 28, 2025
88755c3
improve path travesal mitigations
arozx Jan 28, 2025
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
9 changes: 9 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
BasedOnStyle: Google
IndentWidth: 4
ColumnLimit: 100
AllowShortFunctionsOnASingleLine: All
AllowShortLambdasOnASingleLine: All
BraceWrapping:
AfterFunction: false
AfterClass: false
BreakBeforeBraces: Attach
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
run: |
sudo apt update
sudo apt install -y cmake build-essential pkg-config \
libglfw3-dev libgl1-mesa-dev libx11-dev libgl-dev libglm-dev libfreetype6-dev ccache
libglfw3-dev libgl1-mesa-dev libx11-dev libgl-dev libglm-dev libfreetype6-dev ccache lua5.4

- name: Update submodules
run: git submodule update --init --recursive
Expand Down
16 changes: 16 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

# build files
build/
cmake.db

#docs
docs/
Expand All @@ -22,3 +23,18 @@ profile_results.json
profiler_n_frames.json

heightmap_chunk*.bmp

# Vcpkg
vcpkg_installed/

# Visual Studio
.vs/voxel-eng/FileContentIndex
.vs/voxel-eng/v17/

.vs/CMake Overview
.vs/slnx.sqlite*

.vs/voxel-eng/copilot*

cmake-build-debug/
cmake-build-release
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

244 changes: 244 additions & 0 deletions .idea/editor.xml

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions .idea/voxels.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

186 changes: 186 additions & 0 deletions .idea/workspace.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions .vs/ProjectSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"CurrentProjectSetting": "x64-Debug"
}
16 changes: 16 additions & 0 deletions .vs/VSWorkspaceState.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"DevContainersInfoBarHidden": true,
"ActiveTargetSystem": "Local Machine",
"OutputFoldersPerTargetSystem": {
"Local Machine": [
"out\\build\\x64-Debug",
"out\\install\\x64-Debug",
"out\\build\\x64-Release",
"out\\install\\x64-Release"
],
"WSL: Arch": [
"out\\build\\x64-Debug",
"out\\install\\x64-Debug"
]
}
}
12 changes: 12 additions & 0 deletions .vs/launch.vs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"version": "0.2.1",
"defaults": {},
"configurations": [
{
"type": "default",
"project": "CMakeLists.txt",
"projectTarget": "sandbox.exe",
"name": "sandbox.exe"
}
]
}
46 changes: 31 additions & 15 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,28 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)

if(WIN32)
set(CMAKE_TOOLCHAIN_FILE "${CMAKE_SOURCE_DIR}/vcpkg/scripts/buildsystems/vcpkg.cmake")
set(CMAKE_TOOLCHAIN_FILE "$ENV{USERPROFILE}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
else()
include_directories(/usr/include)
link_directories(/usr/lib)
include_directories(/usr/include)
link_directories(/usr/lib)
endif()

set(OpenGL_GL_PREFERENCE GLVND)

find_package(OpenGL REQUIRED)
if (NOT OPENGL_FOUND)
message(FATAL_ERROR "OpenGL not found. Please install OpenGL package.")
endif()

find_package(glfw3 CONFIG REQUIRED)
if (NOT glfw3_FOUND)
message(FATAL_ERROR "GLFW not found. Please install GLFW3 package.")
endif()

find_package(Lua 5.4 REQUIRED)
if(NOT LUA_FOUND)
message(FATAL_ERROR "Lua >= 5.4 not found. Please install lua5.4 and lua5.4-dev packages.")
endif()

# Add GLAD
add_library(glad STATIC
Expand Down Expand Up @@ -69,6 +82,8 @@ set(ENGINE_SOURCES
src/Noise/SimplexNoise/SimplexNoise.cpp
src/Noise/ValueNoise/ValueNoise.cpp
external/stb_image/src/stb_image.cpp
src/Scripting/LuaScriptSystem.cpp
src/Scene/Scene.cpp
${IMGUI_SOURCES}
)

Expand All @@ -82,12 +97,14 @@ target_include_directories(voxel-engine PUBLIC
${CMAKE_SOURCE_DIR}/external/stb_image/src
${CMAKE_SOURCE_DIR}/external/json
${CMAKE_SOURCE_DIR}/external/glad/include
${CMAKE_SOURCE_DIR}/external/sol2
)

target_link_libraries(voxel-engine PUBLIC
glfw
OpenGL::GL
glad
${LUA_LIBRARIES} # Add Lua libraries
)

# Create sandbox executable
Expand All @@ -98,21 +115,20 @@ set(SANDBOX_SOURCES
add_executable(sandbox ${SANDBOX_SOURCES})
target_link_libraries(sandbox PRIVATE voxel-engine)

add_custom_command(TARGET sandbox POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/sandbox/assets/scripts
${CMAKE_BINARY_DIR}/assets/scripts
)

add_custom_command(TARGET sandbox POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/assets $<TARGET_FILE_DIR:sandbox>/assets
)

# Enable precompiled headers - specify C++ explicitly
target_precompile_headers(voxel-engine
PRIVATE
$<INSTALL_INTERFACE:pch.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/pch.h>
)

# Force C++ compilation for PCH
set_source_files_properties(
${CMAKE_CURRENT_SOURCE_DIR}/src/pch.h
PROPERTIES
LANGUAGE CXX
)

# Ensure PCH is used for all C++ files
set_target_properties(voxel-engine PROPERTIES
COMPILE_FLAGS "-include pch.h"
)
Loading
Loading