MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / readBack

Method readBack

framework/render/gl20/ogl_2_0_renderer.cpp:557–575  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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 {

Callers

nothing calls this directly

Calls 1

getDataMethod · 0.45

Tested by

no test coverage detected