render command_block

This commit is contained in:
2018-10-25 18:49:32 +07:00
parent 774368a0a4
commit 8d5758c2d7
7 changed files with 452 additions and 104 deletions

View File

@@ -205,37 +205,32 @@ int e2d_main() {
.property("u_time", game_time)
.property("u_MVP", MVP);
material.properties()
.sampler("u_texture", render::sampler_state()
.texture(texture)
.min_filter(render::sampler_min_filter::linear)
.mag_filter(render::sampler_mag_filter::linear));
the<render>().execute(render::command_block<64>()
.add_command(render::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)
.properties(render::property_block()
.sampler("u_texture", render::sampler_state()
.texture(texture)
.min_filter(render::sampler_min_filter::linear)
.mag_filter(render::sampler_mag_filter::linear))))
.add_command(render::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}))
.add_command(render::draw_command(material, geometry)
.properties(render::property_block()
.sampler("u_texture", render::sampler_state()
.texture(rt->color())
.min_filter(render::sampler_min_filter::linear)
.mag_filter(render::sampler_mag_filter::linear))))
.add_command(render::swap_command(true)));
the<render>()
.set_render_target(rt)
.set_viewport(rt->size())
.clear_depth_buffer(1.f)
.clear_stencil_buffer(0)
.clear_color_buffer({0.f, 0.4f, 0.f, 1.f})
.draw(material, geometry);
std::this_thread::sleep_for(
time::to_chrono(make_milliseconds(10)));
material.properties()
.sampler("u_texture", render::sampler_state()
.texture(rt->color())
.min_filter(render::sampler_min_filter::linear)
.mag_filter(render::sampler_mag_filter::linear));
the<render>()
.set_render_target(nullptr)
.set_viewport(the<window>().real_size())
.clear_depth_buffer(1.f)
.clear_stencil_buffer(0)
.clear_color_buffer({1.f, 0.4f, 0.f, 1.f})
.draw(material, geometry);
std::this_thread::sleep_for(time::to_chrono(make_milliseconds(10)));
the<window>().swap_buffers(true);
the<input>().frame_tick();
window::poll_events();
}