From 45bc1643f4f6a8e98852674646ef47d54dcd839f Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 29 Jun 2022 20:00:24 +0300 Subject: [PATCH 1/5] Update .gitignore --- .gitignore | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/.gitignore b/.gitignore index 6bf13089..f1bcd4b5 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,10 @@ -Debug/src/*.d -Debug/src/*.o -Debug/src/*/*.d -Debug/src/*/*.o +Debug/src/**/*.d +Debug/src/**/*.o Debug/voxel_engine + +.vscode + +.settings +.cproject +.project From 36b92ce4a796261d15c3544df49496094776040d Mon Sep 17 00:00:00 2001 From: MihailRis Date: Mon, 29 Aug 2022 16:02:16 +0300 Subject: [PATCH 2/5] Update .gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index f1bcd4b5..da925adf 100644 --- a/.gitignore +++ b/.gitignore @@ -3,6 +3,8 @@ Debug/src/**/*.o Debug/voxel_engine +world + .vscode .settings From 30ad8385c9c3035a8763ea23323af32329f51b93 Mon Sep 17 00:00:00 2001 From: Che10VeK <64031910+C4e10VeK@users.noreply.github.com> Date: Wed, 2 Aug 2023 02:44:09 +0000 Subject: [PATCH 3/5] Added cmake support (#11) * Update README.md * added submodules * moved submodules to release tag * fix include for fixed width integer * added cmake support and build instruction * Update README.md * fix cmake links * upd CMakeLists.txt --- .gitignore | 3 +++ .gitmodules | 6 ++++++ CMakeLists.txt | 35 +++++++++++++++++++++++++++++++++++ README.md | 16 ++++++++++++++++ libs/glfw | 1 + libs/glm | 1 + src/audio/audioutil.h | 1 + 7 files changed, 63 insertions(+) create mode 100644 .gitmodules create mode 100644 CMakeLists.txt create mode 160000 libs/glfw create mode 160000 libs/glm diff --git a/.gitignore b/.gitignore index 30c69d45..6420e34a 100644 --- a/.gitignore +++ b/.gitignore @@ -3,10 +3,13 @@ Debug/src/**/*.o Debug/voxel_engine +build + world .vscode +.cache .settings .cproject .project diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000..59b8bea4 --- /dev/null +++ b/.gitmodules @@ -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 diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..7d7591eb --- /dev/null +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index c42ff866..b1812a54 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,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 +29,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 ` get headers `mingw.thread.h` and `mingw.invoke.h` from: diff --git a/libs/glfw b/libs/glfw new file mode 160000 index 00000000..7482de60 --- /dev/null +++ b/libs/glfw @@ -0,0 +1 @@ +Subproject commit 7482de6071d21db77a7236155da44c172a7f6c9e diff --git a/libs/glm b/libs/glm new file mode 160000 index 00000000..bf71a834 --- /dev/null +++ b/libs/glm @@ -0,0 +1 @@ +Subproject commit bf71a834948186f4097caa076cd2663c69a10e1e diff --git a/src/audio/audioutil.h b/src/audio/audioutil.h index f62a06cb..f48c261a 100644 --- a/src/audio/audioutil.h +++ b/src/audio/audioutil.h @@ -3,6 +3,7 @@ #include #include +#include #include From cd5016d93404ec98814c99ecee7d1bd16fb801c2 Mon Sep 17 00:00:00 2001 From: Che10VeK <64031910+C4e10VeK@users.noreply.github.com> Date: Wed, 2 Aug 2023 08:34:06 +0000 Subject: [PATCH 4/5] Create cmake.yml --- .github/workflows/cmake.yml | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 .github/workflows/cmake.yml diff --git a/.github/workflows/cmake.yml b/.github/workflows/cmake.yml new file mode 100644 index 00000000..0d8237ff --- /dev/null +++ b/.github/workflows/cmake.yml @@ -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}} From ee46a8ef66c1265bedb3f951dba1dc87b3ab5e5a Mon Sep 17 00:00:00 2001 From: MihailRis Date: Wed, 2 Aug 2023 12:59:52 +0300 Subject: [PATCH 5/5] Added controls section in README.md --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index b1812a54..8818b84a 100644 --- a/README.md +++ b/README.md @@ -3,6 +3,15 @@ [EXE for windows](https://drive.google.com/file/d/1lkFc5nyYOs0Yyu1wmOoAAwEp4r9jO1tE/view?usp=sharing)
[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`