From 903e1644fce5652a621803a6eb3617d605d22434 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Wed, 12 Apr 2023 00:08:56 +0200 Subject: wip --- main/draw.cpp | 28 ++++++++-------------------- main/main-impl.hpp | 2 +- 2 files changed, 9 insertions(+), 21 deletions(-) (limited to 'main') 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 @@ -123,21 +123,6 @@ void main_impl::draw_world() noexcept { GL::Renderer::setDepthMask(true); - for (int16_t y = miny; y <= maxy; y++) - 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++) { @@ -148,7 +133,10 @@ void main_impl::draw_world() noexcept 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 #include -//#define FM_USE_DEPTH32 +#define FM_USE_DEPTH32 #ifdef FM_USE_DEPTH32 #include -- cgit v1.2.3