Skip to content

Commit

Permalink
merge
Browse files Browse the repository at this point in the history
  • Loading branch information
A-lex-Ra committed Dec 25, 2023
2 parents ca36973 + ea812a3 commit 4d8c856
Show file tree
Hide file tree
Showing 47 changed files with 823 additions and 197 deletions.
37 changes: 37 additions & 0 deletions .github/workflows/appimage.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: C/C++ AppImage

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build-appimage:

runs-on: ubuntu-20.04

steps:
- uses: actions/checkout@v2
with:
submodules: 'true'
- name: install dependencies
run: |
sudo apt-get update
sudo apt-get install -y build-essential libglfw3-dev libglfw3 libglew-dev libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev cmake squashfs-tools
sudo ln -s /usr/lib/x86_64-linux-gnu/libluajit-5.1.a /usr/lib/x86_64-linux-gnu/liblua5.1.a
sudo ln -s /usr/include/luajit-2.1 /usr/include/lua
- name: configure
run: cmake -S . -B build -DCMAKE_BUILD_TYPE=Release -DVOXELENGINE_BUILD_APPDIR=1
- name: build
run: cmake --build build -t install
- name: Build AppImage
uses: AppImageCrafters/build-appimage-action@fe2205a4d6056be47051f7b1b3811106e9814910
env:
UPDATE_INFO: gh-releases-zsync|MihailRis|VoxelEngine-Cpp|latest|*x86_64.AppImage.zsync
with:
recipe: dev/AppImageBuilder.yml
- uses: actions/upload-artifact@v2
with:
name: AppImage
path: './*.AppImage*'
8 changes: 7 additions & 1 deletion .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,15 @@ jobs:
- uses: actions/checkout@v3

- name: Install packages
# If libluajit-5.1-dev is not available, use this:
# git clone https://luajit.org/git/luajit.git
# cd luajit
# make && make install INSTALL_INC=/usr/include/lua
run: |
sudo apt-get update
sudo apt-get install libglfw3-dev libglfw3 libglew-dev libglm-dev libpng-dev libopenal-dev
sudo apt-get install libglfw3-dev libglfw3 libglew-dev libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev
sudo ln -s /usr/lib/x86_64-linux-gnu/libluajit-5.1.a /usr/lib/x86_64-linux-gnu/liblua-5.1.a
sudo ln -s /usr/include/luajit-2.1 /usr/include/lua
- name: Configure CMake
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
Expand Down
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@ Debug/voxel_engine
.project
.git
/Default/
AppDir
appimage-build/

*~
28 changes: 26 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
cmake_minimum_required(VERSION 3.15)
project(VoxelEngine)

option(VOXELENGINE_BUILD_APPDIR OFF)

set(CMAKE_CXX_STANDARD 17)

file(GLOB_RECURSE HEADERS ${CMAKE_CURRENT_SOURCE_DIR}/src/*.hpp)
file(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/src/*.cpp)

add_executable(${PROJECT_NAME} ${HEADERS} ${SOURCES})

if(VOXELENGINE_BUILD_APPDIR)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/icons/hicolor/256x256)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/applications)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/VoxelEngine)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/VoxelEngine)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelEngine.png DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/icons/hicolor/256x256)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelEngine.png DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelEngine.png DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/.dirIcon)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelEngine.desktop DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/share/applications)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/dev/VoxelEngine.desktop DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
install(TARGETS VoxelEngine DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/AppDir/usr/bin)
endif()


if(MSVC)
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /O2)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /source-charset:UTF-8")
Expand All @@ -22,6 +43,8 @@ endif()
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(OpenAL REQUIRED)
# luajit has no CMakeLists.txt to use it as subdirectory, so install it
find_package(Lua REQUIRED)

if (WIN32)
set(PNGLIB spng)
Expand All @@ -46,7 +69,8 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie")
endif()


target_link_libraries(${PROJECT_NAME} ${LIBS} glfw OpenGL::GL ${OPENAL_LIBRARY} GLEW::GLEW ${PNGLIB})
include_directories(${LUA_INCLUDE_DIR})
target_link_libraries(${PROJECT_NAME} ${LIBS} glfw OpenGL::GL ${OPENAL_LIBRARY} GLEW::GLEW ${PNGLIB} ${LUA_LIBRARIES} ${CMAKE_DL_LIBS})

file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION ${CMAKE_CURRENT_BINARY_DIR})

42 changes: 35 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,54 @@ git clone --recursive https://github.com/MihailRis/VoxelEngine-Cpp.git
cd VoxelEngine-Cpp
mkdir build
cd build
cmake ..
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
```

## Install libs:

#### Debian-based distro:
`$ sudo apt install libglfw3-dev libglfw3 libglew-dev libglm-dev libpng-dev libopenal-dev`
```sh
sudo apt install libglfw3-dev libglfw3 libglew-dev libglm-dev libpng-dev libopenal-dev libluajit-5.1-dev
```

CMake missing LUA_INCLUDE_DIR and LUA_LIBRARIES fix:
```sh
sudo ln -s /usr/lib/x86_64-linux-gnu/libluajit-5.1.a /usr/lib/x86_64-linux-gnu/liblua5.1.a
sudo ln -s /usr/include/luajit-2.1 /usr/include/lua
```

#### RHEL-based distro:
`$ sudo dnf install glfw-devel glfw glew-devel glm-devel libpng-devel openal-devel`
```sh
sudo dnf install glfw-devel glfw glew-devel glm-devel libpng-devel openal-devel
```

\+ install LuaJIT

#### Arch-based distro:
If you use X11
`$ sudo pacman -S glfw-x11 glew glm libpng openal`
```sh
sudo pacman -S glfw-x11 glew glm libpng openal
```

If you use Wayland
`$ sudo pacman -S glfw-wayland glew glm libpng openal`
```sh
sudo pacman -S glfw-wayland glew glm libpng openal
```

\+ install LuaJIT

#### LuaJIT installation:
```sh
git clone https://luajit.org/git/luajit.git
cd luajit
make && sudo make install INSTALL_INC=/usr/include/lua
```

#### macOS:

`$ brew install glfw3 glew glm libpng`
```
brew install glfw3 glew glm libpng
```

Download, compile and install OpenAL
Download, compile and install OpenAL and LuaJIT
75 changes: 75 additions & 0 deletions dev/AppImageBuilder.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
version: 1
AppDir:
path: AppDir
app_info:
id: VoxelEngine
name: VoxelEngine
icon: VoxelEngine
version: latest
exec: usr/bin/VoxelEngine
exec_args: --dir $HOME --res $APPDIR/usr/share/VoxelEngine/res $@
apt:
arch: amd64
sources:
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal main restricted universe multiverse
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x3b4fe6acc0b21f32'
key_url: 'http://keyserver.ubuntu.com/pks/lookup?op=get&search=0x871920D1991BC93C'
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-updates main restricted universe multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-backports main restricted universe multiverse
- sourceline: deb http://archive.ubuntu.com/ubuntu/ focal-security main restricted universe multiverse
include:
- libbz2-1.0
- libexpat1
- libfam0
- libgcrypt20
- libglfw3
- libglew2.1
- libpng16-16
- libopenal1
- libopengl0
- libasound2
- libglx0
exclude:
- hicolor-icon-theme
- sound-theme-freedesktop
- perl
- perl-base
- kwayland-data
- libwacom2
- libasound2
- breeze
- breeze-icon-theme
- breeze-cursor-theme
- kwin-style-breeze
- kde-style-breeze
- plasma-integration
files:
exclude:
- usr/share/man
- usr/share/doc/*/README.*
- usr/share/doc/*/changelog.*
- usr/share/doc/*/NEWS.*
- usr/share/doc/*/TODO.*
test:
fedora:
image: appimagecrafters/tests-env:fedora-30
command: ./AppRun
use_host_x: true
debian:
image: appimagecrafters/tests-env:debian-stable
command: ./AppRun
use_host_x: true
arch:
image: appimagecrafters/tests-env:archlinux-latest
command: ./AppRun
use_host_x: true
centos:
image: appimagecrafters/tests-env:centos-7
command: ./AppRun
use_host_x: true
ubuntu:
image: appimagecrafters/tests-env:ubuntu-xenial
command: ./AppRun
use_host_x: true
AppImage:
arch: x86_64
10 changes: 10 additions & 0 deletions dev/VoxelEngine.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[Desktop Entry]
Version=1.0
Type=Application
Name=VoxelEngine
Comment=Minecraft-like game engine in C++ with OpenGL
TryExec=VoxelEngine
Exec=VoxelEngine
Icon=VoxelEngine
MimeType=image/x-foo;
Categories=Game;
Binary file added dev/VoxelEngine.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion res/content/base/blocks/flower.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"light-passing": true,
"obstacle": false,
"replaceable": true,
"grounded": true,
"model": "X",
"hitbox": [0.15, 0.0, 0.15, 0.7, 0.7, 0.7]
}
}
3 changes: 2 additions & 1 deletion res/content/base/blocks/grass.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"light-passing": true,
"obstacle": false,
"replaceable": true,
"grounded": true,
"model": "X",
"hitbox": [0.15, 0.0, 0.15, 0.7, 0.7, 0.7]
}
}
2 changes: 1 addition & 1 deletion res/content/base/blocks/torch.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
],
"emission": [13, 13, 12],
"model": "aabb",
"hitbox": [0.3, 0.0, 0.7, 0.125, 0.5, 0.125],
"hitbox": [0.4375, 0.0, 0.4375, 0.125, 0.5, 0.125],
"light-passing": true,
"obstacle": false,
"rotation": "pipe"
Expand Down
16 changes: 0 additions & 16 deletions res/content/base/blocks/wallpaper.json

This file was deleted.

3 changes: 1 addition & 2 deletions res/content/base/content.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
"pane",
"pipe",
"lightbulb",
"torch",
"wallpaper"
"torch"
]
}
20 changes: 20 additions & 0 deletions res/content/base/scripts/grass_block.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
function on_random_update(x, y, z)
local dirtid = block_index('base:dirt');
if is_solid_at(x, y+1, z) then
set_block(x, y, z, dirtid)
else
local grassblockid = block_index('base:grass_block')
for lx=-1,1 do
for ly=-1,1 do
for lz=-1,1 do
if get_block(x + lx, y + ly, z + lz) == dirtid then
if not is_solid_at(x + lx, y + ly + 1, z + lz) then
set_block(x + lx, y + ly, z + lz, grassblockid)
return
end
end
end
end
end
end
end
Binary file removed res/content/base/textures/blocks/wallpaper_s.png
Binary file not shown.
Empty file added res/scripts/world.lua
Empty file.
24 changes: 12 additions & 12 deletions src/assets/AssetsLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,18 +50,18 @@ void AssetsLoader::createDefaults(AssetsLoader& loader) {
loader.addLoader(ASSET_ATLAS, assetload::atlas);
}

void AssetsLoader::addDefaults(AssetsLoader& loader) {
loader.add(ASSET_SHADER, SHADERS_FOLDER"/main", "main");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/lines", "lines");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/ui", "ui");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/ui3d", "ui3d");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/background", "background");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/skybox_gen", "skybox_gen");

loader.add(ASSET_ATLAS, TEXTURES_FOLDER"/blocks", "blocks");
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/menubg.png", "menubg");

loader.add(ASSET_FONT, FONTS_FOLDER"/font", "normal");
void AssetsLoader::addDefaults(AssetsLoader& loader, bool allAssets) {
if (allAssets) {
loader.add(ASSET_SHADER, SHADERS_FOLDER"/main", "main");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/lines", "lines");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/ui", "ui");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/ui3d", "ui3d");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/background", "background");
loader.add(ASSET_SHADER, SHADERS_FOLDER"/skybox_gen", "skybox_gen");
loader.add(ASSET_TEXTURE, TEXTURES_FOLDER"/menubg.png", "menubg");
loader.add(ASSET_FONT, FONTS_FOLDER"/font", "normal");
}
loader.add(ASSET_ATLAS, TEXTURES_FOLDER"/blocks", "blocks");
}

const ResPaths* AssetsLoader::getPaths() const {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/AssetsLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ class AssetsLoader {
bool loadNext();

static void createDefaults(AssetsLoader& loader);
static void addDefaults(AssetsLoader& loader);
static void addDefaults(AssetsLoader& loader, bool allAssets);

const ResPaths* getPaths() const;
};
Expand Down
Loading

0 comments on commit 4d8c856

Please sign in to comment.