Skip to content

Commit

Permalink
Merge pull request #68 from edunad/features/wrappers
Browse files Browse the repository at this point in the history
Add missing lua wrappers
  • Loading branch information
edunad authored Aug 16, 2023
2 parents bea6e01 + f44e01a commit 0b9ed43
Show file tree
Hide file tree
Showing 151 changed files with 3,440 additions and 614 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ jobs:
run: |
sudo apt update
sudo apt upgrade -y
sudo apt install -y build-essential wget cmake libvpx-dev gcc-11 libgl1-mesa-glx libgl1-mesa-dev libglew-dev ninja-build python3-pip libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev
sudo apt install -y build-essential wget cmake libssl-dev libvpx-dev gcc-11 libgl1-mesa-glx libgl1-mesa-dev libglew-dev ninja-build python3-pip libx11-dev libx11-xcb-dev libfontenc-dev libice-dev libsm-dev libxau-dev libxaw7-dev libxcomposite-dev libxcursor-dev libxdamage-dev libxdmcp-dev libxext-dev libxfixes-dev libxft-dev libxi-dev libxinerama-dev libxkbfile-dev libxmu-dev libxmuu-dev libxpm-dev libxrandr-dev libxrender-dev libxres-dev libxss-dev libxt-dev libxtst-dev libxv-dev libxvmc-dev libxxf86vm-dev xtrans-dev libxcb-render0-dev libxcb-render-util0-dev libxcb-xkb-dev libxcb-icccm4-dev libxcb-image0-dev libxcb-keysyms1-dev libxcb-randr0-dev libxcb-shape0-dev libxcb-sync-dev libxcb-xfixes0-dev libxcb-xinerama0-dev xkb-data libxcb-dri3-dev uuid-dev libxcb-util-dev
- name: Restore cache
id: cache
Expand All @@ -40,7 +40,7 @@ jobs:
path: |
./build
~/cpm-cache
key: host-${{ runner.os }}-${{ hashFiles('./CMakeLists.txt', './bass/CMakeLists.txt', './engine/CMakeLists.txt', './math/CMakeLists.txt', './render/CMakeLists.txt', './resources/CMakeLists.txt', './ui/CMakeLists.txt', './utils/CMakeLists.txt', './physics_3d/CMakeLists.txt', './physics_2d/CMakeLists.txt', './webm/CMakeLists.txt', './assimp/CMakeLists.txt') }}
key: host-${{ runner.os }}-${{ hashFiles('./CMakeLists.txt', './bass/CMakeLists.txt', './engine/CMakeLists.txt', './math/CMakeLists.txt', './render/CMakeLists.txt', './resources/CMakeLists.txt', './ui/CMakeLists.txt', './utils/CMakeLists.txt', './physics_3d/CMakeLists.txt', './physics_2d/CMakeLists.txt', './webm/CMakeLists.txt', './assimp/CMakeLists.txt', './scripting/CMakeLists.txt') }}

- name: Build
id: build
Expand All @@ -58,7 +58,7 @@ jobs:
path: |
./build
~/cpm-cache
key: host-${{ runner.os }}-${{ hashFiles('./CMakeLists.txt', './bass/CMakeLists.txt', './engine/CMakeLists.txt', './math/CMakeLists.txt', './render/CMakeLists.txt', './resources/CMakeLists.txt', './ui/CMakeLists.txt', './utils/CMakeLists.txt', './physics_3d/CMakeLists.txt', './physics_2d/CMakeLists.txt', './webm/CMakeLists.txt', './assimp/CMakeLists.txt') }}
key: host-${{ runner.os }}-${{ hashFiles('./CMakeLists.txt', './bass/CMakeLists.txt', './engine/CMakeLists.txt', './math/CMakeLists.txt', './render/CMakeLists.txt', './resources/CMakeLists.txt', './ui/CMakeLists.txt', './utils/CMakeLists.txt', './physics_3d/CMakeLists.txt', './physics_2d/CMakeLists.txt', './webm/CMakeLists.txt', './assimp/CMakeLists.txt', './scripting/CMakeLists.txt') }}

- name: Run tests
run: |
Expand Down
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@
"isTable",
"isString",
"json",
"fmt"
"fmt",
"printTable",
"scripting",
"stencil",
"http",
"curtime",
"BGFX_FRAME"
]
}
2 changes: 1 addition & 1 deletion .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
{
"label": "Clean project",
"type": "shell",
"command": "rm -rf build bin .cache",
"command": "rm -rf build bin .cache bass/deps webm/deps",
"group": "build",
"options": {
"cwd": "${workspaceFolder}"
Expand Down
33 changes: 25 additions & 8 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ list(PREPEND CONAN_GENERATORS_FOLDER ${CMAKE_BINARY_DIR})
# ---

# OPTIONS ---
option(BUILD_TESTING "Build tests" ON)
option(RAWRBOX_BUILD_TESTING "Build tests" ON)
option(RAWRBOX_USE_WAYLAND "Use Wayland for linux" OFF)

option(RAWRBOX_BUILD_SAMPLES "Build samples" ON)
Expand Down Expand Up @@ -52,6 +52,7 @@ if(RAWRBOX_BUILD_RAWRBOX_3D_PHYSICS)
endif()

option(RAWRBOX_ENABLE_QHULL "Include QHull on utils" ON)
option(RAWRBOX_ENABLE_HTTP_REQUEST "Include HTTP requests on utils" ON)
# -----

# OTHER SETTINGS ----
Expand Down Expand Up @@ -97,11 +98,7 @@ set(CMAKE_SKIP_RPATH TRUE)
set(CMAKE_SKIP_BUILD_RPATH TRUE)
# ---------------------------------

# SETUP CCACHE ---
CPMAddPackage("gh:TheLartians/[email protected]")
# --------------

# PACKAGES ------
# GLOBAL PACKAGES ------
CPMAddPackage("gh:fmtlib/fmt#10.0.0")
if(fmt_ADDED)
set_lib_runtime_mt(fmt)
Expand All @@ -115,6 +112,22 @@ endif()
if(NOT WIN32 AND RAWRBOX_USE_WAYLAND)
CPMAddPackage("gl:wayland/[email protected]")
endif()

CPMAddPackage(
NAME
nlohmann_json
VERSION
3.11.2
# the git repo is incredibly large, so we download the archived include directory
URL
https://github.com/nlohmann/json/releases/download/v3.11.2/include.zip
URL_HASH
SHA256=e5c7a9f49a16814be27e4ed0ee900ecd0092bfb7dbfca65b5a421b774dccaaed)

if(nlohmann_json_ADDED)
add_library(nlohmann_json INTERFACE IMPORTED)
target_include_directories(nlohmann_json INTERFACE ${nlohmann_json_SOURCE_DIR}/include)
endif()
# --------------------

add_subdirectory("math")
Expand Down Expand Up @@ -164,6 +177,10 @@ if(RAWRBOX_BUILD_RAWRBOX_2D_PHYSICS)
endif()

if(RAWRBOX_BUILD_SAMPLES)
message(STATUS "Enabled SAMPLES building")
add_subdirectory("samples")
if(NOT RAWRBOX_BUILD_RAWRBOX_RESOURCES)
message(WARNING "Samples require RAWRBOX.RESOURCES to be enabled")
else()
message(STATUS "Enabled SAMPLES building")
add_subdirectory("samples")
endif()
endif()
28 changes: 16 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,24 +25,26 @@

# FEATURES (so far)

- Model loading (animations, light, texture import) using assimp
- Model loading (animations, light, texture import) using [assimp](https://github.com/assimp/assimp)
- Light support (point, spot, directional)
- Clustered rendering
- Clustered rendering & support for other type of rendering
- 3D text
- 2D stencil drawing
- Fonts
- Images (png, jpeg, tga, bitmap)
- Video (webm)
- Sounds (using BASS lib)
- Fonts (ttf) using [stb](https://github.com/nothings/stb)
- JSON loading using [nlohmann json](https://github.com/nlohmann/json)
- Images (png, jpeg, tga, bitmap, gif) using [stb](https://github.com/nothings/stb)
- Video ([webm](https://github.com/webmproject/libwebm))
- Sounds (using [BASS](https://www.un4seen.com/) lib)
- Custom UI
- Material system (similar to unity)
- GIF loading & animation
- Vulkan / DirectX / OpenGL support
- Vulkan / DirectX / OpenGL support using [BGFX](https://github.com/bkaradzic/bgfx)
- Linux Wayland support + steam deck support
- 3D Physics system using [JoltPhysics](https://github.com/jrouwe/JoltPhysics)
- 2D Physics system using [Muli](https://github.com/Sopiro/Muli)
- Decal system
- Scripting / modding support with LUA
- Scripting / modding support with LUA using [sol2](https://github.com/ThePhD/sol2) and [luajit2](https://github.com/openresty/luajit2)
- Post-processing effects support
- HTTP / HTTPS requests using curl + [libcpr](https://github.com/libcpr/cpr)

# TODO LIST

Expand Down Expand Up @@ -79,14 +81,15 @@

| OPTION NAME | NOTE |
| :------------------------------------------- | :------------------------------------------------------------------------------------------------- |
| `BUILD_TESTING` | Builds & enables project tests |
| `RAWRBOX_BUILD_TESTING` | Builds & enables project tests |
| -- | -- |
| `RAWRBOX_OUTPUT_BIN` | The output build folder. Default is `bin` |
| `RAWRBOX_CONTENT_FOLDER` | The content folder to output resources. Default is `content` |
| -- | -- |
| `RAWRBOX_USE_WAYLAND` | Enables WAYLAND compiling on LINUX |
| -- | -- |
| `RAWRBOX_ENABLE_QHULL` | Enables QHull util |
| `RAWRBOX_ENABLE_HTTP_REQUEST` | Enables HTTP / HTTPS requests util |
| -- | -- |
| `RAWRBOX_BUILD_SAMPLES` | Builds the project sample |
| `RAWRBOX_BUILD_RAWRBOX_UI` | Builds and includes ui |
Expand Down Expand Up @@ -124,6 +127,7 @@
| muli | ✖️ | Used for managing 2D physics |
| webmlib & vpx | ✖️ | Used for loading webm |
| lua & sol2 & luajit | ✖️ | Used for loading & managing lua scripting |
| curl + libcpr | ✖️ | Used for HTTP / HTTPS requests |

# BUILDING

Expand Down Expand Up @@ -160,7 +164,7 @@

### 001-stencil

<a href='/samples/001-stencil'><img src="https://i.rawr.dev/ycW6AgfHss-min.gif" width=512 /></a>
<a href='/samples/001-stencil'><img src="https://i.rawr.dev/Pu8XDzsdXt-min.gif" width=512 /></a>

### 002-generated-models

Expand Down Expand Up @@ -192,7 +196,7 @@

### 009-physics

<a href='/samples/009-physics'><img src="https://i.rawr.dev/Ir57QELn6F-min3.gif" width=512 /></a>
<a href='/samples/009-physics-3d'><img src="https://i.rawr.dev/Ir57QELn6F-min3.gif" width=512 /></a>

### 010-instancing

Expand Down
71 changes: 37 additions & 34 deletions assimp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,39 +3,48 @@ project("RAWRBOX.ASSIMP" VERSION ${RAWRBOX_VERSION} DESCRIPTION "RawrBox - ASSIM
set(output_target RAWRBOX.ASSIMP)

# LIBS ---
find_package(ZLIB QUIET)
if(ZLIB_FOUND)
message(STATUS "Found zlib, turning off build zlib on assimp")
set(BUILD_ZLIB 0)
set(ZLIB_FOUND 0) # Because assimp will then try to install invalid targets
else()
set(BUILD_ZLIB 1)
endif()

CPMAddPackage(
NAME
assimp
VERSION
5.2.5
GIT_TAG
master
GITHUB_REPOSITORY
assimp/assimp
OPTIONS
"BUILD_SHARED_LIBS OFF"
"ASSIMP_NO_EXPORT ON"
"ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT OFF"
"ASSIMP_INSTALL ON"
"ASSIMP_BUILD_ASSIMP_TOOLS OFF"
"ASSIMP_BUILD_TESTS OFF"
"ASSIMP_BUILD_SAMPLES OFF"
"ASSIMP_BUILD_DOCS OFF"
"USE_STATIC_CRT ON"
"ASSIMP_BUILD_ASSIMP_VIEW OFF"
"ASSIMP_BUILD_ZLIB TRUE"
"ASSIMP_WARNINGS_AS_ERRORS OFF"
"ASSIMP_INSTALL_PDB OFF"
"ASSIMP_BUILD_DRACO OFF"
"ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT OFF"
"ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT OFF"
"BUILD_SHARED_LIBS 0"
"ASSIMP_NO_EXPORT 1"
"ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT 0"
"ASSIMP_INSTALL 1"
"ASSIMP_BUILD_ASSIMP_TOOLS 0"
"ASSIMP_BUILD_TESTS 0"
"ASSIMP_BUILD_SAMPLES 0"
"ASSIMP_BUILD_DOCS 0"
"USE_STATIC_CRT 1"
"ASSIMP_BUILD_ASSIMP_VIEW 0"
"ASSIMP_BUILD_ZLIB ${BUILD_ZLIB}"
"ASSIMP_WARNINGS_AS_ERRORS 0"
"ASSIMP_INSTALL_PDB 0"
"ASSIMP_BUILD_DRACO 0"
"ASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT 0"
"ASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT 0"
# IMPORT SUPPORTS
"ASSIMP_BUILD_OBJ_IMPORTER ON"
"ASSIMP_BUILD_FBX_IMPORTER ON"
"ASSIMP_BUILD_DAE_IMPORTER ON"
"ASSIMP_BUILD_STL_IMPORTER ON"
"ASSIMP_BUILD_GLTF_IMPORTER ON"
"ASSIMP_BUILD_3DS_IMPORTER ON"
# "ASSIMP_BUILD_MDL_IMPORTER ON"
"ASSIMP_BUILD_MD5_IMPORTER ON")
"ASSIMP_BUILD_OBJ_IMPORTER 1"
"ASSIMP_BUILD_FBX_IMPORTER 1"
"ASSIMP_BUILD_DAE_IMPORTER 1"
"ASSIMP_BUILD_STL_IMPORTER 1"
"ASSIMP_BUILD_GLTF_IMPORTER 1"
"ASSIMP_BUILD_3DS_IMPORTER 1"
# "ASSIMP_BUILD_MDL_IMPORTER 1"
"ASSIMP_BUILD_MD5_IMPORTER 1")
# ----

# Grab source files
Expand All @@ -44,14 +53,8 @@ file(GLOB_RECURSE RAWRBOX_ASSIMP_IMPORTS "src/*.cpp" "include/*.hpp")
if(RAWRBOX_BUILD_RAWRBOX_RESOURCES)
set(RAWRBOX_EXTRA_LIBS RAWRBOX.RESOURCES)
else()
if(NOT RAWRBOX_BUILD_RAWRBOX_RESOURCES)
foreach(TMP_PATH ${RAWRBOX_ASSIMP_IMPORTS})
string(FIND ${TMP_PATH} "/resources/" EXCLUDE_DIR_FOUND)
if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM RAWRBOX_ASSIMP_IMPORTS ${TMP_PATH})
endif()
endforeach(TMP_PATH)
endif()
remove_folder("${RAWRBOX_ASSIMP_IMPORTS}" "/resources/")
set(RAWRBOX_ASSIMP_IMPORTS "${CLEAN_SOURCES}")
endif()
# ----

Expand Down
12 changes: 6 additions & 6 deletions assimp/include/rawrbox/assimp/importer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,15 @@ namespace rawrbox {
uint64_t blending = BGFX_STATE_BLEND_NORMAL;

OptionalTexture diffuse = std::nullopt;
rawrbox::Colorf diffuseColor = rawrbox::Colors::White;
rawrbox::Colorf diffuseColor = rawrbox::Colors::White();

std::unique_ptr<rawrbox::TextureBase> normal = nullptr;
std::unique_ptr<rawrbox::TextureBase> specular = nullptr;
rawrbox::Colorf specularColor = rawrbox::Colors::White;
rawrbox::Colorf specularColor = rawrbox::Colors::White();
float shininess = 25.F;

std::unique_ptr<rawrbox::TextureBase> emissive = nullptr;
rawrbox::Colorf emissionColor = rawrbox::Colors::White;
rawrbox::Colorf emissionColor = rawrbox::Colors::White();
float intensity = 1.F;

explicit AssimpMaterial(std::string _name) : name(std::move(_name)){};
Expand All @@ -65,9 +65,9 @@ namespace rawrbox {
std::string name = "light";
std::string parentID = "";

rawrbox::Colorf diffuse = rawrbox::Colors::White;
rawrbox::Colorf specular = rawrbox::Colors::White;
rawrbox::Colorf ambient = rawrbox::Colors::Black;
rawrbox::Colorf diffuse = rawrbox::Colors::White();
rawrbox::Colorf specular = rawrbox::Colors::White();
rawrbox::Colorf ambient = rawrbox::Colors::Black();

rawrbox::Vector3f pos = {};
rawrbox::Vector3f direction = {};
Expand Down
19 changes: 11 additions & 8 deletions bass/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,17 @@ file(GLOB_RECURSE RAWRBOX_BASS_SOURCES "src/*.cpp" "include/*.hpp")
if(RAWRBOX_BUILD_RAWRBOX_RESOURCES)
set(RAWRBOX_EXTRA_LIBS RAWRBOX.RESOURCES)
else()
if(NOT RAWRBOX_BUILD_RAWRBOX_RESOURCES)
foreach(TMP_PATH ${RAWRBOX_BASS_SOURCES})
string(FIND ${TMP_PATH} "/resources/" EXCLUDE_DIR_FOUND)
if(NOT ${EXCLUDE_DIR_FOUND} EQUAL -1)
list(REMOVE_ITEM RAWRBOX_BASS_SOURCES ${TMP_PATH})
endif()
endforeach(TMP_PATH)
remove_folder("${RAWRBOX_BASS_SOURCES}" "/resources/")
set(RAWRBOX_BASS_SOURCES "${CLEAN_SOURCES}")
endif()

if(RAWRBOX_BUILD_RAWRBOX_SCRIPTING)
if(NOT RAWRBOX_BUILD_RAWRBOX_RESOURCES) # RAWRBOX.RESOURCES already includes scripting if RAWRBOX_BUILD_RAWRBOX_SCRIPTING is enabled
list(APPEND RAWRBOX_EXTRA_LIBS RAWRBOX.SCRIPTING)
endif()
else()
remove_folder("${RAWRBOX_BASS_SOURCES}" "/scripting/")
set(RAWRBOX_BASS_SOURCES "${CLEAN_SOURCES}")
endif()
# ----

Expand Down Expand Up @@ -56,6 +59,6 @@ target_compile_definitions(${output_target} PRIVATE _CRT_SECURE_NO_WARNINGS NOMI
target_compile_definitions(${output_target} PUBLIC RAWRBOX_BASS)
target_include_directories(${output_target} PUBLIC "include")
target_compile_features(${output_target} PUBLIC cxx_std_${CMAKE_CXX_STANDARD})
target_link_libraries(${output_target} PUBLIC RAWRBOX.ENGINE RAWRBOX.MATH ${RAWRBOX_EXTRA_LIBS} fmt::fmt BASS::BASS BASS::FX)
target_link_libraries(${output_target} PUBLIC RAWRBOX.ENGINE RAWRBOX.MATH ${RAWRBOX_EXTRA_LIBS} BASS::BASS BASS::FX)

set_lib_runtime_mt(${output_target})
18 changes: 18 additions & 0 deletions bass/include/rawrbox/bass/scripting/plugin.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#pragma once
#include <rawrbox/scripting/plugin.hpp>

namespace rawrbox {
class BASSPlugin : public rawrbox::Plugin {
public:
void registerTypes(sol::state& lua) override {
}

void registerGlobal(rawrbox::Mod* mod) override {
if (mod == nullptr) throw std::runtime_error("[RawrBox-BASSPlugin] Tried to register plugin on invalid mod!");
}

void loadLuaExtensions(rawrbox::Mod* mod) override {
if (mod == nullptr) throw std::runtime_error("[RawrBox-BASSPlugin] Tried to register plugin on invalid mod!");
}
};
} // namespace rawrbox
Loading

1 comment on commit 0b9ed43

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cpp-Linter Report ⚠️

Some files did not pass the configured checks!

clang-tidy reports: 2 concern(s)
  • bass/src/sound/instance.cpp

    /bass/src/sound/instance.cpp:30:8: error: [clang-analyzer-optin.cplusplus.VirtualCall,-warnings-as-errors]

    Call to virtual method 'SoundInstance::isCreated' during destruction bypasses virtual dispatch

                    if (!this->isCreated()) return;
                         ^~~~~~~~~~~~~~~~~
    /runner/_work/rawrbox/rawrbox/bass/src/sound/instance.cpp:30:8: note: Call to virtual method 'SoundInstance::isCreated' during destruction bypasses virtual dispatch
                    if (!this->isCreated()) return;
                         ^~~~~~~~~~~~~~~~~
  • render/src/scripting/wrappers/light/manager_wrapper.cpp

    /render/src/scripting/wrappers/light/manager_wrapper.cpp:74:59: error: [misc-unused-parameters,-warnings-as-errors]

    parameter 'indx' is unused

            rawrbox::LightBaseWrapper LightsWrapper::getLight(size_t indx) {
                                                                     ^~~~
                                                                      /*indx*/

Have any feedback or feature suggestions? Share it here.

Please sign in to comment.