summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-08 15:59:19 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-08 15:59:19 +0200
commit3570e2f5aefdd0b5d262fe99ccd8b4a54aa79b83 (patch)
treedd6f1b9f1cc4fbd4ac74de7b6e0cd90900c75330 /main
parentc908c0cc43211d9937340b2a0704e8c53241b035 (diff)
fix wall z>0 clipping over z=0 scenery
Diffstat (limited to 'main')
-rw-r--r--main/draw.cpp18
-rw-r--r--main/main-impl.hpp2
2 files changed, 10 insertions, 10 deletions
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 <Magnum/GL/DebugOutput.h>
#include <Magnum/Platform/Sdl2Application.h>
-//#define FM_USE_DEPTH32
+#define FM_USE_DEPTH32
#ifdef FM_USE_DEPTH32
#include <Magnum/GL/Framebuffer.h>