mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
engine::parameters::without_graphics flag
This commit is contained in:
@@ -89,24 +89,28 @@ namespace e2d
|
|||||||
|
|
||||||
parameters& game_name(str_view value);
|
parameters& game_name(str_view value);
|
||||||
parameters& company_name(str_view value);
|
parameters& company_name(str_view value);
|
||||||
|
parameters& without_graphics(bool value);
|
||||||
parameters& debug_params(const debug_parameters& value);
|
parameters& debug_params(const debug_parameters& value);
|
||||||
parameters& window_params(const window_parameters& value);
|
parameters& window_params(const window_parameters& value);
|
||||||
parameters& timer_params(const timer_parameters& value);
|
parameters& timer_params(const timer_parameters& value);
|
||||||
|
|
||||||
str& game_name() noexcept;
|
str& game_name() noexcept;
|
||||||
str& company_name() noexcept;
|
str& company_name() noexcept;
|
||||||
|
bool& without_graphics() noexcept;
|
||||||
debug_parameters& debug_params() noexcept;
|
debug_parameters& debug_params() noexcept;
|
||||||
window_parameters& window_params() noexcept;
|
window_parameters& window_params() noexcept;
|
||||||
timer_parameters& timer_params() noexcept;
|
timer_parameters& timer_params() noexcept;
|
||||||
|
|
||||||
const str& game_name() const noexcept;
|
const str& game_name() const noexcept;
|
||||||
const str& company_name() const noexcept;
|
const str& company_name() const noexcept;
|
||||||
|
const bool& without_graphics() const noexcept;
|
||||||
const debug_parameters& debug_params() const noexcept;
|
const debug_parameters& debug_params() const noexcept;
|
||||||
const window_parameters& window_params() const noexcept;
|
const window_parameters& window_params() const noexcept;
|
||||||
const timer_parameters& timer_params() const noexcept;
|
const timer_parameters& timer_params() const noexcept;
|
||||||
private:
|
private:
|
||||||
str game_name_{"noname"};
|
str game_name_{"noname"};
|
||||||
str company_name_{"noname"};
|
str company_name_{"noname"};
|
||||||
|
bool without_graphics_{false};
|
||||||
debug_parameters debug_params_;
|
debug_parameters debug_params_;
|
||||||
window_parameters window_params_;
|
window_parameters window_params_;
|
||||||
timer_parameters timer_params_;
|
timer_parameters timer_params_;
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ namespace
|
|||||||
|
|
||||||
int e2d_main(int argc, char *argv[]) {
|
int e2d_main(int argc, char *argv[]) {
|
||||||
const auto starter_params = starter::parameters(
|
const auto starter_params = starter::parameters(
|
||||||
engine::parameters("sample_03", "enduro3d")
|
engine::parameters("sample_03", "enduro2d")
|
||||||
.timer_params(engine::timer_parameters()
|
.timer_params(engine::timer_parameters()
|
||||||
.maximal_framerate(100)));
|
.maximal_framerate(100)));
|
||||||
modules::initialize<starter>(
|
modules::initialize<starter>(
|
||||||
|
|||||||
@@ -156,6 +156,11 @@ namespace e2d
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
engine::parameters& engine::parameters::without_graphics(bool value) {
|
||||||
|
without_graphics_ = value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
engine::parameters& engine::parameters::debug_params(const debug_parameters& value) {
|
engine::parameters& engine::parameters::debug_params(const debug_parameters& value) {
|
||||||
debug_params_ = value;
|
debug_params_ = value;
|
||||||
return *this;
|
return *this;
|
||||||
@@ -179,6 +184,10 @@ namespace e2d
|
|||||||
return company_name_;
|
return company_name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool& engine::parameters::without_graphics() noexcept {
|
||||||
|
return without_graphics_;
|
||||||
|
}
|
||||||
|
|
||||||
engine::debug_parameters& engine::parameters::debug_params() noexcept {
|
engine::debug_parameters& engine::parameters::debug_params() noexcept {
|
||||||
return debug_params_;
|
return debug_params_;
|
||||||
}
|
}
|
||||||
@@ -199,6 +208,10 @@ namespace e2d
|
|||||||
return company_name_;
|
return company_name_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool& engine::parameters::without_graphics() const noexcept {
|
||||||
|
return without_graphics_;
|
||||||
|
}
|
||||||
|
|
||||||
const engine::debug_parameters& engine::parameters::debug_params() const noexcept {
|
const engine::debug_parameters& engine::parameters::debug_params() const noexcept {
|
||||||
return debug_params_;
|
return debug_params_;
|
||||||
}
|
}
|
||||||
@@ -346,6 +359,8 @@ namespace e2d
|
|||||||
the<debug>().register_sink<debug_stream_sink>(std::move(log_stream));
|
the<debug>().register_sink<debug_stream_sink>(std::move(log_stream));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ( !params.without_graphics() )
|
||||||
|
{
|
||||||
// setup input
|
// setup input
|
||||||
|
|
||||||
safe_module_initialize<input>();
|
safe_module_initialize<input>();
|
||||||
@@ -365,8 +380,17 @@ namespace e2d
|
|||||||
the<debug>(),
|
the<debug>(),
|
||||||
the<window>());
|
the<window>());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
engine::~engine() noexcept = default;
|
engine::~engine() noexcept {
|
||||||
|
modules::shutdown<render>();
|
||||||
|
modules::shutdown<window>();
|
||||||
|
modules::shutdown<input>();
|
||||||
|
modules::shutdown<vfs>();
|
||||||
|
modules::shutdown<debug>();
|
||||||
|
modules::shutdown<deferrer>();
|
||||||
|
modules::shutdown<platform>();
|
||||||
|
}
|
||||||
|
|
||||||
bool engine::start(application_uptr app) {
|
bool engine::start(application_uptr app) {
|
||||||
E2D_ASSERT(is_in_main_thread());
|
E2D_ASSERT(is_in_main_thread());
|
||||||
|
|||||||
@@ -19,6 +19,28 @@ namespace
|
|||||||
modules::initialize<Module>(std::forward<Args>(args)...);
|
modules::initialize<Module>(std::forward<Args>(args)...);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
class starter_application final : public application {
|
||||||
|
public:
|
||||||
|
starter_application(application_uptr application)
|
||||||
|
: application_(std::move(application)) {}
|
||||||
|
|
||||||
|
bool initialize() final {
|
||||||
|
return application_ && application_->initialize();
|
||||||
|
}
|
||||||
|
|
||||||
|
void shutdown() noexcept final {
|
||||||
|
if ( application_ ) {
|
||||||
|
application_->shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool frame_tick() final {
|
||||||
|
return application_ && application_->frame_tick();
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
application_uptr application_;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace e2d
|
namespace e2d
|
||||||
@@ -74,9 +96,21 @@ namespace e2d
|
|||||||
safe_module_initialize<asset_cache<material_asset>>(the<library>());
|
safe_module_initialize<asset_cache<material_asset>>(the<library>());
|
||||||
}
|
}
|
||||||
|
|
||||||
starter::~starter() noexcept = default;
|
starter::~starter() noexcept {
|
||||||
|
modules::shutdown<asset_cache<material_asset>>();
|
||||||
|
modules::shutdown<asset_cache<texture_asset>>();
|
||||||
|
modules::shutdown<asset_cache<shader_asset>>();
|
||||||
|
modules::shutdown<asset_cache<binary_asset>>();
|
||||||
|
modules::shutdown<asset_cache<image_asset>>();
|
||||||
|
modules::shutdown<asset_cache<mesh_asset>>();
|
||||||
|
modules::shutdown<asset_cache<text_asset>>();
|
||||||
|
modules::shutdown<library>();
|
||||||
|
modules::shutdown<engine>();
|
||||||
|
}
|
||||||
|
|
||||||
bool starter::start(application_uptr app) {
|
bool starter::start(application_uptr app) {
|
||||||
return the<engine>().start(std::move(app));
|
return the<engine>().start(
|
||||||
|
std::make_unique<starter_application>(
|
||||||
|
std::move(app)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
18
untests/sources/untests_high/starter.cpp
Normal file
18
untests/sources/untests_high/starter.cpp
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
/*******************************************************************************
|
||||||
|
* This file is part of the "Enduro2D"
|
||||||
|
* For conditions of distribution and use, see copyright notice in LICENSE.md
|
||||||
|
* Copyright (C) 2018 Matvey Cherevko
|
||||||
|
******************************************************************************/
|
||||||
|
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
#include "_high.hpp"
|
||||||
|
using namespace e2d;
|
||||||
|
|
||||||
|
TEST_CASE("starter"){
|
||||||
|
modules::initialize<starter>(0, nullptr,
|
||||||
|
starter::parameters(
|
||||||
|
engine::parameters("starter_untests", "enduro2d")
|
||||||
|
.without_graphics(true)));
|
||||||
|
modules::shutdown<starter>();
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user