summaryrefslogtreecommitdiff
path: root/src/render/gl/GLFramebuffer.hpp
blob: c171444e936038718a4ab888610cfdd19e4408ee (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
#pragma once

#include "../../defines.hpp"
#include "../Texture.hpp"
#include "../Framebuffer.hpp"
#include <drm_fourcc.h>

class CGLFramebuffer : public IFramebuffer {
  public:
    CGLFramebuffer();
    CGLFramebuffer(const std::string& name);
    ~CGLFramebuffer();

    void   addStencil(SP<ITexture> tex) override;
    void   release() override;
    bool   readPixels(CHLBufferReference buffer, uint32_t offsetX = 0, uint32_t offsetY = 0, uint32_t width = 0, uint32_t height = 0) override;

    void   bind() override;
    void   unbind();
    GLuint getFBID();
    void   invalidate(const std::vector<GLenum>& attachments);

  protected:
    bool internalAlloc(int w, int h, uint32_t format = DRM_FORMAT_ARGB8888) override;

  private:
    GLuint m_fb = -1;

    friend class CGLRenderbuffer;
};