39 const math::fvec2 viewport_center = viewport_size * 0.5f;
45 const auto& splash_dimensions = splash_texture->
get_image_view()->get_image()->get_dimensions();
48 splash_billboard_material = std::make_shared<render::material>();
51 splash_billboard_material->set_variable(
"background", std::make_shared<render::matvar_texture_2d>(1, splash_texture));
53 auto splash_tint = std::make_shared<render::matvar_fvec4>(1,
math::fvec4{1, 1, 1, 0});
54 splash_billboard_material->set_variable(
"tint", splash_tint);
57 splash_billboard.
set_material(splash_billboard_material);
58 splash_billboard.
set_scale({
static_cast<float>(splash_dimensions[0]) * 0.5f,
static_cast<float>(splash_dimensions[1]) * 0.5f, 1.0f});
65 const float splash_fade_in_duration = 0.5;
66 const float splash_duration = 2.0;
67 const float splash_fade_out_duration = 0.5;
73 splash_fade_in_opacity_channel->
insert_keyframe({splash_fade_in_duration, 1.0f});
74 splash_fade_in_opacity_channel->
insert_keyframe({splash_fade_in_duration + splash_duration, 1.0f});
80 splash_fade_out_opacity_channel->
insert_keyframe({splash_fade_out_duration, 0.0f});
83 auto set_splash_opacity = [splash_tint](
int channel,
const float& opacity)
95 this->splash_fade_out_animation.
play();
117 ctx.
animator->add_animation(&splash_fade_in_animation);
118 ctx.
animator->add_animation(&splash_fade_out_animation);
121 splash_fade_in_animation.
play();
124 window_resized_subscription =
ctx.
window->get_resized_channel().subscribe
126 [&](
const auto&
event)
129 const math::fvec2 viewport_center = viewport_size * 0.5f;
135 auto skip = [&](
const auto&
event)
153 input_mapped_subscriptions.emplace_back
160 input_mapped_subscriptions.emplace_back
167 input_mapped_subscriptions.emplace_back
193 input_mapped_subscriptions.clear();
196 ctx.
animator->remove_animation(&splash_fade_in_animation);
197 ctx.
animator->remove_animation(&splash_fade_out_animation);
void set_end_callback(std::function< void()> callback)
Sets the callback that's executed when a non-looped animation has finished.
void play()
Plays the animation.
Single channel in a keyframe animation.
void insert_keyframe(const keyframe &k)
Adds a keyframe to the animation.
void set_interpolator(interpolator_type interpolator)
Sets the frame interpolator function object.
channel * add_channel(int id)
Adds a channel to the animation.
void set_frame_callback(std::function< void(int, const T &)> callback)
Sets the callback that's executed on each frame of animation.
Abstract base class for game states.
std::unique_ptr< scene::collection > ui_scene
hsm::state_machine< game_state > state_machine
std::unique_ptr< animator > animator
std::unique_ptr< resource_manager > resource_manager
std::shared_ptr< app::window > window
std::queue< std::function< void()> > function_queue
input::mapper input_mapper
std::unique_ptr< app::input_manager > input_manager
Template used to for generating one or more shader variants from a single source.
constexpr const std::shared_ptr< image_view_2d > & get_image_view() const noexcept
Returns the image view.
void set_material(std::shared_ptr< render::material > material)
Sets the billboard material.
void set_scale(const vector_type &scale)
Sets the scale of the object.
void set_translation(const vector_type &translation)
Sets the translation of the object.
splash_state(::game &ctx)
log_message< log_message_severity::trace, Args... > log_trace
Formats and logs a trace message.
Publish-subscribe messaging.
@ color_clear_bit
Indicates the color buffer should be cleared.
constexpr vector< T, N > round(const vector< T, N > &x)
Performs a element-wise round operation.
@ translucent
Material is translucent.
Container for templated easing functions.
constexpr element_type & x() noexcept
Returns a reference to the first element.
constexpr element_type & y() noexcept
Returns a reference to the second element.