Compare commits

...

7 commits

14 changed files with 128 additions and 12 deletions

View file

@ -1,8 +1,10 @@
cmake_minimum_required(VERSION 3.31..) cmake_minimum_required(VERSION 3.30.0)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 20)
project(openblocks VERSION 0.1.0) project(openblocks VERSION 0.1.0)
set(OpenGL_GL_PREFERENCE "GLVND") set(OpenGL_GL_PREFERENCE "GLVND")
set( CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )
set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin ) set( CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin )
set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) set( CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib ) set( CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib )
@ -11,4 +13,7 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
add_subdirectory(core) add_subdirectory(core)
add_subdirectory(client) add_subdirectory(client)
add_subdirectory(editor) add_subdirectory(editor)
install(FILES $<TARGET_RUNTIME_DLLS:editor> TYPE BIN)

13
CMakePresets.json Normal file
View file

@ -0,0 +1,13 @@
{
"version": 2,
"configurePresets": [
{
"name": "vcpkg",
"generator": "Visual Studio 17 2022",
"binaryDir": "${sourceDir}/build",
"cacheVariables": {
"CMAKE_TOOLCHAIN_FILE": "$env{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
}
}
]
}

13
CMakeUserPresets.json Normal file
View file

@ -0,0 +1,13 @@
{
"version": 2,
"configurePresets": [
{
"name": "default",
"inherits": "vcpkg",
"environment": {
"VCPKG_ROOT": "C:\\Program Files\\Microsoft Visual Studio\\2022\\Community\\VC\\vcpkg\\vcpkg.exe"
}
}
]
}

30
cmake/FindStb.cmake Normal file
View file

@ -0,0 +1,30 @@
# Distributed under the OSI-approved BSD 3-Clause License.
# Copyright Stefano Sinigardi
#.rst:
# FindStb
# ------------
#
# Find the Stb include headers.
#
# Result Variables
# ^^^^^^^^^^^^^^^^
#
# This module defines the following variables:
#
# ``Stb_FOUND``
# True if Stb library found
#
# ``Stb_INCLUDE_DIR``
# Location of Stb headers
#
include(${CMAKE_ROOT}/Modules/FindPackageHandleStandardArgs.cmake)
include(${CMAKE_ROOT}/Modules/SelectLibraryConfigurations.cmake)
if(NOT Stb_INCLUDE_DIR)
find_path(Stb_INCLUDE_DIR NAMES stb_image.h PATHS ${Stb_DIR} PATH_SUFFIXES include stb include/stb)
endif()
find_package_handle_standard_args(Stb DEFAULT_MSG Stb_INCLUDE_DIR)
mark_as_advanced(Stb_INCLUDE_DIR)

View file

@ -6,10 +6,13 @@ include_directories(${GLEW_INCLUDE_DIRS})
find_package(OpenGL) find_package(OpenGL)
find_package(glm CONFIG REQUIRED) find_package(glm CONFIG REQUIRED)
find_package(ReactPhysics3D REQUIRED) find_package(ReactPhysics3D REQUIRED)
find_package(pugixml REQUIRED) find_package(pugixml 1.15 REQUIRED)
find_package(Stb REQUIRED)
include_directories(${Stb_INCLUDE_DIR})
file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h") file(GLOB_RECURSE SOURCES "src/*.cpp" "src/*.h")
add_library(openblocks ${SOURCES}) add_library(openblocks STATIC ${SOURCES})
set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks") set_target_properties(openblocks PROPERTIES OUTPUT_NAME "openblocks")
target_link_libraries(openblocks ${GLEW_LIBRARIES} OpenGL::GL ReactPhysics3D::ReactPhysics3D pugixml::pugixml) target_link_libraries(openblocks ${GLEW_LIBRARIES} OpenGL::GL ReactPhysics3D::ReactPhysics3D pugixml::pugixml)
target_include_directories(openblocks PUBLIC "src" "../include") target_include_directories(openblocks PUBLIC "src" "../include")

View file

@ -28,7 +28,6 @@ namespace Data {
std::string name; std::string name;
Deserializer deserializer; Deserializer deserializer;
FromString fromString; FromString fromString;
TypeInfo(const TypeInfo&) = delete;
}; };
class String; class String;

View file

@ -1,6 +1,6 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <stb/stb_image.h> #include <stb_image.h>
#include "skybox.h" #include "skybox.h"

View file

@ -2,7 +2,7 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <stb/stb_image.h> #include <stb_image.h>
Texture::Texture(const char* texturePath, unsigned int format, bool noMipMaps) { Texture::Texture(const char* texturePath, unsigned int format, bool noMipMaps) {
glGenTextures(1, &this->ID); glGenTextures(1, &this->ID);

View file

@ -2,7 +2,7 @@
#include <GL/glew.h> #include <GL/glew.h>
#include <GL/gl.h> #include <GL/gl.h>
#include <stb/stb_image.h> #include <stb_image.h>
Texture3D::Texture3D(const char* texturePath, unsigned int tileWidth, unsigned int tileHeight, unsigned int tileCount, unsigned int format) { Texture3D::Texture3D(const char* texturePath, unsigned int tileWidth, unsigned int tileHeight, unsigned int tileCount, unsigned int format) {
glGenTextures(1, &this->ID); glGenTextures(1, &this->ID);

View file

@ -1,2 +1,2 @@
#define STB_IMAGE_IMPLEMENTATION #define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.h> #include <stb_image.h>

View file

@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.31..) cmake_minimum_required(VERSION 3.30.0)
project(editor VERSION 0.1 LANGUAGES CXX) project(editor VERSION 0.1 LANGUAGES CXX)
@ -6,7 +6,7 @@ set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON) set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON) set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON) set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON) set(CMAKE_INCLUDE_CURRENT_DIR ON)
@ -14,6 +14,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools) find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets LinguistTools)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets LinguistTools)
set(TS_FILES editor_en_US.ts) set(TS_FILES editor_en_US.ts)
set(PROJECT_SOURCES set(PROJECT_SOURCES
@ -75,6 +76,32 @@ if (${QT_VERSION} GREATER_EQUAL 6)
target_link_libraries(editor PRIVATE Qt6::OpenGL Qt6::OpenGLWidgets) target_link_libraries(editor PRIVATE Qt6::OpenGL Qt6::OpenGLWidgets)
endif() endif()
# Copy assets
add_custom_command(
TARGET editor POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/assets
$<TARGET_FILE_DIR:editor>/assets)
# Copy Qt files
if (WIN32)
#include("${QT_DEPLOY_SUPPORT}")
# TODO: Add other translations
add_custom_command(
TARGET editor POST_BUILD
COMMAND ${WINDEPLOYQT_EXECUTABLE} $<TARGET_FILE:editor> --translations en --no-compiler-runtime --no-opengl-sw --no-system-d3d-compiler --plugindir $<TARGET_FILE_DIR:editor>/qtplugins
)
# No sense adding opengl-sw given that hardware acceleration is necessary, anyway
# Also don't want to clutter with plugins, add only needed ones
# Copy qt.conf to override default plugins location
add_custom_command(
TARGET editor POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/qt.conf $<TARGET_FILE_DIR:editor>/qt.conf
)
endif ()
# Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1. # Qt for iOS sets MACOSX_BUNDLE_GUI_IDENTIFIER automatically since Qt 6.1.
# If you are developing for iOS or macOS you should consider setting an # If you are developing for iOS or macOS you should consider setting an
# explicit, fixed bundle identifier manually though. # explicit, fixed bundle identifier manually though.

2
editor/qt.conf Normal file
View file

@ -0,0 +1,2 @@
[Paths]
Plugins = "qtplugins"

14
vcpkg-configuration.json Normal file
View file

@ -0,0 +1,14 @@
{
"default-registry": {
"kind": "git",
"baseline": "0c4cf19224a049cf82f4521e29e39f7bd680440c",
"repository": "https://github.com/microsoft/vcpkg"
},
"registries": [
{
"kind": "artifact",
"location": "https://github.com/microsoft/vcpkg-ce-catalog/archive/refs/heads/main.zip",
"name": "microsoft"
}
]
}

10
vcpkg.json Normal file
View file

@ -0,0 +1,10 @@
{
"dependencies": [
"glew",
"glfw3",
"glm",
{ "name": "pugixml", "version>=": "1.15" },
"sdl2",
"stb"
]
}