MCPcopy Create free account
hub / github.com/VCVRack/Rack / screenshot

Method screenshot

src/window/Window.cpp:555–572  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

553
554
555void 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
575void Window::screenshotModules(const std::string& screenshotsDir, float zoom) {

Callers

nothing calls this directly

Calls 1

flipBitmapFunction · 0.85

Tested by

no test coverage detected