rename render_target_command to target_command

This commit is contained in:
2018-10-29 20:29:20 +07:00
parent 18b9c880d8
commit 2a5b5121a4
4 changed files with 44 additions and 44 deletions

View File

@@ -776,6 +776,17 @@ namespace e2d
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 {
public:
viewport_command() = default;
@@ -787,23 +798,12 @@ namespace e2d
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<
swap_command,
draw_command,
clear_command,
viewport_command,
render_target_command>;
target_command,
viewport_command>;
template < std::size_t N >
class command_block final {
@@ -864,8 +864,8 @@ namespace e2d
render& execute(const swap_command& command);
render& execute(const draw_command& command);
render& execute(const clear_command& command);
render& execute(const target_command& command);
render& execute(const viewport_command& command);
render& execute(const render_target_command& command);
private:
class internal_state;
std::unique_ptr<internal_state> state_;

View File

@@ -218,14 +218,14 @@ int e2d_main() {
.property("u_MVP", MVP);
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::clear_command()
.color_value({0.f, 0.4f, 0.f, 1.f}))
.add_command(render::draw_command(material, geometry, texture_props)));
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::clear_command()
.color_value({1.f, 0.4f, 0.f, 1.f})));

View File

@@ -93,11 +93,11 @@ namespace
render_.execute(command);
}
void operator()(const render::viewport_command& command) const {
void operator()(const render::target_command& command) const {
render_.execute(command);
}
void operator()(const render::render_target_command& command) const {
void operator()(const render::viewport_command& command) const {
render_.execute(command);
}
private:
@@ -974,6 +974,26 @@ namespace e2d
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
//
@@ -994,26 +1014,6 @@ namespace e2d
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
//

View File

@@ -809,6 +809,12 @@ namespace e2d
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) {
E2D_ASSERT(main_thread() == std::this_thread::get_id());
const b2u vp = make_minmax_rect(command.rect());
@@ -819,12 +825,6 @@ namespace e2d
math::numeric_cast<GLsizei>(vp.size.y)));
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