From de45406eaea69e5730bcb26e5cf7e455d5253fc4 Mon Sep 17 00:00:00 2001 From: Robertleoj Date: Sat, 28 Feb 2026 15:04:21 +0100 Subject: [PATCH 1/3] wip --- .../src/slamd/bindings/__init__.pyi | 4 +-- python_bindings/src/slamd/bindings/geom.pyi | 18 +++++----- python_bindings/src/slamd/bindings/geom2d.pyi | 4 +-- python_examples/bunch_of_triads.py | 2 +- slamd/include/slamd_window/frame_buffer.hpp | 2 +- .../slamd_window/geom/arcball_indicator.hpp | 1 + slamd/include/slamd_window/state_manager.hpp | 2 +- slamd/include/slamd_window/view/view.hpp | 3 ++ slamd/src/window/frame_buffer.cpp | 5 +-- slamd/src/window/geom/arcball_indicator.cpp | 9 +++++ slamd/src/window/glfw.cpp | 1 + slamd/src/window/run_window.cpp | 36 +++++++++---------- slamd/src/window/state_manager.cpp | 8 +++-- slamd/src/window/view/canvas_view.cpp | 14 ++++++-- slamd/src/window/view/scene_view.cpp | 14 ++++++-- slamd/src/window/view/view.cpp | 4 +++ tools/build_python.py | 2 +- 17 files changed, 83 insertions(+), 46 deletions(-) diff --git a/python_bindings/src/slamd/bindings/__init__.pyi b/python_bindings/src/slamd/bindings/__init__.pyi index fb7d0381..ac48d649 100644 --- a/python_bindings/src/slamd/bindings/__init__.pyi +++ b/python_bindings/src/slamd/bindings/__init__.pyi @@ -27,7 +27,7 @@ class Scene: def set_transform(self, path: str, transform: numpy.ndarray) -> None: ... class Visualizer: - def __init__(self, name: str, port: typing.SupportsInt = 5555) -> None: + def __init__(self, name: str, port: typing.SupportsInt | typing.SupportsIndex = 5555) -> None: ... def add_canvas(self, name: str, canvas: Canvas) -> None: ... @@ -41,5 +41,5 @@ class Visualizer: ... def scene(self, name: str) -> Scene: ... -def spawn_window(port: typing.SupportsInt = 5555, executable_path: str | None = None) -> None: +def spawn_window(port: typing.SupportsInt | typing.SupportsIndex = 5555, executable_path: str | None = None) -> None: ... diff --git a/python_bindings/src/slamd/bindings/geom.pyi b/python_bindings/src/slamd/bindings/geom.pyi index fab1f7ce..b09967cd 100644 --- a/python_bindings/src/slamd/bindings/geom.pyi +++ b/python_bindings/src/slamd/bindings/geom.pyi @@ -4,7 +4,7 @@ import collections.abc import numpy import typing __all__ = ['Arrows', 'Box', 'CameraFrustum', 'Mesh', 'Plane', 'PointCloud', 'PolyLine', 'Sphere', 'Triad'] -def Arrows(starts: numpy.ndarray, ends: numpy.ndarray, colors: numpy.ndarray, thickness: typing.SupportsFloat) -> bindings._geom.Arrows: +def Arrows(starts: numpy.ndarray, ends: numpy.ndarray, colors: numpy.ndarray, thickness: typing.SupportsFloat | typing.SupportsIndex) -> bindings._geom.Arrows: """ Create an Arrows geometry """ @@ -12,37 +12,37 @@ def Box() -> bindings._geom.Box: """ Create a Box geometry """ -def CameraFrustum(intrinsics_matrix: numpy.ndarray, image_width: typing.SupportsInt, image_height: typing.SupportsInt, image: numpy.ndarray | None = None, scale: typing.SupportsFloat = 1.0) -> bindings._geom.CameraFrustum: +def CameraFrustum(intrinsics_matrix: numpy.ndarray, image_width: typing.SupportsInt | typing.SupportsIndex, image_height: typing.SupportsInt | typing.SupportsIndex, image: numpy.ndarray | None = None, scale: typing.SupportsFloat | typing.SupportsIndex = 1.0) -> bindings._geom.CameraFrustum: """ Create a CameraFrustum geometry """ @typing.overload -def Mesh(vertices: numpy.ndarray, vertex_colors: numpy.ndarray, triangle_indices: collections.abc.Sequence[typing.SupportsInt]) -> bindings._geom.Mesh: +def Mesh(vertices: numpy.ndarray, vertex_colors: numpy.ndarray, triangle_indices: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex]) -> bindings._geom.Mesh: """ Create a SimpleMesh geometry from raw data """ @typing.overload -def Mesh(vertices: numpy.ndarray, vertex_colors: numpy.ndarray, triangle_indices: collections.abc.Sequence[typing.SupportsInt], vertex_normals: numpy.ndarray) -> bindings._geom.Mesh: +def Mesh(vertices: numpy.ndarray, vertex_colors: numpy.ndarray, triangle_indices: collections.abc.Sequence[typing.SupportsInt | typing.SupportsIndex], vertex_normals: numpy.ndarray) -> bindings._geom.Mesh: """ Create a SimpleMesh geometry from raw data """ -def Plane(normal: numpy.ndarray, point: numpy.ndarray, color: numpy.ndarray, radius: typing.SupportsFloat, alpha: typing.SupportsFloat) -> bindings._geom.Plane: +def Plane(normal: numpy.ndarray, point: numpy.ndarray, color: numpy.ndarray, radius: typing.SupportsFloat | typing.SupportsIndex, alpha: typing.SupportsFloat | typing.SupportsIndex) -> bindings._geom.Plane: """ Create a Plane geometry """ -def PointCloud(positions: numpy.ndarray, colors: numpy.ndarray, radii: list[float] | numpy.ndarray, min_brightness: typing.SupportsFloat = 1.0) -> bindings._geom.PointCloud: +def PointCloud(positions: numpy.ndarray, colors: numpy.ndarray, radii: list[float] | numpy.ndarray, min_brightness: typing.SupportsFloat | typing.SupportsIndex = 1.0) -> bindings._geom.PointCloud: """ Create a PointCloud with per-point color and radius """ -def PolyLine(points: numpy.ndarray, thickness: typing.SupportsFloat, color: numpy.ndarray, min_brightness: typing.SupportsFloat) -> bindings._geom.PolyLine: +def PolyLine(points: numpy.ndarray, thickness: typing.SupportsFloat | typing.SupportsIndex, color: numpy.ndarray, min_brightness: typing.SupportsFloat | typing.SupportsIndex) -> bindings._geom.PolyLine: """ Create a PolyLine geometry """ -def Sphere(radius: typing.SupportsFloat = 1.0, color: numpy.ndarray = ...) -> bindings._geom.Sphere: +def Sphere(radius: typing.SupportsFloat | typing.SupportsIndex = 1.0, color: numpy.ndarray = ...) -> bindings._geom.Sphere: """ Create a Sphere geometry """ -def Triad(pose: numpy.ndarray[float32[4][4]] | None = None, scale: typing.SupportsFloat = 1.0, thickness: typing.SupportsFloat = 0.10000000149011612) -> bindings._geom.Triad: +def Triad(pose: numpy.ndarray[float32[4][4]] | None = None, scale: typing.SupportsFloat | typing.SupportsIndex = 1.0, thickness: typing.SupportsFloat | typing.SupportsIndex = 0.10000000149011612) -> bindings._geom.Triad: """ Create a Triad geometry """ diff --git a/python_bindings/src/slamd/bindings/geom2d.pyi b/python_bindings/src/slamd/bindings/geom2d.pyi index 231346cf..74efc652 100644 --- a/python_bindings/src/slamd/bindings/geom2d.pyi +++ b/python_bindings/src/slamd/bindings/geom2d.pyi @@ -3,7 +3,7 @@ import bindings._geom import numpy import typing __all__ = ['Circles', 'Image', 'Points', 'PolyLine'] -def Circles(positions: numpy.ndarray, colors: numpy.ndarray, radii: list[float] | numpy.ndarray, thickness: typing.SupportsFloat = 0.1) -> bindings._geom.Circles2D: +def Circles(positions: numpy.ndarray, colors: numpy.ndarray, radii: list[float] | numpy.ndarray, thickness: typing.SupportsFloat | typing.SupportsIndex = 0.1) -> bindings._geom.Circles2D: """ Create a set of circles """ @@ -15,7 +15,7 @@ def Points(positions: numpy.ndarray, colors: numpy.ndarray, radii: list[float] | """ Create 2D points with per-point color and radius """ -def PolyLine(points: numpy.ndarray, color: numpy.ndarray, thickness: typing.SupportsFloat) -> bindings._geom.PolyLine2D: +def PolyLine(points: numpy.ndarray, color: numpy.ndarray, thickness: typing.SupportsFloat | typing.SupportsIndex) -> bindings._geom.PolyLine2D: """ Create a 2D poly line """ diff --git a/python_examples/bunch_of_triads.py b/python_examples/bunch_of_triads.py index 1fd943b9..d7acbf90 100644 --- a/python_examples/bunch_of_triads.py +++ b/python_examples/bunch_of_triads.py @@ -21,7 +21,7 @@ def random_poses(n: int, t_scale: float = 10.0) -> np.ndarray: def main(): - vis = slamd.Visualizer("poses") + vis = slamd.Visualizer("poses", port=4399) scene = vis.scene("poses") for i, pose_mat in enumerate(random_poses(100, 10)): diff --git a/slamd/include/slamd_window/frame_buffer.hpp b/slamd/include/slamd_window/frame_buffer.hpp index 039e213d..31ec42ac 100644 --- a/slamd/include/slamd_window/frame_buffer.hpp +++ b/slamd/include/slamd_window/frame_buffer.hpp @@ -24,7 +24,7 @@ class FrameBuffer { ~FrameBuffer(); uint32_t frame_texture(); // Resolved texture ID - void rescale(size_t width, size_t height); + bool rescale(size_t width, size_t height); void bind(); // Bind MSAA FBO for rendering void unbind(); // Unbind void resolve(); // Blit MSAA → resolved texture diff --git a/slamd/include/slamd_window/geom/arcball_indicator.hpp b/slamd/include/slamd_window/geom/arcball_indicator.hpp index b67360a4..d2bf8668 100644 --- a/slamd/include/slamd_window/geom/arcball_indicator.hpp +++ b/slamd/include/slamd_window/geom/arcball_indicator.hpp @@ -15,6 +15,7 @@ class ArcballIndicator : public Geometry { void set_arcball_zoom(float zoom); void interact(); + bool is_animating() const; private: static glm::mat4 get_scale_mat(float scale); diff --git a/slamd/include/slamd_window/state_manager.hpp b/slamd/include/slamd_window/state_manager.hpp index d73a2da0..d862673b 100644 --- a/slamd/include/slamd_window/state_manager.hpp +++ b/slamd/include/slamd_window/state_manager.hpp @@ -20,7 +20,7 @@ class StateManager { void try_connect(std::string ip = "127.0.0.1", ushort port = 5555); - void apply_updates(); + bool apply_updates(); private: void handle_initial_state(const slamd::flatb::InitialState* initial_state); diff --git a/slamd/include/slamd_window/view/view.hpp b/slamd/include/slamd_window/view/view.hpp index 7d21a2a4..5a5a0a0f 100644 --- a/slamd/include/slamd_window/view/view.hpp +++ b/slamd/include/slamd_window/view/view.hpp @@ -12,7 +12,10 @@ class View { static std::unique_ptr deserialize(const flatb::View* view, std::shared_ptr tree); + void mark_dirty(); + public: + bool _dirty = true; std::shared_ptr tree; std::unordered_map tree_open; std::optional visualize_glob = std::nullopt; diff --git a/slamd/src/window/frame_buffer.cpp b/slamd/src/window/frame_buffer.cpp index a6ec721c..68f0d1e3 100644 --- a/slamd/src/window/frame_buffer.cpp +++ b/slamd/src/window/frame_buffer.cpp @@ -159,12 +159,12 @@ void FrameBuffer::resolve() { gl::glBindFramebuffer(gl::GL_FRAMEBUFFER, 0); } -void FrameBuffer::rescale( +bool FrameBuffer::rescale( size_t width, size_t height ) { if (width == current_width && height == current_height) { - return; + return false; } current_width = width; @@ -211,6 +211,7 @@ void FrameBuffer::rescale( width, height ); + return true; } double FrameBuffer::aspect() const { diff --git a/slamd/src/window/geom/arcball_indicator.cpp b/slamd/src/window/geom/arcball_indicator.cpp index b04100a2..8a3a783e 100644 --- a/slamd/src/window/geom/arcball_indicator.cpp +++ b/slamd/src/window/geom/arcball_indicator.cpp @@ -118,6 +118,15 @@ void ArcballIndicator::render( gl::glBindVertexArray(0); }; +bool ArcballIndicator::is_animating() const { + if (!this->last_interacted.has_value()) { + return false; + } + auto now = std::chrono::high_resolution_clock::now(); + std::chrono::duration secs = now - last_interacted.value(); + return secs.count() < 0.4f; +} + void ArcballIndicator::set_arcball_zoom( float zoom ) { diff --git a/slamd/src/window/glfw.cpp b/slamd/src/window/glfw.cpp index 39c232f5..ac5267a6 100644 --- a/slamd/src/window/glfw.cpp +++ b/slamd/src/window/glfw.cpp @@ -27,6 +27,7 @@ GLFWwindow* make_window( SPDLOG_INFO("GLFW window created"); glfwMakeContextCurrent(window); + glfwSwapInterval(1); glbinding::initialize(glfwGetProcAddress); diff --git a/slamd/src/window/run_window.cpp b/slamd/src/window/run_window.cpp index dacb1004..101e9029 100644 --- a/slamd/src/window/run_window.cpp +++ b/slamd/src/window/run_window.cpp @@ -6,7 +6,6 @@ #include #include #include -#include #include #include @@ -109,11 +108,13 @@ inline void tree_menu( ); ImGui::PushStyleVar(ImGuiStyleVar_FrameBorderSize, 1.0f); } - ImGui::InputText( - "##filter", - view->filter_buf, - IM_ARRAYSIZE(view->filter_buf) - ); + if (ImGui::InputText( + "##filter", + view->filter_buf, + IM_ARRAYSIZE(view->filter_buf) + )) { + view->mark_dirty(); + } if (filter_error_text.has_value()) { ImGui::PopStyleVar(); ImGui::PopStyleColor(4); @@ -173,7 +174,9 @@ inline void tree_menu( ImGui::PushStyleVar(ImGuiStyleVar_Alpha, base_alpha * 0.45f); } - ImGui::Checkbox("##visible", &n->checked); + if (ImGui::Checkbox("##visible", &n->checked)) { + view->mark_dirty(); + } ImGui::SameLine(0.0f, 4.0f); bool open = false; @@ -370,13 +373,16 @@ void run_window( ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 330"); - FrameTimer frame_timer; - constexpr double target_frame_time = 1.0 / 120.0; // ~0.00833 seconds bool loaded_layout = false; bool checked_layout = false; while (!glfwWindowShouldClose(window)) { - state_manager.apply_updates(); + bool had_updates = state_manager.apply_updates(); + if (had_updates) { + for (auto& [name, view] : state_manager.views) { + view->mark_dirty(); + } + } ImGui_ImplOpenGL3_NewFrame(); ImGui_ImplGlfw_NewFrame(); @@ -444,16 +450,6 @@ void run_window( glfwSwapBuffers(window); glfwPollEvents(); - - frame_timer.log_frame(); - float frame_time = frame_timer.timedelta(); - - if (frame_time < target_frame_time) { - float sleep_duration = target_frame_time - frame_time; - std::this_thread::sleep_for( - std::chrono::duration(sleep_duration) - ); - } } SPDLOG_INFO("Window closed!"); diff --git a/slamd/src/window/state_manager.cpp b/slamd/src/window/state_manager.cpp index 2fc322fe..d10b4732 100644 --- a/slamd/src/window/state_manager.cpp +++ b/slamd/src/window/state_manager.cpp @@ -247,19 +247,21 @@ void StateManager::handle_update_point_cloud_radii( geom->update_radii(data); } -void StateManager::apply_updates() { +bool StateManager::apply_updates() { if (!this->connection.has_value()) { - return; + return false; } auto& connection = this->connection.value(); auto& message_queue = connection.messages; + bool had_updates = false; while (true) { auto maybe_message = message_queue.try_pop(); if (!maybe_message.has_value()) { - return; + return had_updates; } + had_updates = true; auto message = std::move(maybe_message.value()); auto message_fb = message->msg(); diff --git a/slamd/src/window/view/canvas_view.cpp b/slamd/src/window/view/canvas_view.cpp index 6f421989..c01cfc21 100644 --- a/slamd/src/window/view/canvas_view.cpp +++ b/slamd/src/window/view/canvas_view.cpp @@ -21,7 +21,7 @@ void CanvasView::render_to_imgui() { int width = static_cast(image_size.x); int height = static_cast(image_size.y); - this->frame_buffer.rescale(width, height); + bool resized = this->frame_buffer.rescale(width, height); if (!this->manually_moved) { this->set_default_pos(); @@ -29,7 +29,12 @@ void CanvasView::render_to_imgui() { this->fix_view_aspect(); } - this->render_to_frame_buffer(); + bool need_render = this->_dirty || resized; + + if (need_render) { + this->render_to_frame_buffer(); + this->_dirty = false; + } ImGui::Image( (ImTextureID)this->frame_buffer.frame_texture(), @@ -99,6 +104,7 @@ void CanvasView::handle_input() { if (ImGui::IsKeyPressed(ImGuiKey_Period, false)) { this->set_default_pos(); this->manually_moved = false; + this->mark_dirty(); } } } @@ -127,6 +133,7 @@ void CanvasView::handle_mouse_input() { {-mouse_drag_delta_x, -mouse_drag_delta_y} ); this->manually_moved = true; + this->mark_dirty(); } if (io.MouseWheel != 0.0f) { @@ -140,6 +147,7 @@ void CanvasView::handle_mouse_input() { ); this->manually_moved = true; + this->mark_dirty(); } } } @@ -194,11 +202,13 @@ void CanvasView::handle_translation_input() { if (glm::length(translation) > 1e-6f) { this->manually_moved = true; this->camera.translate_relative(translation); + this->mark_dirty(); } if (glm::abs(zoom) > 1e-6f) { this->manually_moved = true; this->camera.zoom_relative(zoom); + this->mark_dirty(); } } diff --git a/slamd/src/window/view/scene_view.cpp b/slamd/src/window/view/scene_view.cpp index 5e344813..2c33cda4 100644 --- a/slamd/src/window/view/scene_view.cpp +++ b/slamd/src/window/view/scene_view.cpp @@ -28,9 +28,15 @@ void SceneView::render_to_imgui() { ImVec2 availSize = ImGui::GetContentRegionAvail(); int width = static_cast(availSize.x); int height = static_cast(availSize.y); - this->frame_buffer.rescale(width, height); + bool resized = this->frame_buffer.rescale(width, height); - this->render_to_frame_buffer(); + bool need_render = + this->_dirty || resized || this->arcball_indicator.is_animating(); + + if (need_render) { + this->render_to_frame_buffer(); + this->_dirty = false; + } ImGui::Image( (ImTextureID)this->frame_buffer.frame_texture(), @@ -83,6 +89,7 @@ void SceneView::handle_input() { this->xy_grid.set_arcball_zoom(this->arcball.radius); this->arcball_indicator.set_arcball_zoom(this->arcball.radius); this->arcball_indicator.interact(); + this->mark_dirty(); } } } @@ -119,6 +126,7 @@ void SceneView::handle_mouse_input() { -slamd::gmath::Angle::rad(y_angle_diff) ); this->arcball_indicator.interact(); + this->mark_dirty(); } if (io.MouseWheel != 0.0f) { @@ -136,6 +144,7 @@ void SceneView::handle_mouse_input() { this->xy_grid.set_arcball_zoom(this->arcball.radius); this->arcball_indicator.set_arcball_zoom(this->arcball.radius); this->arcball_indicator.interact(); + this->mark_dirty(); } } } @@ -175,6 +184,7 @@ void SceneView::handle_translation_input() { if (glm::length(translation) > 1e-6f) { this->arcball.translate_relative(translation); this->arcball_indicator.interact(); + this->mark_dirty(); } } diff --git a/slamd/src/window/view/view.cpp b/slamd/src/window/view/view.cpp index 1a22d35b..c319482f 100644 --- a/slamd/src/window/view/view.cpp +++ b/slamd/src/window/view/view.cpp @@ -9,6 +9,10 @@ View::View( ) : tree(std::move(t)) {} +void View::mark_dirty() { + this->_dirty = true; +} + std::unique_ptr View::deserialize( const flatb::View* view_fb, std::shared_ptr tree diff --git a/tools/build_python.py b/tools/build_python.py index 50443bc8..4fa9e4ff 100644 --- a/tools/build_python.py +++ b/tools/build_python.py @@ -17,7 +17,7 @@ BUILD_DIR = "build" -TARGET_NAME = "bindings.cpython-311-x86_64-linux-gnu.so" +TARGET_NAME = "bindings.cpython-313-x86_64-linux-gnu.so" LIB_PATH = Path("./build") / TARGET_NAME DEST_PATH = Path("./src/slamd/") / TARGET_NAME From 23dac302a890f6336adc13d24dfd1b672c521329 Mon Sep 17 00:00:00 2001 From: Robertleoj Date: Sat, 28 Feb 2026 15:09:04 +0100 Subject: [PATCH 2/3] wip --- slamd/src/window/glfw.cpp | 1 - slamd/src/window/run_window.cpp | 14 ++++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/slamd/src/window/glfw.cpp b/slamd/src/window/glfw.cpp index ac5267a6..39c232f5 100644 --- a/slamd/src/window/glfw.cpp +++ b/slamd/src/window/glfw.cpp @@ -27,7 +27,6 @@ GLFWwindow* make_window( SPDLOG_INFO("GLFW window created"); glfwMakeContextCurrent(window); - glfwSwapInterval(1); glbinding::initialize(glfwGetProcAddress); diff --git a/slamd/src/window/run_window.cpp b/slamd/src/window/run_window.cpp index 101e9029..88df3b21 100644 --- a/slamd/src/window/run_window.cpp +++ b/slamd/src/window/run_window.cpp @@ -6,8 +6,10 @@ #include #include #include +#include #include #include +#include namespace slamd { @@ -373,6 +375,7 @@ void run_window( ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 330"); + FrameTimer frame_timer; bool loaded_layout = false; bool checked_layout = false; @@ -450,6 +453,17 @@ void run_window( glfwSwapBuffers(window); glfwPollEvents(); + + frame_timer.log_frame(); + float frame_time = frame_timer.timedelta(); + constexpr double target_frame_time = 1.0 / 120.0; + + if (frame_time < target_frame_time) { + float sleep_duration = target_frame_time - frame_time; + std::this_thread::sleep_for( + std::chrono::duration(sleep_duration) + ); + } } SPDLOG_INFO("Window closed!"); From 5957ba3e0bf25ea85fd7ab73d38b88d33a2fa840 Mon Sep 17 00:00:00 2001 From: Robertleoj Date: Sat, 28 Feb 2026 15:16:57 +0100 Subject: [PATCH 3/3] wip --- .vscode/settings.json | 6 +++--- slamd/src/window/glfw.cpp | 1 + slamd/src/window/run_window.cpp | 14 -------------- 3 files changed, 4 insertions(+), 17 deletions(-) diff --git a/.vscode/settings.json b/.vscode/settings.json index bd9e3964..bb965869 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,7 +1,7 @@ { "clangd.arguments": [ - // "--compile-commands-dir=python_examples/build", - "--compile-commands-dir=examples/build", + "--compile-commands-dir=python_bindings/build", + // "--compile-commands-dir=examples/build", "--function-arg-placeholders=false", "--tweaks=-Wall", "--tweaks=-Wextra", @@ -120,7 +120,7 @@ "C_Cpp.inlayHints.parameterNames.enabled": true, "C_Cpp.inlayHints.referenceOperator.enabled": true, "python.analysis.extraPaths": ["python_bindings/src/"], - "cmake.sourceDirectory": "/home/robert/learning/slam_dunk/examples", + "cmake.sourceDirectory": "/home/robert/projects/slam_dunk/examples", "python.analysis.exclude": [ "**/build/", "**/.venv/", diff --git a/slamd/src/window/glfw.cpp b/slamd/src/window/glfw.cpp index 39c232f5..ac5267a6 100644 --- a/slamd/src/window/glfw.cpp +++ b/slamd/src/window/glfw.cpp @@ -27,6 +27,7 @@ GLFWwindow* make_window( SPDLOG_INFO("GLFW window created"); glfwMakeContextCurrent(window); + glfwSwapInterval(1); glbinding::initialize(glfwGetProcAddress); diff --git a/slamd/src/window/run_window.cpp b/slamd/src/window/run_window.cpp index 88df3b21..101e9029 100644 --- a/slamd/src/window/run_window.cpp +++ b/slamd/src/window/run_window.cpp @@ -6,10 +6,8 @@ #include #include #include -#include #include #include -#include namespace slamd { @@ -375,7 +373,6 @@ void run_window( ImGui_ImplGlfw_InitForOpenGL(window, true); ImGui_ImplOpenGL3_Init("#version 330"); - FrameTimer frame_timer; bool loaded_layout = false; bool checked_layout = false; @@ -453,17 +450,6 @@ void run_window( glfwSwapBuffers(window); glfwPollEvents(); - - frame_timer.log_frame(); - float frame_time = frame_timer.timedelta(); - constexpr double target_frame_time = 1.0 / 120.0; - - if (frame_time < target_frame_time) { - float sleep_duration = target_frame_time - frame_time; - std::this_thread::sleep_for( - std::chrono::duration(sleep_duration) - ); - } } SPDLOG_INFO("Window closed!");