diff --git a/include/display.h b/include/display.h index 220cb1c2a..1553c4c4a 100644 --- a/include/display.h +++ b/include/display.h @@ -342,6 +342,11 @@ float display_get_delta_time(void); */ void display_set_fps_limit(float fps); +/** + * @brief Returns a surface that points to the framebuffer currently being shown on screen. + */ +surface_t display_get_current_framebuffer(void); + /** @cond */ __attribute__((deprecated("use display_get or display_try_get instead"))) static inline surface_t* display_lock(void) { diff --git a/src/display.c b/src/display.c index 4d987f139..55fba2dca 100644 --- a/src/display.c +++ b/src/display.c @@ -640,4 +640,13 @@ void display_set_fps_limit(float fps) enable_interrupts(); } +surface_t display_get_current_framebuffer(void) +{ + return surface_make_linear( + VirtualUncachedAddr(*VI_ORIGIN), + display_get_bitdepth() == 2 ? FMT_RGBA16 : FMT_RGBA32, + display_get_width(), + display_get_height()); +} + extern inline void vi_write_config(const vi_config_t* config);