diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-20 08:07:31 +0100 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-11-20 08:07:31 +0100 |
commit | 469ef7e7097ee6d48163247fe56a5b6a042ed10f (patch) | |
tree | 4d416fe344ed9960f32ea9d8f6f553b29e8fb895 /main/draw.cpp | |
parent | 5db374dd83a08bc176b2735463b4119306bb94cd (diff) |
main: move animation drawing out of MSAA code
Diffstat (limited to 'main/draw.cpp')
-rw-r--r-- | main/draw.cpp | 28 |
1 files changed, 24 insertions, 4 deletions
diff --git a/main/draw.cpp b/main/draw.cpp index 98f5da85..1b441650 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -83,7 +83,7 @@ auto main_impl::get_draw_bounds() const noexcept -> draw_bounds void main_impl::draw_world() noexcept { - auto [minx, maxx, miny, maxy] = get_draw_bounds(); + const auto [minx, maxx, miny, maxy] = get_draw_bounds(); const auto sz = windowSize(); for (std::int16_t y = miny; y <= maxy; y++) @@ -110,14 +110,32 @@ void main_impl::draw_world() noexcept auto& c = _world[pos]; const with_shifted_camera_offset o{_shader, pos}; if (check_chunk_visible(_shader.camera_offset(), sz)) - { _wall_mesh.draw(_shader, c); + } + GL::Renderer::disable(GL::Renderer::Feature::DepthTest); +} + +void main_impl::draw_anim() noexcept +{ + const auto sz = windowSize(); + const auto [minx, maxx, miny, maxy] = get_draw_bounds(); + + GL::Renderer::enable(GL::Renderer::Feature::DepthTest); + + for (std::int16_t y = miny; y <= maxy; y++) + for (std::int16_t x = minx; x <= maxx; x++) + { + const chunk_coords pos{x, y}; + auto& c = _world[pos]; + const with_shifted_camera_offset o{_shader, pos}; + if (check_chunk_visible(_shader.camera_offset(), sz)) _anim_mesh.draw(_shader, c); - } } + GL::Renderer::disable(GL::Renderer::Feature::DepthTest); } + bool main_impl::check_chunk_visible(const Vector2d& offset, const Vector2i& size) noexcept { constexpr Vector3d len = dTILE_SIZE * TILE_MAX_DIM20d; @@ -181,9 +199,11 @@ void main_impl::drawEvent() { GL::defaultFramebuffer.bind(); using Blit = GL::FramebufferBlit; - constexpr auto blit_mask = Blit::Color /* | Blit::Depth | Blit::Stencil */; + constexpr auto blit_mask = Blit::Color | Blit::Depth | Blit::Stencil; GL::Framebuffer::blit(_msaa_framebuffer, GL::defaultFramebuffer, {{}, windowSize()}, blit_mask); } + _shader.set_tint({1, 1, 1, 1}); + draw_anim(); } app.draw(); |