diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 6edd616ae..230c3dac9 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1115,6 +1115,7 @@ set( FASTMATH_SOURCES gl/stereo3d/scoped_view_shifter.cpp gl/stereo3d/gl_anaglyph.cpp gl/stereo3d/gl_quadstereo.cpp + gl/stereo3d/gl_sidebyside3d.cpp gl/dynlights/gl_dynlight.cpp gl/dynlights/gl_glow.cpp gl/dynlights/gl_dynlight1.cpp diff --git a/src/gl/stereo3d/gl_sidebyside3d.cpp b/src/gl/stereo3d/gl_sidebyside3d.cpp new file mode 100644 index 000000000..f526dce8b --- /dev/null +++ b/src/gl/stereo3d/gl_sidebyside3d.cpp @@ -0,0 +1,79 @@ +/* +** gl_sidebyside3d.cpp +** Color mask based 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_sidebyside3d.h" +#include "gl/renderer/gl_renderer.h" +#include "gl/renderer/gl_renderbuffers.h" + +namespace s3d { + + +/* static */ +const SideBySideSquished& SideBySideSquished::getInstance(float ipd) +{ + static SideBySideSquished instance(ipd); + return instance; +} + +SideBySideSquished::SideBySideSquished(double ipdMeters) + : leftEye(ipdMeters), rightEye(ipdMeters) +{ + eye_ptrs.Push(&leftEye); + eye_ptrs.Push(&rightEye); +} + +void SideBySideSquished::Present() const +{ + GLRenderer->mBuffers->BindOutputFB(); + GLRenderer->ClearBorders(); + + // Compute screen regions to use for left and right eye views + int leftWidth = GLRenderer->mOutputLetterbox.width/2; + int rightWidth = GLRenderer->mOutputLetterbox.width - leftWidth; + GL_IRECT leftHalfScreen = GLRenderer->mOutputLetterbox; + leftHalfScreen.width = leftWidth; + GL_IRECT rightHalfScreen = GLRenderer->mOutputLetterbox; + rightHalfScreen.width = rightWidth; + rightHalfScreen.left += leftWidth; + + GLRenderer->mBuffers->BindEyeTexture(0, 0); + GLRenderer->DrawPresentTexture(leftHalfScreen, true); + + GLRenderer->mBuffers->BindEyeTexture(1, 0); + GLRenderer->DrawPresentTexture(rightHalfScreen, true); +} + + +} /* namespace s3d */ diff --git a/src/gl/stereo3d/gl_sidebyside3d.h b/src/gl/stereo3d/gl_sidebyside3d.h new file mode 100644 index 000000000..2f2946424 --- /dev/null +++ b/src/gl/stereo3d/gl_sidebyside3d.h @@ -0,0 +1,63 @@ +/* +** gl_sidebyside3d.h +** Color mask based 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_SIDEBYSIDE3D_H_ +#define GL_SIDEBYSIDE3D_H_ + +#include "gl_stereo3d.h" +#include "gl_stereo_leftright.h" +#include "gl/system/gl_system.h" +#include "gl/renderer/gl_renderstate.h" + + +namespace s3d { + +class SideBySideSquished : public Stereo3DMode +{ +public: + static const SideBySideSquished& getInstance(float ipd); + + SideBySideSquished(double ipdMeters); + void Present() const override; +private: + LeftEyePose leftEye; + RightEyePose rightEye; +}; + + +} /* namespace s3d */ + + +#endif /* GL_SIDEBYSIDE3D_H_ */ diff --git a/src/gl/stereo3d/gl_stereo_cvars.cpp b/src/gl/stereo3d/gl_stereo_cvars.cpp index f904c2a51..cd6336026 100644 --- a/src/gl/stereo3d/gl_stereo_cvars.cpp +++ b/src/gl/stereo3d/gl_stereo_cvars.cpp @@ -29,6 +29,7 @@ #include "gl/stereo3d/gl_stereo_leftright.h" #include "gl/stereo3d/gl_anaglyph.h" #include "gl/stereo3d/gl_quadstereo.h" +#include "gl/stereo3d/gl_sidebyside3d.h" #include "gl/system/gl_cvars.h" // Set up 3D-specific console variables: @@ -71,7 +72,10 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode() case 2: setCurrentMode(RedCyan::getInstance(vr_ipd)); break; - // TODO: missing indices 3, 4 for not-yet-implemented side-by-side modes, to match values from GZ3Doom + // TODO: missing index 3 for not-yet-implemented side-by-side mode, to match values from GZ3Doom + case 4: + setCurrentMode(SideBySideSquished::getInstance(vr_ipd)); + break; case 5: setCurrentMode(LeftEyeView::getInstance(vr_ipd)); break; diff --git a/wadsrc/static/language.enu b/wadsrc/static/language.enu index e3fbb16ca..4b4013cc7 100644 --- a/wadsrc/static/language.enu +++ b/wadsrc/static/language.enu @@ -2701,6 +2701,7 @@ OPTVAL_REDCYAN = "Red/Cyan"; OPTVAL_AMBERBLUE = "Amber/Blue"; OPTVAL_LEFTEYE = "Left Eye"; OPTVAL_RIGHTEYE = "Right Eye"; +OPTVAL_SBSNARROW = "Side-by-side Narrow"; OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_HEJLDAWSON = "Hejl Dawson"; diff --git a/wadsrc/static/menudef.z b/wadsrc/static/menudef.z index 980cdacc3..28c343c2a 100644 --- a/wadsrc/static/menudef.z +++ b/wadsrc/static/menudef.z @@ -167,6 +167,7 @@ OptionValue VRMode 1, "$OPTVAL_GREENMAGENTA" 2, "$OPTVAL_REDCYAN" 9, "$OPTVAL_AMBERBLUE" + 4, "$OPTVAL_SBSNARROW" 5, "$OPTVAL_LEFTEYE" 6, "$OPTVAL_RIGHTEYE" 7, "$OPTVAL_QUADBUFFERED"