mirror of
https://github.com/hyprwm/Hyprland.git
synced 2025-10-16 06:55:58 +00:00
render: refactor class member vars (#10292)
* render: refactor class member vars * render: fix clang format
This commit is contained in:
@@ -12,10 +12,10 @@ bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) {
|
||||
uint32_t glFormat = NFormatUtils::drmFormatToGL(drmFormat);
|
||||
uint32_t glType = NFormatUtils::glFormatToType(glFormat);
|
||||
|
||||
if (!m_cTex) {
|
||||
m_cTex = makeShared<CTexture>();
|
||||
m_cTex->allocate();
|
||||
glBindTexture(GL_TEXTURE_2D, m_cTex->m_iTexID);
|
||||
if (!m_tex) {
|
||||
m_tex = makeShared<CTexture>();
|
||||
m_tex->allocate();
|
||||
glBindTexture(GL_TEXTURE_2D, m_tex->m_texID);
|
||||
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);
|
||||
@@ -23,24 +23,24 @@ bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) {
|
||||
firstAlloc = true;
|
||||
}
|
||||
|
||||
if (!m_iFbAllocated) {
|
||||
glGenFramebuffers(1, &m_iFb);
|
||||
m_iFbAllocated = true;
|
||||
firstAlloc = true;
|
||||
if (!m_fbAllocated) {
|
||||
glGenFramebuffers(1, &m_fb);
|
||||
m_fbAllocated = true;
|
||||
firstAlloc = true;
|
||||
}
|
||||
|
||||
if (firstAlloc || m_vSize != Vector2D(w, h)) {
|
||||
glBindTexture(GL_TEXTURE_2D, m_cTex->m_iTexID);
|
||||
if (firstAlloc || m_size != Vector2D(w, h)) {
|
||||
glBindTexture(GL_TEXTURE_2D, m_tex->m_texID);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, glFormat, w, h, 0, GL_RGBA, glType, nullptr);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_cTex->m_iTexID, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fb);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, m_tex->m_texID, 0);
|
||||
|
||||
// TODO: Allow this with gles2
|
||||
#ifndef GLES2
|
||||
if (m_pStencilTex) {
|
||||
glBindTexture(GL_TEXTURE_2D, m_pStencilTex->m_iTexID);
|
||||
if (m_stencilTex) {
|
||||
glBindTexture(GL_TEXTURE_2D, m_stencilTex->m_texID);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, w, h, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_pStencilTex->m_iTexID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_stencilTex->m_texID, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -53,7 +53,7 @@ bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) {
|
||||
glBindTexture(GL_TEXTURE_2D, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
m_vSize = Vector2D(w, h);
|
||||
m_size = Vector2D(w, h);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -61,13 +61,13 @@ bool CFramebuffer::alloc(int w, int h, uint32_t drmFormat) {
|
||||
void CFramebuffer::addStencil(SP<CTexture> tex) {
|
||||
// TODO: Allow this with gles2
|
||||
#ifndef GLES2
|
||||
m_pStencilTex = tex;
|
||||
glBindTexture(GL_TEXTURE_2D, m_pStencilTex->m_iTexID);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_vSize.x, m_vSize.y, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
|
||||
m_stencilTex = tex;
|
||||
glBindTexture(GL_TEXTURE_2D, m_stencilTex->m_texID);
|
||||
glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH24_STENCIL8, m_size.x, m_size.y, 0, GL_DEPTH_STENCIL, GL_UNSIGNED_INT_24_8, nullptr);
|
||||
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fb);
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_pStencilTex->m_iTexID, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, m_stencilTex->m_texID, 0);
|
||||
|
||||
auto status = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
RASSERT((status == GL_FRAMEBUFFER_COMPLETE), "Failed adding a stencil to fbo!", status);
|
||||
@@ -79,15 +79,15 @@ void CFramebuffer::addStencil(SP<CTexture> tex) {
|
||||
|
||||
void CFramebuffer::bind() {
|
||||
#ifndef GLES2
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_iFb);
|
||||
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, m_fb);
|
||||
#else
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
|
||||
#endif
|
||||
|
||||
if (g_pHyprOpenGL)
|
||||
glViewport(0, 0, g_pHyprOpenGL->m_RenderData.pMonitor->m_pixelSize.x, g_pHyprOpenGL->m_RenderData.pMonitor->m_pixelSize.y);
|
||||
glViewport(0, 0, g_pHyprOpenGL->m_renderData.pMonitor->m_pixelSize.x, g_pHyprOpenGL->m_renderData.pMonitor->m_pixelSize.y);
|
||||
else
|
||||
glViewport(0, 0, m_vSize.x, m_vSize.y);
|
||||
glViewport(0, 0, m_size.x, m_size.y);
|
||||
}
|
||||
|
||||
void CFramebuffer::unbind() {
|
||||
@@ -99,20 +99,20 @@ void CFramebuffer::unbind() {
|
||||
}
|
||||
|
||||
void CFramebuffer::release() {
|
||||
if (m_iFbAllocated) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_iFb);
|
||||
if (m_fbAllocated) {
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, m_fb);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, 0, 0);
|
||||
glBindFramebuffer(GL_FRAMEBUFFER, 0);
|
||||
|
||||
glDeleteFramebuffers(1, &m_iFb);
|
||||
m_iFbAllocated = false;
|
||||
m_iFb = 0;
|
||||
glDeleteFramebuffers(1, &m_fb);
|
||||
m_fbAllocated = false;
|
||||
m_fb = 0;
|
||||
}
|
||||
|
||||
if (m_cTex)
|
||||
m_cTex.reset();
|
||||
if (m_tex)
|
||||
m_tex.reset();
|
||||
|
||||
m_vSize = Vector2D();
|
||||
m_size = Vector2D();
|
||||
}
|
||||
|
||||
CFramebuffer::~CFramebuffer() {
|
||||
@@ -120,17 +120,17 @@ CFramebuffer::~CFramebuffer() {
|
||||
}
|
||||
|
||||
bool CFramebuffer::isAllocated() {
|
||||
return m_iFbAllocated && m_cTex;
|
||||
return m_fbAllocated && m_tex;
|
||||
}
|
||||
|
||||
SP<CTexture> CFramebuffer::getTexture() {
|
||||
return m_cTex;
|
||||
return m_tex;
|
||||
}
|
||||
|
||||
GLuint CFramebuffer::getFBID() {
|
||||
return m_iFbAllocated ? m_iFb : 0;
|
||||
return m_fbAllocated ? m_fb : 0;
|
||||
}
|
||||
|
||||
SP<CTexture> CFramebuffer::getStencilTex() {
|
||||
return m_pStencilTex;
|
||||
return m_stencilTex;
|
||||
}
|
||||
|
Reference in New Issue
Block a user