| 212 | } |
| 213 | |
| 214 | void 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 | |
| 228 | void polymer_app::main_loop() |
| 229 | { |
nothing calls this directly
no test coverage detected