| 553 | |
| 554 | |
| 555 | void Window::screenshot(const std::string& screenshotPath) { |
| 556 | // Get window framebuffer size |
| 557 | int width, height; |
| 558 | glfwGetFramebufferSize(APP->window->win, &width, &height); |
| 559 | |
| 560 | // Allocate pixel color buffer |
| 561 | uint8_t* pixels = new uint8_t[height * width * 4]; |
| 562 | |
| 563 | // glReadPixels defaults to GL_BACK, but the back-buffer is unstable, so use the front buffer (what the user sees) |
| 564 | glReadBuffer(GL_FRONT); |
| 565 | glReadPixels(0, 0, width, height, GL_RGBA, GL_UNSIGNED_BYTE, pixels); |
| 566 | |
| 567 | // Write pixels to PNG |
| 568 | flipBitmap(pixels, width, height, 4); |
| 569 | stbi_write_png(screenshotPath.c_str(), width, height, 4, pixels, width * 4); |
| 570 | |
| 571 | delete[] pixels; |
| 572 | } |
| 573 | |
| 574 | |
| 575 | void Window::screenshotModules(const std::string& screenshotsDir, float zoom) { |
nothing calls this directly
no test coverage detected