diff --git a/headers/enduro2d/core/render.hpp b/headers/enduro2d/core/render.hpp index 5418f0bd..9d14c70f 100644 --- a/headers/enduro2d/core/render.hpp +++ b/headers/enduro2d/core/render.hpp @@ -758,7 +758,7 @@ namespace e2d render& clear_depth_buffer(f32 value) noexcept; render& clear_stencil_buffer(u8 value) noexcept; render& clear_color_buffer(const color& value) noexcept; - render& set_viewport(const v2u& pos, const v2u& size) noexcept; + render& set_viewport(const r4u& rect) noexcept; render& set_render_target(const render_target_ptr& rt) noexcept; private: class internal_state; diff --git a/samples/sources/sample_00/sample_00.cpp b/samples/sources/sample_00/sample_00.cpp index 3f534df2..7f3c07a4 100644 --- a/samples/sources/sample_00/sample_00.cpp +++ b/samples/sources/sample_00/sample_00.cpp @@ -120,8 +120,7 @@ int e2d_main() { the().open(url("ships://ship (19).png"))); const auto shader = the().create_shader( - make_memory_stream(buffer(vs_source_cstr, std::strlen(vs_source_cstr))), - make_memory_stream(buffer(fs_source_cstr, std::strlen(fs_source_cstr)))); + vs_source_cstr, fs_source_cstr); const auto indices = generate_quad_indices(); const auto index_buffer = the().create_index_buffer( diff --git a/samples/sources/sample_01/sample_01.cpp b/samples/sources/sample_01/sample_01.cpp index 959847f9..353cff4c 100644 --- a/samples/sources/sample_01/sample_01.cpp +++ b/samples/sources/sample_01/sample_01.cpp @@ -178,8 +178,7 @@ int e2d_main() { the().open(url("ships://ship (3).png"))); const auto shader = the().create_shader( - make_memory_stream(buffer(vs_source_cstr, std::strlen(vs_source_cstr))), - make_memory_stream(buffer(fs_source_cstr, std::strlen(fs_source_cstr)))); + vs_source_cstr, fs_source_cstr); const auto indices = generate_cube_indices(); const auto index_buffer = the().create_index_buffer( diff --git a/samples/sources/sample_02/sample_02.cpp b/samples/sources/sample_02/sample_02.cpp index 2ab0d07d..0e31a6e5 100644 --- a/samples/sources/sample_02/sample_02.cpp +++ b/samples/sources/sample_02/sample_02.cpp @@ -133,8 +133,7 @@ int e2d_main() { the().open(url("ships://ship (3).png"))); const auto shader = the().create_shader( - make_memory_stream(buffer(vs_source_cstr, std::strlen(vs_source_cstr))), - make_memory_stream(buffer(fs_source_cstr, std::strlen(fs_source_cstr)))); + vs_source_cstr, fs_source_cstr); const auto indices = generate_cube_indices(); const auto index_buffer = the().create_index_buffer( @@ -214,7 +213,7 @@ int e2d_main() { the() .set_render_target(rt) - .set_viewport(v2u::zero(), rt->size()) + .set_viewport(rt->size()) .clear_depth_buffer(1.f) .clear_stencil_buffer(0) .clear_color_buffer({0.f, 0.4f, 0.f, 1.f}) @@ -228,7 +227,7 @@ int e2d_main() { the() .set_render_target(nullptr) - .set_viewport(v2u::zero(), the().real_size()) + .set_viewport(the().real_size()) .clear_depth_buffer(1.f) .clear_stencil_buffer(0) .clear_color_buffer({1.f, 0.4f, 0.f, 1.f}) diff --git a/sources/enduro2d/core/render_impl/render_none.cpp b/sources/enduro2d/core/render_impl/render_none.cpp index 72597852..aa159547 100644 --- a/sources/enduro2d/core/render_impl/render_none.cpp +++ b/sources/enduro2d/core/render_impl/render_none.cpp @@ -253,8 +253,8 @@ namespace e2d return *this; } - render& render::set_viewport(const v2u& pos, const v2u& size) noexcept { - E2D_UNUSED(pos, size); + render& render::set_viewport(const r4u& rect) noexcept { + E2D_UNUSED(rect); return *this; } diff --git a/sources/enduro2d/core/render_impl/render_opengl.cpp b/sources/enduro2d/core/render_impl/render_opengl.cpp index 01002518..fc8186b3 100644 --- a/sources/enduro2d/core/render_impl/render_opengl.cpp +++ b/sources/enduro2d/core/render_impl/render_opengl.cpp @@ -849,16 +849,17 @@ namespace e2d return *this; } - render& render::set_viewport(const v2u& pos, const v2u& size) noexcept { + render& render::set_viewport(const r4u& rect) noexcept { E2D_ASSERT( std::this_thread::get_id() == modules::main_thread()); + const r4u vp = make_minmax_rect(rect); GL_CHECK_CODE(state_->dbg(), glViewport( - math::numeric_cast(pos.x), - math::numeric_cast(pos.y), - math::numeric_cast(size.x), - math::numeric_cast(size.y))); + math::numeric_cast(vp.position.x), + math::numeric_cast(vp.position.y), + math::numeric_cast(vp.size.x), + math::numeric_cast(vp.size.y))); return *this; }