From f33ddd8ccebc532e84e77056b5c7fadcaa70d3e3 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 12 Jun 2018 14:44:58 +0200 Subject: [PATCH] Made the ScopedViewShifter fully inline --- src/CMakeLists.txt | 1 - src/gl/scene/gl_scene.cpp | 2 +- src/gl/stereo3d/scoped_view_shifter.cpp | 48 ------------------------- src/gl/stereo3d/scoped_view_shifter.h | 38 ++++++++++++-------- src/hwrenderer/data/renderqueue.h | 33 +++++++++++++++++ 5 files changed, 58 insertions(+), 64 deletions(-) delete mode 100644 src/gl/stereo3d/scoped_view_shifter.cpp create mode 100644 src/hwrenderer/data/renderqueue.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2dd4bbaef..ca228c247 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1040,7 +1040,6 @@ set (PCH_SOURCES gl/stereo3d/gl_stereo3d.cpp gl/stereo3d/gl_stereo_cvars.cpp gl/stereo3d/gl_stereo_leftright.cpp - gl/stereo3d/scoped_view_shifter.cpp gl/stereo3d/gl_anaglyph.cpp gl/stereo3d/gl_quadstereo.cpp gl/stereo3d/gl_sidebyside3d.cpp diff --git a/src/gl/scene/gl_scene.cpp b/src/gl/scene/gl_scene.cpp index d4aea2768..1461fd94d 100644 --- a/src/gl/scene/gl_scene.cpp +++ b/src/gl/scene/gl_scene.cpp @@ -670,7 +670,7 @@ sector_t * GLSceneDrawer::RenderViewpoint (AActor * camera, IntRect * bounds, fl SetViewAngle(r_viewpoint.Angles.Yaw); // Stereo mode specific viewpoint adjustment - temporarily shifts global ViewPos eye->GetViewShift(GLRenderer->mAngles.Yaw.Degrees, viewShift); - s3d::ScopedViewShifter viewShifter(viewShift); + ScopedViewShifter viewShifter(r_viewpoint.Pos, viewShift); SetViewMatrix(r_viewpoint.Pos.X, r_viewpoint.Pos.Y, r_viewpoint.Pos.Z, false, false); gl_RenderState.ApplyMatrices(); diff --git a/src/gl/stereo3d/scoped_view_shifter.cpp b/src/gl/stereo3d/scoped_view_shifter.cpp deleted file mode 100644 index ac2b89a27..000000000 --- a/src/gl/stereo3d/scoped_view_shifter.cpp +++ /dev/null @@ -1,48 +0,0 @@ -// -//--------------------------------------------------------------------------- -// -// Copyright(C) 2015 Christopher Bruns -// 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/ -// -//-------------------------------------------------------------------------- -// -/* -** scoped_view_shifter.cpp -** Stack-scoped class for temporarily changing camera viewpoint -** Used for stereoscopic 3D. -** -*/ - -#include "scoped_view_shifter.h" -#include "r_utility.h" - -namespace s3d { - -ScopedViewShifter::ScopedViewShifter(float dxyz[3]) // in meters -{ - // save original values - cachedView = r_viewpoint.Pos; - // modify values - r_viewpoint.Pos += DVector3(dxyz[0], dxyz[1], dxyz[2]); -} - -ScopedViewShifter::~ScopedViewShifter() -{ - // restore original values - r_viewpoint.Pos = cachedView; -} - -} \ No newline at end of file diff --git a/src/gl/stereo3d/scoped_view_shifter.h b/src/gl/stereo3d/scoped_view_shifter.h index bac7f2dac..9e80a28ad 100644 --- a/src/gl/stereo3d/scoped_view_shifter.h +++ b/src/gl/stereo3d/scoped_view_shifter.h @@ -32,21 +32,31 @@ #include "basictypes.h" #include "vectors.h" -namespace s3d { +/** + * Temporarily shift + */ +class ScopedViewShifter +{ +public: + ScopedViewShifter(DVector3 &var, float dxyz[3]) // in meters + { + // save original values + mVar = &var; + cachedView = var; + // modify values + var += DVector3(dxyz[0], dxyz[1], dxyz[2]); + } + + ~ScopedViewShifter() + { + // restore original values + *mVar = cachedView; + } - /** - * Temporarily shift - */ - class ScopedViewShifter - { - public: - ScopedViewShifter(float dxyz[3]); // in meters - ~ScopedViewShifter(); +private: + DVector3 *mVar; + DVector3 cachedView; +}; - private: - DVector3 cachedView; - }; - -} /* namespace s3d */ #endif // GL_STEREO3D_SCOPED_VIEW_SHIFTER_H_ diff --git a/src/hwrenderer/data/renderqueue.h b/src/hwrenderer/data/renderqueue.h new file mode 100644 index 000000000..69e67b990 --- /dev/null +++ b/src/hwrenderer/data/renderqueue.h @@ -0,0 +1,33 @@ +#pragma once + +#include +#include "tflags.h" + +// A render queue is what contains all render commands. +// On Vulkan there can be several of them so this interface is needed to allow for the needed parallelism. +// On OpenGL the render state is global so all this will do is to translate the system independent calls into OpenGL API calls. + +enum class ColormaskBits +{ + RED = 1, + GREEN = 2, + BLUE = 4, + ALPHA = 8 +}; + +typedef TFlags Colormask; + +class IRenderQueue +{ + Colormask mColorMask; + + + Colormask GetColorMask() const + { + return mColorMask; + } + + void SetColorMask(Colormask mask) = 0; + + +};