| 555 | } |
| 556 | |
| 557 | sp<Image> readBack() override |
| 558 | { |
| 559 | auto img = mksp<RGBImage>(size); |
| 560 | BindFramebuffer f(this->fbo); |
| 561 | |
| 562 | RGBImageLock l(img); |
| 563 | // Foiled once again by inverted y! Read in each line bottom->top writing top->bottom in the |
| 564 | // image |
| 565 | uint8_t *imgPos = reinterpret_cast<uint8_t *>(l.getData()); |
| 566 | unsigned imgStride = size.x * 4; |
| 567 | for (int y = 0; y < size.y; y++) |
| 568 | { |
| 569 | gl20::ReadPixels(0, size.y - 1 - y, size.x, size.y - y, gl20::RGBA, gl20::UNSIGNED_BYTE, |
| 570 | imgPos); |
| 571 | imgPos += imgStride; |
| 572 | } |
| 573 | |
| 574 | return img; |
| 575 | } |
| 576 | |
| 577 | FBOData(Vec2<int> size, OGL20Renderer *owner) : size(size.x, size.y), owner(owner) |
| 578 | { |