From 3570e2f5aefdd0b5d262fe99ccd8b4a54aa79b83 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sat, 8 Apr 2023 15:59:19 +0200 Subject: fix wall z>0 clipping over z=0 scenery --- main/draw.cpp | 18 +++++++++--------- main/main-impl.hpp | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'main') diff --git a/main/draw.cpp b/main/draw.cpp index 9adb38a2..1a46d4f6 100644 --- a/main/draw.cpp +++ b/main/draw.cpp @@ -22,7 +22,7 @@ void main_impl::recalc_viewport(Vector2i fb_size, Vector2i win_size) noexcept update_window_state(); _shader.set_scale(Vector2{fb_size}); - GL::defaultFramebuffer.bind(); + GL::Renderer::setDepthMask(true); #ifdef FM_USE_DEPTH32 { @@ -40,9 +40,12 @@ void main_impl::recalc_viewport(Vector2i fb_size, Vector2i win_size) noexcept framebuffer.fb.bind(); } -#endif - +#else GL::defaultFramebuffer.setViewport({{}, fb_size }); + GL::defaultFramebuffer.clearColor(Color4{0.f, 0.f, 0.f, 1.f}); + GL::defaultFramebuffer.clearDepth(0); + GL::defaultFramebuffer.bind(); +#endif // -- state --- using R = GL::Renderer; @@ -125,10 +128,11 @@ void main_impl::draw_world() noexcept #else GL::defaultFramebuffer.clearDepth(0); #endif + GL::Renderer::enable(GL::Renderer::Feature::DepthTest); - for (int8_t z = z_min; z <= z_max; z++) + for (int8_t z = z_max; z >= z_min; z--) { - GL::Renderer::setDepthMask(false); + GL::Renderer::setDepthMask(true); for (int16_t y = miny; y <= maxy; y++) for (int16_t x = minx; x <= maxx; x++) @@ -145,9 +149,6 @@ void main_impl::draw_world() noexcept _floor_mesh.draw(_shader, c); } - GL::Renderer::setDepthMask(true); - GL::Renderer::enable(GL::Renderer::Feature::DepthTest); - for (int16_t y = miny; y <= maxy; y++) for (int16_t x = minx; x <= maxx; x++) { @@ -178,7 +179,6 @@ void main_impl::draw_world() noexcept } GL::Renderer::setDepthMask(true); - GL::Renderer::disable(GL::Renderer::Feature::DepthTest); } diff --git a/main/main-impl.hpp b/main/main-impl.hpp index 859f2a8f..2cfeffd4 100644 --- a/main/main-impl.hpp +++ b/main/main-impl.hpp @@ -14,7 +14,7 @@ #include #include -//#define FM_USE_DEPTH32 +#define FM_USE_DEPTH32 #ifdef FM_USE_DEPTH32 #include -- cgit v1.2.3