From bec588eaf45ea12a9f5c73dae752195d9d221622 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 28 Aug 2018 23:36:13 +0200 Subject: [PATCH] - moved the two remaining functions from gl_wipe.cpp to gl_framebuffer.cpp and deleted the file. The single most hideous thing in the GL renderer is finally gone. :) --- src/CMakeLists.txt | 1 - src/gl/system/gl_framebuffer.cpp | 68 ++++++++++++++++++++ src/gl/system/gl_wipe.cpp | 104 ------------------------------- 3 files changed, 68 insertions(+), 105 deletions(-) delete mode 100644 src/gl/system/gl_wipe.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c880459d2..110c20fc38 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1061,7 +1061,6 @@ set (PCH_SOURCES gl_load/gl_interface.cpp gl/system/gl_framebuffer.cpp gl/system/gl_debug.cpp - gl/system/gl_wipe.cpp gl/textures/gl_hwtexture.cpp gl/textures/gl_samplers.cpp hwrenderer/data/flatvertices.cpp diff --git a/src/gl/system/gl_framebuffer.cpp b/src/gl/system/gl_framebuffer.cpp index 2af278c5f9..729ecad1fa 100644 --- a/src/gl/system/gl_framebuffer.cpp +++ b/src/gl/system/gl_framebuffer.cpp @@ -483,3 +483,71 @@ void OpenGLFrameBuffer::PostProcessScene(int fixedcm, const std::functionPostProcessScene(fixedcm, afterBloomDrawEndScene2D); } + +//========================================================================== +// +// This is just a wrapper around the hardware texture being extracted below so that it can be passed to the 2D code. +// +//========================================================================== + +class FGLWipeTexture : public FTexture +{ +public: + + FGLWipeTexture(int w, int h) + { + Width = w; + Height = h; + WidthBits = 4; + UseType = ETextureType::SWCanvas; + bNoCompress = true; + SystemTexture[0] = screen->CreateHardwareTexture(this); + } + +}; + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeStartScreen +// +// Called before the current screen has started rendering. This needs to +// save what was drawn the previous frame so that it can be animated into +// what gets drawn this frame. +// +//========================================================================== + +FTexture *OpenGLFrameBuffer::WipeStartScreen() +{ + const auto &viewport = screen->mScreenViewport; + + FGLWipeTexture *tex = new FGLWipeTexture(viewport.width, viewport.height); + tex->SystemTexture[0]->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen"); + glFinish(); + static_cast(tex->SystemTexture[0])->Bind(0, false, false); + + GLRenderer->mBuffers->BindCurrentFB(); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); + return tex; +} + +//========================================================================== +// +// OpenGLFrameBuffer :: WipeEndScreen +// +// The screen we want to animate to has just been drawn. +// +//========================================================================== + +FTexture *OpenGLFrameBuffer::WipeEndScreen() +{ + GLRenderer->Flush(); + const auto &viewport = screen->mScreenViewport; + FGLWipeTexture *tex = new FGLWipeTexture(viewport.width, viewport.height); + tex->SystemTexture[0]->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen"); + glFinish(); + static_cast(tex->SystemTexture[0])->Bind(0, false, false); + GLRenderer->mBuffers->BindCurrentFB(); + glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); + return tex; +} + diff --git a/src/gl/system/gl_wipe.cpp b/src/gl/system/gl_wipe.cpp deleted file mode 100644 index bf1c6b45af..0000000000 --- a/src/gl/system/gl_wipe.cpp +++ /dev/null @@ -1,104 +0,0 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2008-2016 Christoph Oelckers -// All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Lesser General Public License as published by -// the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Lesser General Public License for more details. -// -// You should have received a copy of the GNU Lesser General Public License -// along with this program. If not, see http://www.gnu.org/licenses/ -// -//-------------------------------------------------------------------------- -// -/* -** Screen wipe stuff -** -*/ - -#include "gl_load/gl_system.h" -#include "f_wipe.h" -#include "m_random.h" -#include "w_wad.h" -#include "v_palette.h" -#include "templates.h" - -#include "gl_load/gl_interface.h" -#include "gl/renderer/gl_renderer.h" -#include "gl/renderer/gl_renderstate.h" -#include "gl/renderer/gl_renderbuffers.h" -#include "gl/system/gl_framebuffer.h" -#include "gl/textures/gl_samplers.h" -#include "gl/data/gl_vertexbuffer.h" - - -class FGLWipeTexture : public FTexture -{ -public: - - FGLWipeTexture(int w, int h) - { - Width = w; - Height = h; - WidthBits = 4; - UseType = ETextureType::SWCanvas; - bNoCompress = true; - SystemTexture[0] = screen->CreateHardwareTexture(this); - } - - // This is just a wrapper around the hardware texture being extracted below so that it can be passed to the 2D code. -}; - -//========================================================================== -// -// OpenGLFrameBuffer :: WipeStartScreen -// -// Called before the current screen has started rendering. This needs to -// save what was drawn the previous frame so that it can be animated into -// what gets drawn this frame. -// -//========================================================================== - -FTexture *OpenGLFrameBuffer::WipeStartScreen() -{ - const auto &viewport = screen->mScreenViewport; - - FGLWipeTexture *tex = new FGLWipeTexture(viewport.width, viewport.height); - tex->SystemTexture[0]->CreateTexture(nullptr, viewport.width, viewport.height, 0, false, 0, "WipeStartScreen"); - glFinish(); - static_cast(tex->SystemTexture[0])->Bind(0, false, false); - - GLRenderer->mBuffers->BindCurrentFB(); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); - return tex; -} - -//========================================================================== -// -// OpenGLFrameBuffer :: WipeEndScreen -// -// The screen we want to animate to has just been drawn. -// -//========================================================================== - -FTexture *OpenGLFrameBuffer::WipeEndScreen() -{ - GLRenderer->Flush(); - const auto &viewport = screen->mScreenViewport; - FGLWipeTexture *tex = new FGLWipeTexture(viewport.width, viewport.height); - tex->SystemTexture[0]->CreateTexture(NULL, viewport.width, viewport.height, 0, false, 0, "WipeEndScreen"); - glFinish(); - static_cast(tex->SystemTexture[0])->Bind(0, false, false); - GLRenderer->mBuffers->BindCurrentFB(); - glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, viewport.left, viewport.top, viewport.width, viewport.height); - return tex; -} -