mirror of
https://github.com/enduro2d/enduro2d.git
synced 2026-05-04 01:31:53 +07:00
code style fixes
This commit is contained in:
@@ -96,7 +96,7 @@ namespace e2d
|
||||
|
||||
void volume(f32 value) noexcept;
|
||||
[[nodiscard]] f32 volume() const noexcept;
|
||||
|
||||
|
||||
void resume() noexcept;
|
||||
void pause() noexcept;
|
||||
private:
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
|
||||
#include "_core.hpp"
|
||||
|
||||
#include "deferrer.hpp"
|
||||
|
||||
namespace e2d
|
||||
{
|
||||
class profiler final : public module<profiler> {
|
||||
@@ -156,7 +158,7 @@ namespace e2d
|
||||
|
||||
void on_event(const event_info& event) noexcept final {
|
||||
const bool skip = info_.events.empty() && depth_;
|
||||
|
||||
|
||||
if ( std::holds_alternative<begin_scope_info>(event) ) {
|
||||
++depth_;
|
||||
} else if ( std::holds_alternative<end_scope_info>(event) ) {
|
||||
@@ -168,7 +170,7 @@ namespace e2d
|
||||
if ( !skip ) {
|
||||
info_.events.push_back(event);
|
||||
}
|
||||
|
||||
|
||||
if ( !depth_ && time_point_ <= Clock::now() ) {
|
||||
promise_.resolve(std::move(info_));
|
||||
}
|
||||
@@ -212,7 +214,7 @@ namespace e2d::profilers
|
||||
bool try_save_recording_info(
|
||||
const profiler::recording_info& src,
|
||||
buffer& dst) noexcept;
|
||||
|
||||
|
||||
bool try_save_recording_info(
|
||||
const profiler::recording_info& src,
|
||||
const output_stream_uptr& dst) noexcept;
|
||||
|
||||
@@ -906,7 +906,7 @@ namespace e2d
|
||||
shader_ptr create_shader(
|
||||
str_view vertex_source,
|
||||
str_view fragment_source);
|
||||
|
||||
|
||||
shader_ptr create_shader(
|
||||
buffer_view vertex_source,
|
||||
buffer_view fragment_source);
|
||||
|
||||
@@ -105,7 +105,7 @@ namespace e2d
|
||||
private:
|
||||
debug& debug_;
|
||||
};
|
||||
|
||||
|
||||
class window_input_source final : public window::event_listener {
|
||||
public:
|
||||
window_input_source(input& input) noexcept;
|
||||
|
||||
@@ -61,7 +61,7 @@ namespace e2d
|
||||
buffer_view::buffer_view(const std::array<T,N>& buffer) noexcept
|
||||
: data_(buffer.data())
|
||||
, size_(buffer.size() * sizeof(T)) {}
|
||||
|
||||
|
||||
template < typename T, std::size_t N >
|
||||
buffer_view::buffer_view(const T (&buffer)[N]) noexcept
|
||||
: data_(&buffer[0])
|
||||
|
||||
@@ -38,7 +38,7 @@ namespace e2d
|
||||
|
||||
const str& scheme() const noexcept;
|
||||
const str& path() const noexcept;
|
||||
|
||||
|
||||
str schemepath() const;
|
||||
|
||||
url& operator+=(str_view path);
|
||||
|
||||
@@ -96,7 +96,7 @@ namespace
|
||||
the<vfs>().register_scheme_alias(
|
||||
"ships",
|
||||
url("piratepack://PNG/Retina/Ships"));
|
||||
|
||||
|
||||
image texture1_image;
|
||||
if ( !images::try_load_image(texture1_image, the<vfs>().read(url("ships://ship (2).png"))) ) {
|
||||
return false;
|
||||
|
||||
@@ -156,7 +156,7 @@ namespace
|
||||
the<vfs>().register_scheme_alias(
|
||||
"ships",
|
||||
url("piratepack://PNG/Retina/Ships"));
|
||||
|
||||
|
||||
image texture_image;
|
||||
if ( !images::try_load_image(texture_image, the<vfs>().read(url("ships://ship (3).png"))) ) {
|
||||
return false;
|
||||
|
||||
@@ -111,7 +111,7 @@ namespace
|
||||
the<vfs>().register_scheme_alias(
|
||||
"ships",
|
||||
url("piratepack://PNG/Retina/Ships"));
|
||||
|
||||
|
||||
image texture_image;
|
||||
if ( !images::try_load_image(texture_image, the<vfs>().read(url("ships://ship (3).png"))) ) {
|
||||
return false;
|
||||
|
||||
@@ -36,6 +36,20 @@ namespace
|
||||
if ( k.is_key_pressed(keyboard_key::lsuper) && k.is_key_just_released(keyboard_key::enter) ) {
|
||||
the<window>().toggle_fullscreen(!the<window>().fullscreen());
|
||||
}
|
||||
|
||||
if ( k.is_key_just_released(keyboard_key::space) ) {
|
||||
the<profiler>().record_for(std::chrono::seconds(1))
|
||||
.then([](const profiler::recording_info& info){
|
||||
the<debug>().trace("Profile done: %0", info.events.size());
|
||||
profilers::try_save_recording_info(info, the<vfs>().write({"desktop", "trace.json"}, false));
|
||||
});
|
||||
the<deferrer>().do_in_main_thread([](){
|
||||
the<library>().load_asset_async<prefab_asset>("scenes/spine_scene_prefab.json")
|
||||
.then([](const prefab_asset::load_result& prefab_data){
|
||||
the<world>().instantiate(prefab_data->content());
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ namespace
|
||||
the<vfs>().register_scheme_alias(
|
||||
"audio",
|
||||
url("rpgaudio://Audio"));
|
||||
|
||||
|
||||
auto sstream1 = the<audio>().create_stream(the<vfs>().read(url("audio://chop.ogg")));
|
||||
auto sstream2 = the<audio>().create_stream(*the<vfs>().load(url("audio://footstep00.ogg")));
|
||||
|
||||
@@ -29,7 +29,7 @@ namespace
|
||||
|
||||
sound_src1_ = the<audio>().create_source(sstream1);
|
||||
sound_src2_ = the<audio>().create_source(sstream2);
|
||||
|
||||
|
||||
if ( !sound_src1_ || !sound_src2_ ) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ namespace e2d
|
||||
HCHANNEL channel = stream->state().stream()
|
||||
? stream->state().sound()
|
||||
: BASS_SampleGetChannel(stream->state().sound(), FALSE);
|
||||
|
||||
|
||||
if ( !channel ) {
|
||||
state_->dbg().error("AUDIO: can net retrive sound channel");
|
||||
return nullptr;
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace e2d
|
||||
const input_stream_uptr& sound_stream::internal_state::stream() const noexcept {
|
||||
return stream_;
|
||||
}
|
||||
|
||||
|
||||
//
|
||||
// sound_source::internal_state
|
||||
//
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace e2d
|
||||
|
||||
io.DisplaySize =
|
||||
window_.real_size().cast_to<f32>();
|
||||
|
||||
|
||||
io.DisplayFramebufferScale = io.DisplaySize.x > 0.f && io.DisplaySize.y > 0.f
|
||||
? window_.framebuffer_size().cast_to<f32>() / v2f(io.DisplaySize)
|
||||
: v2f(1.f, 1.f);
|
||||
|
||||
@@ -519,7 +519,7 @@ namespace e2d
|
||||
app->shutdown();
|
||||
throw;
|
||||
}
|
||||
|
||||
|
||||
the<input>().frame_tick();
|
||||
window::poll_events();
|
||||
|
||||
|
||||
@@ -6,7 +6,6 @@
|
||||
|
||||
#include <enduro2d/core/profiler.hpp>
|
||||
|
||||
#include <enduro2d/core/deferrer.hpp>
|
||||
#include <enduro2d/core/engine.hpp>
|
||||
#include <enduro2d/core/vfs.hpp>
|
||||
|
||||
@@ -28,7 +27,7 @@ namespace
|
||||
|
||||
str recording_info_to_json(const profiler::recording_info& src) {
|
||||
str dst("{\"traceEvents\":[\n");
|
||||
|
||||
|
||||
dst += strings::rformat(
|
||||
" {\"name\":\"thread_name\",\"ph\":\"M\",\"tid\":%0,\"pid\":0,\"args\":{\"name\":\"%1\"}},\n",
|
||||
std::hash<std::thread::id>()(the<engine>().main_thread()),
|
||||
@@ -159,7 +158,7 @@ namespace e2d
|
||||
std::move(args),
|
||||
std::this_thread::get_id(),
|
||||
time::to_chrono(time::now_us())};
|
||||
|
||||
|
||||
std::lock_guard guard(rmutex_);
|
||||
for ( const auto& sink : sinks_ ) {
|
||||
if ( sink ) {
|
||||
@@ -175,7 +174,7 @@ namespace e2d
|
||||
end_scope_info event{
|
||||
std::this_thread::get_id(),
|
||||
time::to_chrono(time::now_us())};
|
||||
|
||||
|
||||
std::lock_guard guard(rmutex_);
|
||||
for ( const auto& sink : sinks_ ) {
|
||||
if ( sink ) {
|
||||
@@ -194,7 +193,7 @@ namespace e2d
|
||||
std::move(args),
|
||||
std::this_thread::get_id(),
|
||||
time::to_chrono(time::now_us())};
|
||||
|
||||
|
||||
std::lock_guard guard(rmutex_);
|
||||
for ( const auto& sink : sinks_ ) {
|
||||
if ( sink ) {
|
||||
@@ -213,7 +212,7 @@ namespace e2d
|
||||
std::move(args),
|
||||
std::this_thread::get_id(),
|
||||
time::to_chrono(time::now_us())};
|
||||
|
||||
|
||||
std::lock_guard guard(rmutex_);
|
||||
for ( const auto& sink : sinks_ ) {
|
||||
if ( sink ) {
|
||||
@@ -237,7 +236,7 @@ namespace e2d::profilers
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
bool try_save_recording_info(
|
||||
const profiler::recording_info& src,
|
||||
const output_stream_uptr& dst) noexcept
|
||||
|
||||
@@ -245,7 +245,7 @@ namespace e2d
|
||||
E2D_UNUSED(command);
|
||||
return *this;
|
||||
}
|
||||
|
||||
|
||||
render& render::update_buffer(
|
||||
const index_buffer_ptr& ibuffer,
|
||||
buffer_view indices,
|
||||
|
||||
@@ -514,7 +514,7 @@ namespace e2d
|
||||
}
|
||||
|
||||
gl_shader_id fs(state_->dbg());
|
||||
|
||||
|
||||
{
|
||||
E2D_PROFILER_SCOPE("render.compile_fragment_shader");
|
||||
|
||||
|
||||
@@ -179,7 +179,7 @@ namespace e2d
|
||||
{"url", url.schemepath()}
|
||||
});
|
||||
return load_async(url).then([](auto&& src){
|
||||
return std::optional(std::forward<decltype(src)>(src));
|
||||
return std::optional<buffer>(std::forward<decltype(src)>(src));
|
||||
}).get_or_default(std::nullopt);
|
||||
}
|
||||
|
||||
@@ -202,7 +202,7 @@ namespace e2d
|
||||
{"url", url.schemepath()}
|
||||
});
|
||||
return load_as_string_async(url).then([](auto&& src){
|
||||
return std::optional(std::forward<decltype(src)>(src));
|
||||
return std::optional<str>(std::forward<decltype(src)>(src));
|
||||
}).get_or_default(std::nullopt);
|
||||
}
|
||||
|
||||
|
||||
@@ -99,7 +99,7 @@ namespace
|
||||
|
||||
void frame_render() final {
|
||||
E2D_PROFILER_SCOPE("application.frame_render");
|
||||
|
||||
|
||||
world& w = the<world>();
|
||||
|
||||
{
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace
|
||||
const auto comp = [](const auto& l, const auto& r) noexcept {
|
||||
return std::get<scene>(l).depth() < std::get<scene>(r).depth();
|
||||
};
|
||||
|
||||
|
||||
const auto func = [&ctx](
|
||||
const ecs::const_entity&,
|
||||
const scene&,
|
||||
@@ -36,7 +36,7 @@ namespace
|
||||
ctx.draw(node);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
systems::for_extracted_sorted_components<scene, actor>(
|
||||
owner,
|
||||
comp,
|
||||
@@ -50,7 +50,7 @@ namespace
|
||||
const auto comp = [](const auto& l, const auto& r) noexcept {
|
||||
return std::get<camera>(l).depth() < std::get<camera>(r).depth();
|
||||
};
|
||||
|
||||
|
||||
const auto func = [&drawer, &owner](
|
||||
const ecs::const_entity&,
|
||||
const camera& cam,
|
||||
@@ -60,7 +60,7 @@ namespace
|
||||
for_all_scenes(ctx, owner);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
systems::for_extracted_sorted_components<camera, actor>(
|
||||
owner,
|
||||
comp,
|
||||
|
||||
@@ -196,7 +196,7 @@ namespace e2d
|
||||
|
||||
gobject world::instantiate(const prefab& prefab, const node_iptr& parent) {
|
||||
E2D_PROFILER_SCOPE("world.instantiate");
|
||||
|
||||
|
||||
gobject inst = new_instance(*this, prefab);
|
||||
|
||||
if ( parent ) {
|
||||
|
||||
Reference in New Issue
Block a user