Browse Source

Fix memory leak in application::capture_frame()

master
C. J. Howard 3 years ago
parent
commit
1ce252b988
2 changed files with 3 additions and 4 deletions
  1. +0
    -1
      src/application.cpp
  2. +3
    -3
      src/application.hpp

+ 0
- 1
src/application.cpp View File

@ -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());

+ 3
- 3
src/application.hpp View File

@ -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<image> 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;

Loading…
Cancel
Save