mirror of
https://github.com/hyprwm/Hyprland
synced 2026-01-07 06:10:13 +01:00
ensure framebuffer textures are detached and deleted, avoid leaving framebuffers bound when not needed * render: avoid calling glDeleteProgram on no program its safe to do so but it adds a bunch of unnecessery lines in apitrace when tracing. if guard it and return early. * opengl: ensure texture and buffers are unbound ensure bound buffers are unbound after use, also detach textures from framebuffer before deleting it otherwise it will become dangling and essentially leak.
32 lines
692 B
C++
32 lines
692 B
C++
#pragma once
|
|
|
|
#include "../defines.hpp"
|
|
#include "Texture.hpp"
|
|
|
|
class CFramebuffer {
|
|
public:
|
|
CFramebuffer();
|
|
~CFramebuffer();
|
|
|
|
bool alloc(int w, int h, uint32_t format = GL_RGBA);
|
|
void addStencil(SP<CTexture> tex);
|
|
void bind();
|
|
void unbind();
|
|
void release();
|
|
void reset();
|
|
bool isAllocated();
|
|
SP<CTexture> getTexture();
|
|
SP<CTexture> getStencilTex();
|
|
GLuint getFBID();
|
|
|
|
Vector2D m_vSize;
|
|
|
|
private:
|
|
SP<CTexture> m_cTex;
|
|
GLuint m_iFb = -1;
|
|
bool m_iFbAllocated = false;
|
|
|
|
SP<CTexture> m_pStencilTex;
|
|
|
|
friend class CRenderbuffer;
|
|
};
|