MCPcopy Create free account
hub / github.com/ddiakopoulos/polymer / screenshot_impl

Method screenshot_impl

libraries/lib-app-base/src/glfw-app.cpp:214–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

212}
213
214void polymer_app::screenshot_impl()
215{
216 int width, height;
217 glfwGetWindowSize(window, &width, &height);
218 int2 size(width, height);
219 auto timestamp = make_timestamp();
220 std::vector<uint8_t> screenShot(size.x * size.y * 4);
221 glReadPixels(0, 0, size.x, size.y, GL_RGBA, GL_UNSIGNED_BYTE, screenShot.data());
222 auto flipped = screenShot;
223 for (int y = 0; y < size.y; ++y) memcpy(flipped.data() + y * size.x * 4, screenShot.data() + (size.y - y - 1)*size.x * 4, size.x * 4);
224 stbi_write_png(std::string(screenshotPath + "-" + timestamp + ".png").c_str(), size.x, size.y, 4, flipped.data(), 4 * size.x);
225 screenshotPath.clear();
226}
227
228void polymer_app::main_loop()
229{

Callers

nothing calls this directly

Calls 3

make_timestampFunction · 0.85
dataMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected