1717#include < nanogui/widget.h>
1818#include < nanogui/texture.h>
1919#include < nanogui/colorpass.h>
20+ #include < nanogui/ema.h>
2021
2122NAMESPACE_BEGIN (nanogui)
2223
@@ -220,6 +221,12 @@ class NANOGUI_EXPORT Screen : public Widget {
220221 // / Does the framebuffer use a floating point representation
221222 bool has_float_buffer () const { return m_float_buffer; }
222223
224+ // / Get the index of the last (or current) frame being rendered
225+ uint64_t frame_index () const { return m_frame_index; }
226+
227+ // / Get a smoothed estimate of the rendering time per frame (second-based)
228+ double frame_time () const { return m_frame_timer.value (); }
229+
223230 // / Does the screen apply color management as a post processing shader?
224231 bool applies_color_management () const {
225232#if defined(NANOGUI_USE_METAL)
@@ -316,6 +323,7 @@ class NANOGUI_EXPORT Screen : public Widget {
316323 bool m_drag_active;
317324 Widget *m_drag_widget = nullptr ;
318325 double m_last_interaction;
326+ double m_last_draw;
319327 Color m_background;
320328 std::string m_caption;
321329 bool m_shutdown_glfw;
@@ -332,6 +340,8 @@ class NANOGUI_EXPORT Screen : public Widget {
332340 ref<Texture> m_depth_stencil_texture;
333341 ref<RestartableTimer> m_tooltip_timer;
334342 bool m_tooltip_force_visible = false ;
343+ EMA<double > m_frame_timer;
344+ uint64_t m_frame_index;
335345#if defined(NANOGUI_USE_METAL)
336346 void *m_metal_texture = nullptr ;
337347 void *m_metal_drawable = nullptr ;
0 commit comments