Merge pull request #13 from MihailRis/main

Merge changes from main to v13
This commit is contained in:
MihailRis 2023-09-19 10:56:31 +03:00 committed by GitHub
commit 0837f8945f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 108 additions and 1 deletions

35
.github/workflows/cmake.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: CMake
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
env:
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
BUILD_TYPE: Release
jobs:
build:
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
# You can convert this to a matrix build if you need cross-platform coverage.
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install packages
run: |
sudo apt-get update
sudo apt-get install libglfw3-dev libglfw3 libglew-dev libglm-dev libpng-dev libopenal-dev
- 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.
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
- name: Build
# Build your program with the given configuration
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}

5
.gitignore vendored
View File

@ -3,12 +3,15 @@ Debug/src/**/*.o
Debug/voxel_engine
build
world
.vscode
.cache
.settings
.cproject
.project
.git
/Default/
/Default/

6
.gitmodules vendored Normal file
View File

@ -0,0 +1,6 @@
[submodule "libs/glm"]
path = libs/glm
url = https://github.com/g-truc/glm.git
[submodule "libs/glfw"]
path = libs/glfw
url = https://github.com/glfw/glfw.git

35
CMakeLists.txt Normal file
View File

@ -0,0 +1,35 @@
cmake_minimum_required(VERSION 3.15)
project(VoxelEngine)
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})
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
option(VE_USE_SYSTEM_LIBS "Use system installed libraries" ON)
find_package(OpenGL REQUIRED)
find_package(GLEW REQUIRED)
find_package(OpenAL REQUIRED)
find_package(PNG REQUIRED)
set(LIBS "")
if(NOT VE_USE_SYSTEM_LIBS)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libs/glfw)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/libs/glm)
set(LIBS glm)
else()
find_package(glfw3 REQUIRED)
find_package(glm REQUIRED)
endif(NOT VE_USE_SYSTEM_LIBS)
if(UNIX)
find_package(Threads REQUIRED)
set(LIBS ${LIBS} Threads::Threads)
endif(UNIX)
target_link_libraries(${PROJECT_NAME} ${LIBS} glfw OpenGL::GL ${OPENAL_LIBRARY} GLEW::GLEW PNG::PNG)
file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/res DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/build)

View File

@ -3,6 +3,15 @@
[EXE for windows](https://drive.google.com/file/d/1lkFc5nyYOs0Yyu1wmOoAAwEp4r9jO1tE/view?usp=sharing)<br>
[MinGW libraries (include & lib) + glew32.dll](https://drive.google.com/file/d/1k1Hnbz2Uhr4-03upt2yHxKws396HQDra/view?usp=sharing)
# Controls:
- **Tab** - toggle camera control
- **W,A,S,D** - movement
- **Space** - jump
- **LMB** - remove block
- **RMB** - place block
- **F** - toggle flight mode
- **Esc** - exit
# Run in linux:
`$ git clone https://github.com/MihailRis/VoxelEngine-Cpp.git`
@ -12,6 +21,16 @@
`$ ./voxel_engine`
#### Build with CMake
```sh
git clone --recursive https://github.com/MihailRis/VoxelEngine-Cpp.git
cd VoxelEngine-Cpp
mkdir build
cd build
cmake ../
cmake --build .
```
## Instal libs:
#### Debian-based distro:
`$ sudo apt install libglfw3-dev libglfw3 libglew-dev libglm-dev libpng-dev libopenal-dev`
@ -19,6 +38,12 @@
#### RHEL-based distro:
`$ sudo dnf install glfw-devel glfw glew-devel glm-devel libpng-devel openal-devel`
#### Arch-based distro:
If you use X11
`$ sudo pacman -S glfw-x11 glew glm libpng openal`
If you use Wayland
`$ sudo pacman -S glfw-wayland glew glm libpng openal`
# Note for MinGW compiling:
To fix problem with `#include <mingw.thread.h>` get headers `mingw.thread.h` and `mingw.invoke.h` from:

1
libs/glfw Submodule

@ -0,0 +1 @@
Subproject commit 7482de6071d21db77a7236155da44c172a7f6c9e

1
libs/glm Submodule

@ -0,0 +1 @@
Subproject commit bf71a834948186f4097caa076cd2663c69a10e1e

View File

@ -3,6 +3,7 @@
#include <string>
#include <type_traits>
#include <cstdint>
#include <AL/al.h>