Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tesseratos): add simple template project #1328

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Added resource to easily configure magic numbers in solver (#1281, **@GCeSilva**).
- Audio Plugin (#1004, **@Dageus**, **@diogomsmiranda**).
- Contact caching for collision between box shapes (#1355, **@fallenatlas**).
- Template Cubos project (#1009, **@RiscadoA**).

### Changed

Expand Down
3 changes: 3 additions & 0 deletions tools/tesseratos/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,13 @@ cubos_common_target_options(tesseratos)

if (TESSERATOS_DISTRIBUTE)
target_compile_definitions(tesseratos PRIVATE
TEMPLATES_PATH="templates"
APP_ASSETS_PATH="assets"
BUILTIN_ASSETS_PATH="builtin"
)
else()
target_compile_definitions(tesseratos PRIVATE
TEMPLATES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/templates"
APP_ASSETS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/assets"
BUILTIN_ASSETS_PATH="${CUBOS_ENGINE_ASSETS_PATH}"
)
Expand All @@ -42,6 +44,7 @@ endif()

if(TESSERATOS_DISTRIBUTE)
install(TARGETS tesseratos RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
install(DIRECTORY templates/ DESTINATION ${CMAKE_INSTALL_DATADIR}/tesseratos/templates)
install(DIRECTORY assets/ DESTINATION ${CMAKE_INSTALL_DATADIR}/tesseratos/assets)
install(DIRECTORY ${CUBOS_ENGINE_ASSETS_PATH}/ DESTINATION ${CMAKE_INSTALL_DATADIR}/tesseratos/builtin)
endif()
36 changes: 36 additions & 0 deletions tools/tesseratos/templates/simple/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
cmake_minimum_required(VERSION 3.20.0)
project(game VERSION 0.1.0)

option(DISTRIBUTE "Build the game for distribution" OFF)

add_executable(game
src/main.cpp
)

find_package(cubos REQUIRED)
target_link_libraries(game cubos::engine)

target_compile_features(game PRIVATE cxx_std_20)
target_compile_options(game PRIVATE
# Enable preprocessor conformance mode in MSVC - required for __VA_ARGS__ to work correctly
$<$<CXX_COMPILER_ID:MSVC>: /Zc:preprocessor>
)

if(DISTRIBUTE)
# If we're building for distribution, we want to use the assets directories in the same directory as the executable
target_compile_definitions(game PRIVATE
APP_ASSETS_PATH="assets"
BUILTIN_ASSETS_PATH="builtin"
)

# On installation, copy both the executable and the assets directories to the installation directory
install(TARGETS game RUNTIME DESTINATION .)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/assets/ DESTINATION assets)
install(DIRECTORY ${CUBOS_ENGINE_ASSETS_PATH}/ DESTINATION builtin)
else()
# If we're in development, we want to use the assets directory in the project directory
target_compile_definitions(game PRIVATE
APP_ASSETS_PATH="${CMAKE_CURRENT_SOURCE_DIR}/assets"
BUILTIN_ASSETS_PATH="${CUBOS_ENGINE_ASSETS_PATH}"
)
endif()
33 changes: 33 additions & 0 deletions tools/tesseratos/templates/simple/assets/scenes/main.cubos
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"entities": {
"render-target": {
"cubos::engine::RenderTargetDefaults": {},
"cubos::engine::GizmosTarget": {}
},
"camera": {
"cubos::engine::PerspectiveCamera": 70.0,
"cubos::engine::DrawsTo@render-target": {},
"cubos::engine::Position": {
"x": 0,
"y": 0,
"z": 0
}
},
"sun": {
"cubos::engine::DirectionalLight": {
"color": {
"x": 1.0,
"y": 1.0,
"z": 1.0
},
"intensity": 1.0
},
"cubos::engine::Rotation": {
"w": 1.0,
"x": 0.3,
"y": -0.1,
"z": 0.5
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"id": "ba173db6-4e44-45bc-9cef-c4a25bba8823"
}
27 changes: 27 additions & 0 deletions tools/tesseratos/templates/simple/src/main.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#include <cubos/engine/assets/plugin.hpp>
#include <cubos/engine/defaults/plugin.hpp>
#include <cubos/engine/scene/plugin.hpp>
#include <cubos/engine/settings/plugin.hpp>

using namespace cubos::engine;

static const Asset<Scene> MainSceneAsset = AnyAsset("ba173db6-4e44-45bc-9cef-c4a25bba8823");

int main(int argc, char** argv)
{
Cubos cubos{argc, argv};
cubos.plugin(defaultsPlugin);

// TODO: add your own game plugins here!

cubos.startupSystem("set the assets directory path").before(settingsTag).call([](Settings& settings) {
settings.setString("assets.app.osPath", APP_ASSETS_PATH);
settings.setString("assets.builtin.osPath", BUILTIN_ASSETS_PATH);
});

cubos.startupSystem("load and spawn the Main Scene")
.tagged(assetsTag)
.call([](Commands cmds, const Assets& assets) { cmds.spawn(assets.read(MainSceneAsset)->blueprint); });

cubos.run();
}
Loading