diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 73dba07c4e..e768e945ff 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1116,6 +1116,7 @@ set( FASTMATH_SOURCES gl/stereo3d/gl_anaglyph.cpp gl/stereo3d/gl_quadstereo.cpp gl/stereo3d/gl_sidebyside3d.cpp + gl/stereo3d/gl_interleaved3d.cpp gl/dynlights/gl_dynlight.cpp gl/dynlights/gl_glow.cpp gl/dynlights/gl_dynlight1.cpp diff --git a/src/gl/stereo3d/gl_interleaved3d.cpp b/src/gl/stereo3d/gl_interleaved3d.cpp new file mode 100644 index 0000000000..c811e0d216 --- /dev/null +++ b/src/gl/stereo3d/gl_interleaved3d.cpp @@ -0,0 +1,71 @@ +/* +** gl_interleaved3d.cpp +** Interleaved image stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#include "gl_interleaved3d.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" + +namespace s3d { + +/* static */ +const RowInterleaved3D& RowInterleaved3D::getInstance(float ipd) +{ + static RowInterleaved3D instance(ipd); + return instance; +} + +void RowInterleaved3D::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + // Compute screen regions to use for left and right eye views + int topHeight = GLRenderer->mOutputLetterbox.height / 2; + int bottomHeight = GLRenderer->mOutputLetterbox.height - topHeight; + GL_IRECT topHalfScreen = GLRenderer->mOutputLetterbox; + topHalfScreen.height = topHeight; + GL_IRECT bottomHalfScreen = GLRenderer->mOutputLetterbox; + bottomHalfScreen.height = bottomHeight; + bottomHalfScreen.top += topHeight; + + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(topHalfScreen, true); + + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(bottomHalfScreen, true); +} + + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_interleaved3d.h b/src/gl/stereo3d/gl_interleaved3d.h new file mode 100644 index 0000000000..1f22fa356f --- /dev/null +++ b/src/gl/stereo3d/gl_interleaved3d.h @@ -0,0 +1,58 @@ +/* +** gl_interleaved3d.h +** Interleaved stereoscopic 3D modes for GZDoom +** +**--------------------------------------------------------------------------- +** Copyright 2016 Christopher Bruns +** All rights reserved. +** +** Redistribution and use in source and binary forms, with or without +** modification, are permitted provided that the following conditions +** are met: +** +** 1. Redistributions of source code must retain the above copyright +** notice, this list of conditions and the following disclaimer. +** 2. Redistributions in binary form must reproduce the above copyright +** notice, this list of conditions and the following disclaimer in the +** documentation and/or other materials provided with the distribution. +** 3. The name of the author may not be used to endorse or promote products +** derived from this software without specific prior written permission. +** +** THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +** IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +** OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +** IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +** INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +** NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +** THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +**--------------------------------------------------------------------------- +** +** +*/ + +#ifndef GL_INTERLEAVED3D_H_ +#define GL_INTERLEAVED3D_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" +#include "gl_sidebyside3d.h" +#include "gl/system/gl_system.h" +#include "gl/renderer/gl_renderstate.h" + +namespace s3d { + +class RowInterleaved3D : public TopBottom3D +{ +public: + static const RowInterleaved3D& getInstance(float ipd); + RowInterleaved3D(double ipdMeters) : TopBottom3D(ipdMeters) {} + void Present() const override; +}; + +} /* namespace s3d */ + + +#endif /* GL_INTERLEAVED3D_H_ */ diff --git a/src/gl/stereo3d/gl_sidebyside3d.cpp b/src/gl/stereo3d/gl_sidebyside3d.cpp index c6463d2c8b..d2b0cafddc 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.cpp +++ b/src/gl/stereo3d/gl_sidebyside3d.cpp @@ -108,4 +108,42 @@ void SideBySideFull::AdjustPlayerSprites() const /* override */ gl_RenderState.ApplyMatrices(); } +/* static */ +const TopBottom3D& TopBottom3D::getInstance(float ipd) +{ + static TopBottom3D instance(ipd); + return instance; +} + +void TopBottom3D::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + // Compute screen regions to use for left and right eye views + int topHeight = GLRenderer->mOutputLetterbox.height / 2; + int bottomHeight = GLRenderer->mOutputLetterbox.height - topHeight; + GL_IRECT topHalfScreen = GLRenderer->mOutputLetterbox; + topHalfScreen.height = topHeight; + GL_IRECT bottomHalfScreen = GLRenderer->mOutputLetterbox; + bottomHalfScreen.height = bottomHeight; + bottomHalfScreen.top += topHeight; + + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(topHalfScreen, true); + + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(bottomHalfScreen, true); +} + +// AdjustViewports() is called from within FLGRenderer::SetOutputViewport(...) +void TopBottom3D::AdjustViewports() const +{ + // Change size of renderbuffer, and align to screen + GLRenderer->mSceneViewport.height /= 2; + GLRenderer->mSceneViewport.top /= 2; + GLRenderer->mScreenViewport.height /= 2; + GLRenderer->mScreenViewport.top /= 2; +} + } /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_sidebyside3d.h b/src/gl/stereo3d/gl_sidebyside3d.h index 374f255c59..c98f748a0b 100644 --- a/src/gl/stereo3d/gl_sidebyside3d.h +++ b/src/gl/stereo3d/gl_sidebyside3d.h @@ -88,6 +88,14 @@ private: SBSFRightEyePose rightEye; }; +class TopBottom3D : public SideBySideSquished +{ +public: + static const TopBottom3D& getInstance(float ipd); + TopBottom3D(double ipdMeters) : SideBySideSquished(ipdMeters) {} + void Present() const override; + virtual void AdjustViewports() const override; +}; } /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index c09a7a9749..16296393d6 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -30,6 +30,7 @@ #include "gl/stereo3d/gl_anaglyph.h" #include "gl/stereo3d/gl_quadstereo.h" #include "gl/stereo3d/gl_sidebyside3d.h" +#include "gl/stereo3d/gl_interleaved3d.h" #include "gl/system/gl_cvars.h" // Set up 3D-specific console variables: @@ -100,6 +101,12 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() setCurrentMode(AmberBlue::getInstance(vr_ipd)); break; // TODO: 10: HTC Vive/OpenVR + case 11: + setCurrentMode(TopBottom3D::getInstance(vr_ipd)); + break; + case 12: + setCurrentMode(RowInterleaved3D::getInstance(vr_ipd)); + break; case 0: default: setCurrentMode(MonoView::getInstance()); diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index 50526a75b5..813d6b8f61 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2703,6 +2703,8 @@ OPTVAL_LEFTEYE = "Left Eye"; OPTVAL_RIGHTEYE = "Right Eye"; OPTVAL_SBSFULL = "Side-by-side Full"; OPTVAL_SBSNARROW = "Side-by-side Narrow"; +OPTVAL_TOPBOTTOM = "Top/Bottom"; +OPTVAL_ROWINTERLEAVED = "Row Interleaved"; OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; diff --git a/wadsrc/static/menudef.zz b/wadsrc/static/menudef.zz index 1ab4f1a6d5..6f96ea286c 100644 --- a/wadsrc/static/menudef.zz +++ b/wadsrc/static/menudef.zz @@ -169,6 +169,8 @@ OptionValue VRMode 9, "$OPTVAL_AMBERBLUE" 3, "$OPTVAL_SBSFULL" 4, "$OPTVAL_SBSNARROW" + 11, "$OPTVAL_TOPBOTTOM" + 12, "$OPTVAL_ROWINTERLEAVED" 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" 7, "$OPTVAL_QUADBUFFERED"