Player Frame capture F10

New feature of Player: capture frame (F10 shortcut). Extending the Screenshot class for reading pixels and saving to PNG. Cleaup of screenshot (now associated to F9).
This commit is contained in:
Bruno Herbelin
2022-06-22 01:40:47 +02:00
parent f2405e02f6
commit 7858033628
8 changed files with 182 additions and 85 deletions

View File

@@ -557,3 +557,30 @@ bool FrameBuffer::fill(FrameBufferImage *image)
}
//void FrameBuffer::writePNG(const std::string &filename)
//{
// // not ready
// if (!framebufferid_)
// return;
// // create a temporary RGBA frame buffer at the resolution of cropped area
// int w = attrib_.viewport.x * projection_area_.x;
// int h = attrib_.viewport.y * projection_area_.y;
// FrameBuffer copy(w, h, FrameBuffer_alpha);
// // create temporary RAM buffer to store the cropped RGBA
// uint8_t *buffer = new uint8_t[w * h * 4];
// // blit the frame buffer into the copy
// blit(&copy);
// // get pixels of the copy into buffer
// glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); // set buffer target readpixel
// copy.readPixels(buffer);
// // save to file
// stbi_write_png(filename.c_str(), w, h, 4, buffer, w * 4);
// // delete (copy is also deleted)
// delete[] buffer;
//}