summaryrefslogtreecommitdiff
path: root/src/mbgl/util/offscreen_texture.hpp
blob: 8928bc2434d39cc5a16cd977fc8de903923e21b2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#pragma once

#include <mbgl/map/view.hpp>
#include <mbgl/gl/framebuffer.hpp>
#include <mbgl/gl/texture.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/util/image.hpp>

namespace mbgl {

namespace gl {
class Context;
} // namespace gl

class OffscreenTexture : public View {
public:
    OffscreenTexture(gl::Context&, std::array<uint16_t, 2> size = {{ 256, 256 }});

    void bind() override;

    PremultipliedImage readStillImage();

    gl::Texture& getTexture();

private:
    gl::Context& context;
    std::array<uint16_t, 2> size;
    optional<gl::Framebuffer> framebuffer;
    optional<gl::Texture> texture;
};

} // namespace mbgl