From 6059753e7378851d91d7e69a0b710d01a57fd2a2 Mon Sep 17 00:00:00 2001 From: Alug Date: Tue, 20 Aug 2024 23:26:11 +0200 Subject: [PATCH] cleanup FBO on shutdown + make some stuff static --- src/hardware/hw_main.c | 3 ++ src/hardware/r_opengl/r_opengl.c | 52 ++++++++++++++++---------------- src/hardware/r_opengl/r_opengl.h | 3 -- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/hardware/hw_main.c b/src/hardware/hw_main.c index 545f7f31c..87d2089c7 100644 --- a/src/hardware/hw_main.c +++ b/src/hardware/hw_main.c @@ -27,6 +27,8 @@ #include "hw_md2.h" #include "hw_clip.h" +#include "r_opengl/r_opengl.h" + #include "../i_video.h" // for rendermode == render_glide #include "../v_video.h" #include "../p_local.h" @@ -5850,6 +5852,7 @@ void HWR_Shutdown(void) HWR_FreeMipmapCache(); HWR_FreeTextureCache(); HWD.pfnFlushScreenTextures(); + GLFramebuffer_Disable(); } void HWR_RenderWall(FOutVector *wallVerts, FSurfaceInfo *pSurf, FBITFIELD blend, boolean fogwall, INT32 lightlevel, extracolormap_t *wallcolormap) diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index 048536cea..8c85773d7 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1009,32 +1009,7 @@ void SetStates(void) } #ifdef USE_FBO_OGL -void GLFramebuffer_Generate(void) -{ - if (!supportFBO) - return; - - // Generate the framebuffer - if (FramebufferObject == 0) - pglGenFramebuffers(1, &FramebufferObject); - - if (pglCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) - GLFramebuffer_GenerateAttachments(); -} - -static void GLFramebuffer_Delete(void) -{ - if (!supportFBO) - return; - - if (FramebufferObject) - pglDeleteFramebuffers(1, &FramebufferObject); - - GLFramebuffer_DeleteAttachments(); - FramebufferObject = 0; -} - -void GLFramebuffer_GenerateAttachments(void) +static void GLFramebuffer_GenerateAttachments(void) { if (!supportFBO) return; @@ -1094,6 +1069,31 @@ void GLFramebuffer_DeleteAttachments(void) RenderbufferObject = 0; } +static void GLFramebuffer_Generate(void) +{ + if (!supportFBO) + return; + + // Generate the framebuffer + if (FramebufferObject == 0) + pglGenFramebuffers(1, &FramebufferObject); + + if (pglCheckFramebufferStatus(GL_FRAMEBUFFER) == GL_FRAMEBUFFER_COMPLETE) + GLFramebuffer_GenerateAttachments(); +} + +static void GLFramebuffer_Delete(void) +{ + if (!supportFBO) + return; + + if (FramebufferObject) + pglDeleteFramebuffers(1, &FramebufferObject); + + GLFramebuffer_DeleteAttachments(); + FramebufferObject = 0; +} + inline void GLFramebuffer_Unbind(void) { if (!supportFBO) diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index f916c950d..baab44637 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -105,9 +105,6 @@ static PFNglEnableClientState pglEnableClientState; #endif #ifdef USE_FBO_OGL -void GLFramebuffer_Generate(void); - -void GLFramebuffer_GenerateAttachments(void); void GLFramebuffer_DeleteAttachments(void); void GLFramebuffer_Unbind(void);