mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-13 23:58:18 +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& company_name(str_view value);
|
||||
parameters& without_graphics(bool value);
|
||||
parameters& debug_params(const debug_parameters& value);
|
||||
parameters& window_params(const window_parameters& value);
|
||||
parameters& timer_params(const timer_parameters& value);
|
||||
|
||||
str& game_name() noexcept;
|
||||
str& company_name() noexcept;
|
||||
bool& without_graphics() noexcept;
|
||||
debug_parameters& debug_params() noexcept;
|
||||
window_parameters& window_params() noexcept;
|
||||
timer_parameters& timer_params() noexcept;
|
||||
|
||||
const str& game_name() const noexcept;
|
||||
const str& company_name() const noexcept;
|
||||
const bool& without_graphics() const noexcept;
|
||||
const debug_parameters& debug_params() const noexcept;
|
||||
const window_parameters& window_params() const noexcept;
|
||||
const timer_parameters& timer_params() const noexcept;
|
||||
private:
|
||||
str game_name_{"noname"};
|
||||
str company_name_{"noname"};
|
||||
bool without_graphics_{false};
|
||||
debug_parameters debug_params_;
|
||||
window_parameters window_params_;
|
||||
timer_parameters timer_params_;
|
||||
|
||||
@@ -33,7 +33,7 @@ namespace
|
||||
|
||||
int e2d_main(int argc, char *argv[]) {
|
||||
const auto starter_params = starter::parameters(
|
||||
engine::parameters("sample_03", "enduro3d")
|
||||
engine::parameters("sample_03", "enduro2d")
|
||||
.timer_params(engine::timer_parameters()
|
||||
.maximal_framerate(100)));
|
||||
modules::initialize<starter>(
|
||||
|
||||
@@ -156,6 +156,11 @@ namespace e2d
|
||||
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) {
|
||||
debug_params_ = value;
|
||||
return *this;
|
||||
@@ -179,6 +184,10 @@ namespace e2d
|
||||
return company_name_;
|
||||
}
|
||||
|
||||
bool& engine::parameters::without_graphics() noexcept {
|
||||
return without_graphics_;
|
||||
}
|
||||
|
||||
engine::debug_parameters& engine::parameters::debug_params() noexcept {
|
||||
return debug_params_;
|
||||
}
|
||||
@@ -199,6 +208,10 @@ namespace e2d
|
||||
return company_name_;
|
||||
}
|
||||
|
||||
const bool& engine::parameters::without_graphics() const noexcept {
|
||||
return without_graphics_;
|
||||
}
|
||||
|
||||
const engine::debug_parameters& engine::parameters::debug_params() const noexcept {
|
||||
return debug_params_;
|
||||
}
|
||||
@@ -346,27 +359,38 @@ namespace e2d
|
||||
the<debug>().register_sink<debug_stream_sink>(std::move(log_stream));
|
||||
}
|
||||
|
||||
// setup input
|
||||
if ( !params.without_graphics() )
|
||||
{
|
||||
// setup input
|
||||
|
||||
safe_module_initialize<input>();
|
||||
safe_module_initialize<input>();
|
||||
|
||||
// setup window
|
||||
// setup window
|
||||
|
||||
safe_module_initialize<window>(
|
||||
params.window_params().size(),
|
||||
params.window_params().caption(),
|
||||
params.window_params().fullscreen());
|
||||
safe_module_initialize<window>(
|
||||
params.window_params().size(),
|
||||
params.window_params().caption(),
|
||||
params.window_params().fullscreen());
|
||||
|
||||
the<window>().register_event_listener<window_input_source>(the<input>());
|
||||
the<window>().register_event_listener<window_input_source>(the<input>());
|
||||
|
||||
// setup render
|
||||
// setup render
|
||||
|
||||
safe_module_initialize<render>(
|
||||
the<debug>(),
|
||||
the<window>());
|
||||
safe_module_initialize<render>(
|
||||
the<debug>(),
|
||||
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) {
|
||||
E2D_ASSERT(is_in_main_thread());
|
||||
|
||||
@@ -19,6 +19,28 @@ namespace
|
||||
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
|
||||
@@ -74,9 +96,21 @@ namespace e2d
|
||||
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) {
|
||||
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