diff --git a/headers/enduro2d/core/audio.hpp b/headers/enduro2d/core/audio.hpp index cccfcbab..824dbe16 100644 --- a/headers/enduro2d/core/audio.hpp +++ b/headers/enduro2d/core/audio.hpp @@ -83,12 +83,9 @@ namespace e2d audio(debug& d); ~audio() noexcept; - [[nodiscard]] sound_stream_ptr preload_stream( + [[nodiscard]] sound_stream_ptr create_stream( buffer_view sound_data); - [[nodiscard]] sound_stream_ptr preload_stream( - const input_stream_uptr& file_stream); - [[nodiscard]] sound_stream_ptr create_stream( input_stream_uptr file_stream); diff --git a/headers/enduro2d/core/input.hpp b/headers/enduro2d/core/input.hpp index 3517b91f..7af711a8 100644 --- a/headers/enduro2d/core/input.hpp +++ b/headers/enduro2d/core/input.hpp @@ -8,8 +8,6 @@ #include "_core.hpp" -#include "window.hpp" - namespace e2d { class mouse final : private noncopyable { @@ -120,16 +118,4 @@ namespace e2d class internal_state; std::unique_ptr state_; }; - - class window_input_source : public window::event_listener { - public: - window_input_source(input& input) noexcept; - void on_input_char(char32_t uchar) noexcept final; - void on_move_cursor(const v2f& pos) noexcept final; - void on_mouse_scroll(const v2f& delta) noexcept final; - void on_mouse_button(mouse_button btn, mouse_button_action act) noexcept final; - void on_keyboard_key(keyboard_key key, u32 scancode, keyboard_key_action act) noexcept final; - private: - input& input_; - }; } diff --git a/headers/enduro2d/core/render.hpp b/headers/enduro2d/core/render.hpp index e65402b1..c535d7e2 100644 --- a/headers/enduro2d/core/render.hpp +++ b/headers/enduro2d/core/render.hpp @@ -911,16 +911,9 @@ namespace e2d buffer_view vertex_source, buffer_view fragment_source); - shader_ptr create_shader( - const input_stream_uptr& vertex_stream, - const input_stream_uptr& fragment_stream); - texture_ptr create_texture( const image& image); - texture_ptr create_texture( - const input_stream_uptr& image_stream); - texture_ptr create_texture( const v2u& size, const pixel_declaration& decl); diff --git a/headers/enduro2d/core/vfs.hpp b/headers/enduro2d/core/vfs.hpp index d7850c03..24094ac5 100644 --- a/headers/enduro2d/core/vfs.hpp +++ b/headers/enduro2d/core/vfs.hpp @@ -55,10 +55,10 @@ namespace e2d input_stream_uptr read(const url& url) const; output_stream_uptr write(const url& url, bool append) const; - bool load(const url& url, buffer& dst) const; + std::optional load(const url& url) const; stdex::promise load_async(const url& url) const; - bool load_as_string(const url& url, str& dst) const; + std::optional load_as_string(const url& url) const; stdex::promise load_as_string_async(const url& url) const; template < typename Iter > diff --git a/headers/enduro2d/core/window.hpp b/headers/enduro2d/core/window.hpp index 32c0781d..ddbb7501 100644 --- a/headers/enduro2d/core/window.hpp +++ b/headers/enduro2d/core/window.hpp @@ -89,9 +89,9 @@ namespace e2d std::unique_ptr state_; }; - class window_trace_event_listener final : public window::event_listener { + class window_event_tracer final : public window::event_listener { public: - window_trace_event_listener(debug& debug) noexcept; + window_event_tracer(debug& debug) noexcept; void on_input_char(char32_t uchar) noexcept final; void on_move_cursor(const v2f& pos) noexcept final; void on_mouse_scroll(const v2f& delta) noexcept final; @@ -105,6 +105,18 @@ namespace e2d private: debug& debug_; }; + + class window_input_source final : public window::event_listener { + public: + window_input_source(input& input) noexcept; + void on_input_char(char32_t uchar) noexcept final; + void on_move_cursor(const v2f& pos) noexcept final; + void on_mouse_scroll(const v2f& delta) noexcept final; + void on_mouse_button(mouse_button btn, mouse_button_action act) noexcept final; + void on_keyboard_key(keyboard_key key, u32 scancode, keyboard_key_action act) noexcept final; + private: + input& input_; + }; } ENUM_HPP_REGISTER_TRAITS(e2d::window::cursor_shapes) diff --git a/samples/sources/sample_00/sample_00.cpp b/samples/sources/sample_00/sample_00.cpp index e85e2519..a3ddca95 100644 --- a/samples/sources/sample_00/sample_00.cpp +++ b/samples/sources/sample_00/sample_00.cpp @@ -96,13 +96,20 @@ namespace the().register_scheme_alias( "ships", url("piratepack://PNG/Retina/Ships")); + + image texture1_image; + if ( !images::try_load_image(texture1_image, the().read(url("ships://ship (2).png"))) ) { + return false; + } - shader_ = the().create_shader( - vs_source_cstr, fs_source_cstr); - texture1_ = the().create_texture( - the().read(url("ships://ship (2).png"))); - texture2_ = the().create_texture( - the().read(url("ships://ship (19).png"))); + image texture2_image; + if ( !images::try_load_image(texture2_image, the().read(url("ships://ship (19).png"))) ) { + return false; + } + + shader_ = the().create_shader(vs_source_cstr, fs_source_cstr); + texture1_ = the().create_texture(texture1_image); + texture2_ = the().create_texture(texture2_image); if ( !shader_ || !texture1_ || !texture2_ ) { return false; diff --git a/samples/sources/sample_01/sample_01.cpp b/samples/sources/sample_01/sample_01.cpp index 63f315b7..6e9a9930 100644 --- a/samples/sources/sample_01/sample_01.cpp +++ b/samples/sources/sample_01/sample_01.cpp @@ -156,12 +156,14 @@ namespace the().register_scheme_alias( "ships", url("piratepack://PNG/Retina/Ships")); + + image texture_image; + if ( !images::try_load_image(texture_image, the().read(url("ships://ship (3).png"))) ) { + return false; + } - shader_ = the().create_shader( - vs_source_cstr, fs_source_cstr); - - texture_ = the().create_texture( - the().read(url("ships://ship (3).png"))); + shader_ = the().create_shader(vs_source_cstr, fs_source_cstr); + texture_ = the().create_texture(texture_image); if ( !shader_ || !texture_ ) { return false; diff --git a/samples/sources/sample_02/sample_02.cpp b/samples/sources/sample_02/sample_02.cpp index 1fd0a8a3..3f953597 100644 --- a/samples/sources/sample_02/sample_02.cpp +++ b/samples/sources/sample_02/sample_02.cpp @@ -111,12 +111,14 @@ namespace the().register_scheme_alias( "ships", url("piratepack://PNG/Retina/Ships")); + + image texture_image; + if ( !images::try_load_image(texture_image, the().read(url("ships://ship (3).png"))) ) { + return false; + } - shader_ = the().create_shader( - vs_source_cstr, fs_source_cstr); - - texture_ = the().create_texture( - the().read(url("ships://ship (3).png"))); + shader_ = the().create_shader(vs_source_cstr, fs_source_cstr); + texture_ = the().create_texture(texture_image); if ( !shader_ || !texture_ ) { return false; diff --git a/samples/sources/sample_05/sample_05.cpp b/samples/sources/sample_05/sample_05.cpp index 5d736c47..24917718 100644 --- a/samples/sources/sample_05/sample_05.cpp +++ b/samples/sources/sample_05/sample_05.cpp @@ -20,8 +20,8 @@ namespace "audio", url("rpgaudio://Audio")); - auto sstream1 = the