summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2023-04-12 00:08:56 +0200
committerStanislaw Halik <sthalik@misaki.pl>2023-04-12 00:08:56 +0200
commit903e1644fce5652a621803a6eb3617d605d22434 (patch)
treece088b04f92ffc8bdb5e6c1d31e3981e20a5b2bb /main
parent993d828c3c2cdab6174e460c39a605dbd31d192c (diff)
wip
Diffstat (limited to 'main')
-rw-r--r--main/draw.cpp28
-rw-r--r--main/main-impl.hpp2
2 files changed, 9 insertions, 21 deletions
diff --git a/main/draw.cpp b/main/draw.cpp
index 732c9cee..2c9d6964 100644
--- a/main/draw.cpp
+++ b/main/draw.cpp
@@ -31,19 +31,19 @@ void main_impl::recalc_viewport(Vector2i fb_size, Vector2i win_size) noexcept
framebuffer.color = GL::Texture2D{};
framebuffer.color.setStorage(1, GL::TextureFormat::RGBA8, fb_size);
framebuffer.depth = GL::Renderbuffer{};
- framebuffer.depth.setStorage(GL::RenderbufferFormat::DepthComponent32F, fb_size);
+ framebuffer.depth.setStorage(GL::RenderbufferFormat::Depth32FStencil8, fb_size);
framebuffer.fb.attachTexture(GL::Framebuffer::ColorAttachment{0}, framebuffer.color, 0);
- framebuffer.fb.attachRenderbuffer(GL::Framebuffer::BufferAttachment::Depth, framebuffer.depth);
+ framebuffer.fb.attachRenderbuffer(GL::Framebuffer::BufferAttachment::DepthStencil, framebuffer.depth);
framebuffer.fb.clearColor(0, Color4{0.f, 0.f, 0.f, 1.f});
- framebuffer.fb.clearDepth(0);
+ framebuffer.fb.clearDepthStencil(0, 0);
framebuffer.fb.bind();
}
#else
GL::defaultFramebuffer.setViewport({{}, fb_size });
GL::defaultFramebuffer.clearColor(Color4{0.f, 0.f, 0.f, 1.f});
- GL::defaultFramebuffer.clearDepth(0);
+ GL::defaultFramebuffer.clearDepthStencil(0, 0);
GL::defaultFramebuffer.bind();
#endif
@@ -113,7 +113,7 @@ void main_impl::draw_world() noexcept
_clickable_scenery.clear();
#ifdef FM_USE_DEPTH32
- framebuffer.fb.clearDepth(0);
+ framebuffer.fb.clearDepthStencil(0, 0);
#else
GL::defaultFramebuffer.clearDepth(0);
#endif
@@ -127,28 +127,16 @@ void main_impl::draw_world() noexcept
for (int16_t x = minx; x <= maxx; x++)
{
const chunk_coords_ pos{x, y, z};
- if (pos == chunk_coords_{} && !_world.contains(pos))
- app.maybe_initialize_chunk(pos, _world[pos]);
- auto* c_ = _world.at(pos);
- if (!c_)
- continue;
- auto& c = *c_;
- const with_shifted_camera_offset o{_shader, pos, {minx, miny}, {maxx, maxy}};
- if (check_chunk_visible(_shader.camera_offset(), sz))
- _floor_mesh.draw(_shader, c);
- }
-
- for (int16_t y = miny; y <= maxy; y++)
- for (int16_t x = minx; x <= maxx; x++)
- {
- const chunk_coords_ pos{x, y, z};
auto* c_ = _world.at(pos);
if (!c_)
continue;
auto& c = *c_;
const with_shifted_camera_offset o{_shader, pos, {minx, miny}, {maxx, maxy}};
if (check_chunk_visible(_shader.camera_offset(), sz))
+ {
_wall_mesh.draw(_shader, c);
+ _floor_mesh.draw(_shader, c);
+ }
}
GL::Renderer::setDepthMask(false);
diff --git a/main/main-impl.hpp b/main/main-impl.hpp
index fc20c947..63d18b72 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>