Hyprland/src/render/Framebuffer.hpp
Tom Englund f7fcbe32c9
renderer: various fixes towards improving gpu calls robustness (#9188)
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.
2025-02-08 01:46:26 +01:00

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;
};