summaryrefslogtreecommitdiffhomepage
path: root/main
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2024-03-01 18:50:42 +0100
committerStanislaw Halik <sthalik@misaki.pl>2024-03-01 18:50:42 +0100
commite25a350f907a3833b39b8a7629a4a880fe7b0df4 (patch)
treea8db7fec45da043bcdd3c0c992125dda19a540a0 /main
parent65f51a72b5697e537338422a39a015f2207ab5bc (diff)
c
Diffstat (limited to 'main')
-rw-r--r--main/draw.cpp96
1 files changed, 48 insertions, 48 deletions
diff --git a/main/draw.cpp b/main/draw.cpp
index aef10add..9409d66c 100644
--- a/main/draw.cpp
+++ b/main/draw.cpp
@@ -13,6 +13,54 @@
namespace floormat {
+void main_impl::do_update()
+{
+ constexpr auto eps = 1e-5f;
+ auto dt = timeline.update();
+ if (auto secs = Time::to_seconds(dt); secs > eps)
+ {
+#if 1
+ constexpr float RC = 60;
+ constexpr auto alpha = 1 / (1 + RC);
+ _smoothed_frame_time = _smoothed_frame_time * (1 - alpha) + alpha * secs;
+#else
+ _frame_time = secs;
+#endif
+ static size_t ctr = 0;
+ if (secs > 35e-3f /* && !dt_expected.do_sleep */)
+ fm_debug("%zu frame took %.2f milliseconds", ctr++, (double)secs*1e3);
+ }
+ else
+ swapBuffers();
+
+ app.update(dt);
+}
+
+void main_impl::drawEvent()
+{
+ _shader.set_tint({1, 1, 1, 1});
+
+ constexpr auto clear_color = 0x222222ff_rgbaf;
+#ifdef FM_USE_DEPTH32
+ framebuffer.fb.clearColor(0, clear_color);
+#else
+ GL::defaultFramebuffer.clearColor(clear_color);
+#endif
+ draw_world();
+
+ app.draw();
+ GL::Renderer::flush();
+
+ do_update();
+
+#ifdef FM_USE_DEPTH32
+ GL::Framebuffer::blit(framebuffer.fb, GL::defaultFramebuffer, framebuffer.fb.viewport(), GL::FramebufferBlit::Color);
+#endif
+
+ swapBuffers();
+ redraw();
+}
+
void main_impl::draw_world() noexcept
{
const auto [z_min, z_max, z_cur, only] = app.get_z_bounds();
@@ -84,59 +132,11 @@ void main_impl::draw_world() noexcept
GL::Renderer::disable(GL::Renderer::Feature::DepthTest);
}
-void main_impl::do_update()
-{
- constexpr auto eps = 1e-5f;
- auto dt = timeline.update();
- if (auto secs = Time::to_seconds(dt); secs > eps)
- {
-#if 1
- constexpr float RC = 60;
- constexpr auto alpha = 1 / (1 + RC);
- _smoothed_frame_time = _smoothed_frame_time * (1 - alpha) + alpha * secs;
-#else
- _frame_time = secs;
-#endif
- static size_t ctr = 0;
- if (secs > 35e-3f /* && !dt_expected.do_sleep */)
- fm_debug("%zu frame took %.2f milliseconds", ctr++, (double)secs*1e3);
- }
- else
- swapBuffers();
-
- app.update(dt);
-}
-
void main_impl::bind() noexcept
{
framebuffer.fb.bind();
}
-void main_impl::drawEvent()
-{
- _shader.set_tint({1, 1, 1, 1});
-
- constexpr auto clear_color = 0x222222ff_rgbaf;
-#ifdef FM_USE_DEPTH32
- framebuffer.fb.clearColor(0, clear_color);
-#else
- GL::defaultFramebuffer.clearColor(clear_color);
-#endif
- draw_world();
-
- app.draw();
- GL::Renderer::flush();
-
- do_update();
-
-#ifdef FM_USE_DEPTH32
- GL::Framebuffer::blit(framebuffer.fb, GL::defaultFramebuffer, framebuffer.fb.viewport(), GL::FramebufferBlit::Color);
-#endif
-
- swapBuffers();
- redraw();
-}
-
ArrayView<const clickable> main_impl::clickable_scenery() const noexcept
{
return { _clickable_scenery.data(), _clickable_scenery.size() };