diff --git a/.gitignore b/.gitignore index 55057c5a2..aa5d689ac 100644 --- a/.gitignore +++ b/.gitignore @@ -4,6 +4,7 @@ Debug/src/**/*.o Debug/voxel_engine /build +/cmake-build-** /screenshots /world @@ -11,6 +12,7 @@ Debug/voxel_engine /settings.toml /controls.json +/.idea .vscode /.vs *.sln diff --git a/CMakeLists.txt b/CMakeLists.txt index 1bef14997..c8429711f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,11 +1,12 @@ cmake_minimum_required(VERSION 3.15) project(VoxelEngine) +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}) -target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17) if(MSVC) target_compile_options(${PROJECT_NAME} PRIVATE /W4) @@ -13,7 +14,7 @@ if(MSVC) else() target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra -lstdc++fs # additional warnings - -Wformat-nonliteral -Wcast-align + -Wformat-nonliteral -Wcast-align -Wpointer-arith -Wundef -Wwrite-strings -Wno-unused-parameter) endif() @@ -28,14 +29,18 @@ if (WIN32) else() find_package(PNG REQUIRED) set(PNGLIB PNG::PNG) -endif(WIN32) +endif() + +if (APPLE) + find_package(glfw3 3.3 REQUIRED) +endif () set(LIBS "") if(UNIX) find_package(Threads REQUIRED) set(LIBS ${LIBS} Threads::Threads) -endif(UNIX) +endif() if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -no-pie") diff --git a/README.md b/README.md index 1f5d51f34..066b8eea0 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ git clone --recursive https://github.com/MihailRis/VoxelEngine-Cpp.git cd VoxelEngine-Cpp mkdir build cd build -cmake ../ +cmake .. cmake --build . ``` @@ -39,3 +39,9 @@ If you use X11 If you use Wayland `$ sudo pacman -S glfw-wayland glew glm libpng openal` + +#### macOS: + +`$ brew install glfw3 glew glm libpng` + +Download, compile and install OpenAL diff --git a/src/window/Window.cpp b/src/window/Window.cpp index 6a4f72c66..d6b0eee30 100644 --- a/src/window/Window.cpp +++ b/src/window/Window.cpp @@ -132,7 +132,12 @@ int Window::initialize(DisplaySettings& settings){ glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE); +#ifdef __APPLE__ + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); +#else + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_ANY_PROFILE); +#endif glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); glfwWindowHint(GLFW_SAMPLES, settings.samples);