diff options
| author | Vaxry <43317083+vaxerski@users.noreply.github.com> | 2024-06-08 10:07:59 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-08 10:07:59 +0200 |
| commit | 6967a31450441fc5605c05db6f65505dace4b263 (patch) | |
| tree | 255a3cff7f3e2eb8a50c952eab9b270a7937561d /src/render/Framebuffer.cpp | |
| parent | c31d9ef4172452f6f219f91d9b87a24d91f0cf3a (diff) | |
wayland/core: move to new impl (#6268)
* wayland/core/dmabuf: move to new impl
it's the final countdown
Diffstat (limited to 'src/render/Framebuffer.cpp')
| -rw-r--r-- | src/render/Framebuffer.cpp | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/src/render/Framebuffer.cpp b/src/render/Framebuffer.cpp index 83325dd7..67629e23 100644 --- a/src/render/Framebuffer.cpp +++ b/src/render/Framebuffer.cpp @@ -1,22 +1,26 @@ #include "Framebuffer.hpp" #include "OpenGL.hpp" +CFramebuffer::CFramebuffer() { + m_cTex = makeShared<CTexture>(); +} + bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) { bool firstAlloc = false; RASSERT((w > 1 && h > 1), "cannot alloc a FB with negative / zero size! (attempted {}x{})", w, h); - uint32_t glFormat = drmFormatToGL(drmFormat); - uint32_t glType = glFormatToType(glFormat); + uint32_t glFormat = FormatUtils::drmFormatToGL(drmFormat); + uint32_t glType = FormatUtils::glFormatToType(glFormat); if (m_iFb == (uint32_t)-1) { firstAlloc = true; glGenFramebuffers(1, &m_iFb); } - if (m_cTex.m_iTexID == 0) { + if (m_cTex->m_iTexID == 0) { firstAlloc = true; - glGenTextures(1, &m_cTex.m_iTexID); - glBindTexture(GL_TEXTURE_2D, m_cTex.m_iTexID); + m_cTex->allocate(); + glBindTexture(GL_TEXTURE_2D, m_cTex->m_iTexID); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); @@ -24,11 +28,11 @@ bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) { } if (firstAlloc || m_vSize != Vector2D(w, h)) { - glBindTexture(GL_TEXTURE_2D, m_cTex.m_iTexID); + glBindTexture(GL_TEXTURE_2D, m_cTex->m_iTexID); glTexImage2D(GL_TEXTURE_2D, 0, glFormat, w, h, 0, GL_RGBA, glType, 0); glBindFramebuffer(GL_FRAMEBUFFER, m_iFb); - glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex.m_iTexID, 0); + glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex->m_iTexID, 0); // TODO: Allow this with gles2 #ifndef GLES2 @@ -87,12 +91,9 @@ void CFramebuffer::release() { if (m_iFb != (uint32_t)-1 && m_iFb) glDeleteFramebuffers(1, &m_iFb); - if (m_cTex.m_iTexID) - glDeleteTextures(1, &m_cTex.m_iTexID); - - m_cTex.m_iTexID = 0; - m_iFb = -1; - m_vSize = Vector2D(); + m_cTex->destroyTexture(); + m_iFb = -1; + m_vSize = Vector2D(); } CFramebuffer::~CFramebuffer() { |
