diff --git a/src/hardware/r_opengl/r_opengl.c b/src/hardware/r_opengl/r_opengl.c index a4d5141bb..048536cea 100644 --- a/src/hardware/r_opengl/r_opengl.c +++ b/src/hardware/r_opengl/r_opengl.c @@ -1022,14 +1022,11 @@ void GLFramebuffer_Generate(void) GLFramebuffer_GenerateAttachments(); } -void GLFramebuffer_Delete(void) +static void GLFramebuffer_Delete(void) { if (!supportFBO) return; - // Unbind the framebuffer - pglBindFramebuffer(GL_FRAMEBUFFER, 0); - if (FramebufferObject) pglDeleteFramebuffers(1, &FramebufferObject); @@ -1085,6 +1082,7 @@ void GLFramebuffer_DeleteAttachments(void) // Unbind the framebuffer pglBindFramebuffer(GL_FRAMEBUFFER, 0); + pglBindRenderbuffer(GL_RENDERBUFFER, 0); if (FramebufferTexture) pglDeleteTextures(1, &FramebufferTexture); @@ -1096,6 +1094,15 @@ void GLFramebuffer_DeleteAttachments(void) RenderbufferObject = 0; } +inline void GLFramebuffer_Unbind(void) +{ + if (!supportFBO) + return; + + pglBindFramebuffer(GL_FRAMEBUFFER, 0); + pglBindRenderbuffer(GL_RENDERBUFFER, 0); +} + inline void GLFramebuffer_Enable(void) { if (!supportFBO) @@ -1110,13 +1117,15 @@ inline void GLFramebuffer_Enable(void) pglBindRenderbuffer(GL_RENDERBUFFER, RenderbufferObject); } -inline void GLFramebuffer_Disable(void) +void GLFramebuffer_Disable(void) { if (!supportFBO) return; pglBindFramebuffer(GL_FRAMEBUFFER, 0); pglBindRenderbuffer(GL_RENDERBUFFER, 0); + + GLFramebuffer_Delete(); } #endif // -----------------+ diff --git a/src/hardware/r_opengl/r_opengl.h b/src/hardware/r_opengl/r_opengl.h index 255969d5a..f916c950d 100644 --- a/src/hardware/r_opengl/r_opengl.h +++ b/src/hardware/r_opengl/r_opengl.h @@ -106,11 +106,11 @@ static PFNglEnableClientState pglEnableClientState; #ifdef USE_FBO_OGL void GLFramebuffer_Generate(void); -void GLFramebuffer_Delete(void); void GLFramebuffer_GenerateAttachments(void); void GLFramebuffer_DeleteAttachments(void); +void GLFramebuffer_Unbind(void); void GLFramebuffer_Enable(void); void GLFramebuffer_Disable(void); diff --git a/src/sdl/i_video.c b/src/sdl/i_video.c index 0fd9de075..857e52b82 100644 --- a/src/sdl/i_video.c +++ b/src/sdl/i_video.c @@ -773,6 +773,7 @@ void I_DownSample(void) if (SDL_GetCurrentDisplayMode(currentDisplayIndex, &curmode) != 0) { downsample = false; // couldnt get display info so turn the thing off + RefreshOGLSDLSurface(); return; } @@ -782,7 +783,10 @@ void I_DownSample(void) RefreshOGLSDLSurface(); } else + { downsample = false; // its not so no need to do crap + RefreshOGLSDLSurface(); + } } #if defined (__unix__) diff --git a/src/sdl/ogl_sdl.c b/src/sdl/ogl_sdl.c index aab3c4873..2ea822e63 100644 --- a/src/sdl/ogl_sdl.c +++ b/src/sdl/ogl_sdl.c @@ -196,6 +196,7 @@ boolean OglSdlSurface(INT32 w, INT32 h) if (screen_width != w || screen_height != h) { FlushScreenTextures(); + #ifdef USE_FBO_OGL GLFramebuffer_DeleteAttachments(); #endif @@ -209,15 +210,16 @@ boolean OglSdlSurface(INT32 w, INT32 h) pglClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); #ifdef USE_FBO_OGL - RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); - GLFramebuffer_Disable(); - - if (RenderToFramebuffer + RenderToFramebuffer = ((FrameBufferEnabled && supportFBO && downsample) #if defined (__unix__) - || (isnvidiagpu && xwaylandcrap) + || (isnvidiagpu && xwaylandcrap) #endif - ) + ); + + if (RenderToFramebuffer) GLFramebuffer_Enable(); + else + GLFramebuffer_Disable(); #endif HWR_Startup(); @@ -255,18 +257,20 @@ void OglSdlFinishUpdate(boolean waitvbl) HWR_MakeScreenFinalTexture(); #ifdef USE_FBO_OGL - GLFramebuffer_Disable(); - RenderToFramebuffer = (FrameBufferEnabled && supportFBO && downsample); + RenderToFramebuffer = ((FrameBufferEnabled && supportFBO && downsample) +#if defined (__unix__) + || (isnvidiagpu && xwaylandcrap) +#endif + ); + + if (RenderToFramebuffer) + GLFramebuffer_Unbind(); #endif HWR_DrawScreenFinalTexture(sdlw, sdlh); #ifdef USE_FBO_OGL - if ((RenderToFramebuffer && downsample) -#if defined (__unix__) - || (isnvidiagpu && xwaylandcrap) -#endif - ) + if (RenderToFramebuffer) GLFramebuffer_Enable(); #endif