mirror of
https://github.com/enduro2d/enduro2d.git
synced 2025-12-14 16:09:06 +07:00
rename render_target_command to target_command
This commit is contained in:
@@ -776,6 +776,17 @@ namespace e2d
|
|||||||
u8 _pad[2] = {0};
|
u8 _pad[2] = {0};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class target_command final {
|
||||||
|
public:
|
||||||
|
target_command() = default;
|
||||||
|
target_command(const render_target_ptr& rt) noexcept;
|
||||||
|
target_command& target(const render_target_ptr& value) noexcept;
|
||||||
|
render_target_ptr& target() noexcept;
|
||||||
|
const render_target_ptr& target() const noexcept;
|
||||||
|
private:
|
||||||
|
render_target_ptr target_;
|
||||||
|
};
|
||||||
|
|
||||||
class viewport_command final {
|
class viewport_command final {
|
||||||
public:
|
public:
|
||||||
viewport_command() = default;
|
viewport_command() = default;
|
||||||
@@ -787,23 +798,12 @@ namespace e2d
|
|||||||
b2u rect_;
|
b2u rect_;
|
||||||
};
|
};
|
||||||
|
|
||||||
class render_target_command final {
|
|
||||||
public:
|
|
||||||
render_target_command() = default;
|
|
||||||
render_target_command(const render_target_ptr& rt) noexcept;
|
|
||||||
render_target_command& render_target(const render_target_ptr& value) noexcept;
|
|
||||||
render_target_ptr& render_target() noexcept;
|
|
||||||
const render_target_ptr& render_target() const noexcept;
|
|
||||||
private:
|
|
||||||
render_target_ptr render_target_;
|
|
||||||
};
|
|
||||||
|
|
||||||
using command_value = stdex::variant<
|
using command_value = stdex::variant<
|
||||||
swap_command,
|
swap_command,
|
||||||
draw_command,
|
draw_command,
|
||||||
clear_command,
|
clear_command,
|
||||||
viewport_command,
|
target_command,
|
||||||
render_target_command>;
|
viewport_command>;
|
||||||
|
|
||||||
template < std::size_t N >
|
template < std::size_t N >
|
||||||
class command_block final {
|
class command_block final {
|
||||||
@@ -864,8 +864,8 @@ namespace e2d
|
|||||||
render& execute(const swap_command& command);
|
render& execute(const swap_command& command);
|
||||||
render& execute(const draw_command& command);
|
render& execute(const draw_command& command);
|
||||||
render& execute(const clear_command& command);
|
render& execute(const clear_command& command);
|
||||||
|
render& execute(const target_command& command);
|
||||||
render& execute(const viewport_command& command);
|
render& execute(const viewport_command& command);
|
||||||
render& execute(const render_target_command& command);
|
|
||||||
private:
|
private:
|
||||||
class internal_state;
|
class internal_state;
|
||||||
std::unique_ptr<internal_state> state_;
|
std::unique_ptr<internal_state> state_;
|
||||||
|
|||||||
@@ -218,14 +218,14 @@ int e2d_main() {
|
|||||||
.property("u_MVP", MVP);
|
.property("u_MVP", MVP);
|
||||||
|
|
||||||
the<render>().execute(render::command_block<64>()
|
the<render>().execute(render::command_block<64>()
|
||||||
.add_command(render::render_target_command(rt))
|
.add_command(render::target_command(rt))
|
||||||
.add_command(render::viewport_command(rt->size()))
|
.add_command(render::viewport_command(rt->size()))
|
||||||
.add_command(render::clear_command()
|
.add_command(render::clear_command()
|
||||||
.color_value({0.f, 0.4f, 0.f, 1.f}))
|
.color_value({0.f, 0.4f, 0.f, 1.f}))
|
||||||
.add_command(render::draw_command(material, geometry, texture_props)));
|
.add_command(render::draw_command(material, geometry, texture_props)));
|
||||||
|
|
||||||
the<render>().execute(render::command_block<64>()
|
the<render>().execute(render::command_block<64>()
|
||||||
.add_command(render::render_target_command(nullptr))
|
.add_command(render::target_command(nullptr))
|
||||||
.add_command(render::viewport_command(the<window>().real_size()))
|
.add_command(render::viewport_command(the<window>().real_size()))
|
||||||
.add_command(render::clear_command()
|
.add_command(render::clear_command()
|
||||||
.color_value({1.f, 0.4f, 0.f, 1.f})));
|
.color_value({1.f, 0.4f, 0.f, 1.f})));
|
||||||
|
|||||||
@@ -93,11 +93,11 @@ namespace
|
|||||||
render_.execute(command);
|
render_.execute(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const render::viewport_command& command) const {
|
void operator()(const render::target_command& command) const {
|
||||||
render_.execute(command);
|
render_.execute(command);
|
||||||
}
|
}
|
||||||
|
|
||||||
void operator()(const render::render_target_command& command) const {
|
void operator()(const render::viewport_command& command) const {
|
||||||
render_.execute(command);
|
render_.execute(command);
|
||||||
}
|
}
|
||||||
private:
|
private:
|
||||||
@@ -974,6 +974,26 @@ namespace e2d
|
|||||||
return clear_buffer_;
|
return clear_buffer_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// target_command
|
||||||
|
//
|
||||||
|
|
||||||
|
render::target_command::target_command(const render_target_ptr& rt) noexcept
|
||||||
|
: target_(rt) {}
|
||||||
|
|
||||||
|
render::target_command& render::target_command::target(const render_target_ptr& value) noexcept {
|
||||||
|
target_ = value;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
render_target_ptr& render::target_command::target() noexcept {
|
||||||
|
return target_;
|
||||||
|
}
|
||||||
|
|
||||||
|
const render_target_ptr& render::target_command::target() const noexcept {
|
||||||
|
return target_;
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// viewport_command
|
// viewport_command
|
||||||
//
|
//
|
||||||
@@ -994,26 +1014,6 @@ namespace e2d
|
|||||||
return rect_;
|
return rect_;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// render_target_command
|
|
||||||
//
|
|
||||||
|
|
||||||
render::render_target_command::render_target_command(const render_target_ptr& rt) noexcept
|
|
||||||
: render_target_(rt) {}
|
|
||||||
|
|
||||||
render::render_target_command& render::render_target_command::render_target(const render_target_ptr& value) noexcept {
|
|
||||||
render_target_ = value;
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
|
|
||||||
render_target_ptr& render::render_target_command::render_target() noexcept {
|
|
||||||
return render_target_;
|
|
||||||
}
|
|
||||||
|
|
||||||
const render_target_ptr& render::render_target_command::render_target() const noexcept {
|
|
||||||
return render_target_;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// render
|
// render
|
||||||
//
|
//
|
||||||
|
|||||||
@@ -809,6 +809,12 @@ namespace e2d
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
render& render::execute(const target_command& command) {
|
||||||
|
E2D_ASSERT(main_thread() == std::this_thread::get_id());
|
||||||
|
state_->set_render_target(command.target());
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
render& render::execute(const viewport_command& command) {
|
render& render::execute(const viewport_command& command) {
|
||||||
E2D_ASSERT(main_thread() == std::this_thread::get_id());
|
E2D_ASSERT(main_thread() == std::this_thread::get_id());
|
||||||
const b2u vp = make_minmax_rect(command.rect());
|
const b2u vp = make_minmax_rect(command.rect());
|
||||||
@@ -819,12 +825,6 @@ namespace e2d
|
|||||||
math::numeric_cast<GLsizei>(vp.size.y)));
|
math::numeric_cast<GLsizei>(vp.size.y)));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
render& render::execute(const render_target_command& command) {
|
|
||||||
E2D_ASSERT(main_thread() == std::this_thread::get_id());
|
|
||||||
state_->set_render_target(command.render_target());
|
|
||||||
return *this;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user