Skip to content

Commit

Permalink
Merge pull request #43 from Nelonn/main
Browse files Browse the repository at this point in the history
Поддержка macOS
  • Loading branch information
MihailRis authored Dec 10, 2023
2 parents 5bc75c3 + eba062f commit 10a5a94
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,15 @@ Debug/src/**/*.o
Debug/voxel_engine

/build
/cmake-build-**
/screenshots

/world
/worlds/**/*
/settings.toml
/controls.json

/.idea
.vscode
/.vs
*.sln
Expand Down
13 changes: 9 additions & 4 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
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)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /source-charset:UTF-8")
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()
Expand All @@ -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")
Expand Down
8 changes: 7 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .
```

Expand All @@ -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
7 changes: 6 additions & 1 deletion src/window/Window.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 10a5a94

Please sign in to comment.