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}}
diff --git a/.gitignore b/.gitignore
index 6650ac54..6420e34a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,12 +3,15 @@ Debug/src/**/*.o
Debug/voxel_engine
+build
+
world
.vscode
+.cache
.settings
.cproject
.project
.git
-/Default/
+/Default/
\ No newline at end of file
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..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`
@@ -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 ` 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