From 6ae99f64ffcc8f71bf6ab06bf98a5904b5469736 Mon Sep 17 00:00:00 2001 From: korenkonder Date: Fri, 14 Jun 2024 20:30:58 +0300 Subject: [PATCH] `RenderTexture`: commented out unused code --- src/CRE/render_texture.cpp | 54 ++++++++++++++++++++++++++------------ src/CRE/render_texture.hpp | 6 +++-- 2 files changed, 41 insertions(+), 19 deletions(-) diff --git a/src/CRE/render_texture.cpp b/src/CRE/render_texture.cpp index 031813b9..59fe16e3 100644 --- a/src/CRE/render_texture.cpp +++ b/src/CRE/render_texture.cpp @@ -16,8 +16,8 @@ static int32_t render_texture_init_framebuffer(RenderTexture* rt, int32_t max_le static int32_t render_texture_set_framebuffer_texture(RenderTexture* rrt, GLuint color_texture, int32_t level, GLuint depth_texture, bool stencil); -RenderTexture::RenderTexture() : color_texture(), -depth_texture(), binding(), max_level(), fbos(), rbo(), field_2C() { +RenderTexture::RenderTexture() : color_texture(), depth_texture(), +binding(), max_level(), fbos(), depth_rbo(), stencil_rbo() { } @@ -48,15 +48,15 @@ void RenderTexture::Free() { color_texture = 0; } - if (rbo) { - glDeleteRenderbuffers(1, &rbo); - rbo = 0; + /*if (depth_rbo) { + glDeleteRenderbuffers(1, &depth_rbo); + depth_rbo = 0; } - if (field_2C) { - glDeleteRenderbuffers(1, &field_2C); - field_2C = 0; - } + if (stencil_rbo) { + glDeleteRenderbuffers(1, &stencil_rbo); + stencil_rbo = 0; + }*/ if (fbos) { glDeleteFramebuffers(max_level + 1, fbos); @@ -123,6 +123,26 @@ int32_t RenderTexture::Init(int32_t width, int32_t height, return 0; } +/*int32_t RenderTexture::InitDepthRenderbuffer(GLenum internal_format, int32_t width, int32_t height) { + gl_state_bind_framebuffer(fbos[0]); + glGenRenderbuffers(1, &depth_rbo); + glBindRenderbuffer(GL_RENDERBUFFER, depth_rbo); + glRenderbufferStorage(GL_RENDERBUFFER, internal_format, width, height); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, depth_rbo); + gl_state_bind_framebuffer(0); + return -(glGetError() != GL_ZERO); +} + +int32_t RenderTexture::InitStencilRenderbuffer(GLenum internal_format, int32_t width, int32_t height) { + gl_state_bind_framebuffer(fbos[0]); + glGenRenderbuffers(1, &stencil_rbo); + glBindRenderbuffer(GL_RENDERBUFFER, stencil_rbo); + glRenderbufferStorage(GL_RENDERBUFFER, internal_format, width, height); + glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, stencil_rbo); + gl_state_bind_framebuffer(0); + return -(glGetError() != GL_ZERO); +}*/ + int32_t RenderTexture::SetColorDepthTextures(GLuint color_texture, int32_t max_level, GLuint depth_texture, bool stencil) { int32_t error = 0; @@ -170,11 +190,11 @@ static int32_t render_texture_set_framebuffer_texture(RenderTexture* rt, if (depth_texture) glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, depth_texture, 0); - else if (rt->rbo) { - glBindRenderbuffer(GL_RENDERBUFFER, rt->rbo); + /*else if (rt->depth_rbo) { + glBindRenderbuffer(GL_RENDERBUFFER, rt->depth_rbo); glFramebufferRenderbuffer(GL_FRAMEBUFFER, - GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rt->rbo); - } + GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, rt->depth_rbo); + }*/ else glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, 0, 0); @@ -183,11 +203,11 @@ static int32_t render_texture_set_framebuffer_texture(RenderTexture* rt, if (depth_texture) glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, depth_texture, 0); - else if (rt->rbo) { - glBindRenderbuffer(GL_RENDERBUFFER, rt->rbo); + /*else if (rt->depth_rbo) { + glBindRenderbuffer(GL_RENDERBUFFER, rt->depth_rbo); glFramebufferRenderbuffer(GL_FRAMEBUFFER, - GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->rbo); - } + GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, rt->depth_rbo); + }*/ else glFramebufferTexture(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, 0, 0); diff --git a/src/CRE/render_texture.hpp b/src/CRE/render_texture.hpp index 4df798ad..96581c83 100644 --- a/src/CRE/render_texture.hpp +++ b/src/CRE/render_texture.hpp @@ -14,8 +14,8 @@ struct RenderTexture { int32_t binding; int32_t max_level; GLuint* fbos; - GLuint rbo; - GLuint field_2C; + GLuint depth_rbo; + GLuint stencil_rbo; RenderTexture(); virtual ~RenderTexture(); @@ -24,6 +24,8 @@ struct RenderTexture { void Free(); int32_t Init(int32_t width, int32_t height, int32_t max_level, GLenum color_format, GLenum depth_format); + /*int32_t InitDepthRenderbuffer(GLenum internal_format, int32_t width, int32_t height); + int32_t InitStencilRenderbuffer(GLenum internal_format, int32_t width, int32_t height);*/ int32_t SetColorDepthTextures(GLuint color_texture, int32_t max_level = 0, GLuint depth_texture = 0, bool stencil = false);