From 1ce252b988963c605afe93ede3e1e3aec8f4d8e0 Mon Sep 17 00:00:00 2001 From: "C. J. Howard" Date: Mon, 17 Aug 2020 17:16:23 -0700 Subject: [PATCH] Fix memory leak in application::capture_frame() --- src/application.cpp | 1 - src/application.hpp | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/application.cpp b/src/application.cpp index c60f890..7f2498e 100644 --- a/src/application.cpp +++ b/src/application.cpp @@ -310,7 +310,6 @@ std::shared_ptr application::capture_frame() const frame->resize(w, h); // Read pixel data from framebuffer into image - unsigned char* pixels = new unsigned char[w * h * 3]; glReadBuffer(GL_BACK); glReadPixels(0, 0, w, h, GL_RGB, GL_UNSIGNED_BYTE, frame->get_pixels()); diff --git a/src/application.hpp b/src/application.hpp index 5cfbd4e..672a459 100644 --- a/src/application.hpp +++ b/src/application.hpp @@ -84,16 +84,16 @@ public: void change_state(const state_type& state); /** - * Captures a screenshot of last rendered frame. + * Captures a screenshot of the most recently rendered frame. * * @return Image containing the captured frame. */ std::shared_ptr capture_frame() const; /** - * Captures a screenshot of last rendered frame. + * Saves a PNG screenshot of the most recently rendered frame. * - * @return Image containing the captured frame. + * @param path File path to the where the screenshot should be saved. */ void save_frame(const std::string& path) const;