Implement side-by-side narrow 3D mode.

This commit is contained in:
Christopher Bruns 2016-09-10 15:34:15 -04:00 committed by Christoph Oelckers
parent 2339b18b01
commit 9a257ac158
6 changed files with 150 additions and 1 deletions

View file

@ -1115,6 +1115,7 @@ set( FASTMATH_SOURCES
gl/stereo3d/scoped_view_shifter.cpp gl/stereo3d/scoped_view_shifter.cpp
gl/stereo3d/gl_anaglyph.cpp gl/stereo3d/gl_anaglyph.cpp
gl/stereo3d/gl_quadstereo.cpp gl/stereo3d/gl_quadstereo.cpp
gl/stereo3d/gl_sidebyside3d.cpp
gl/dynlights/gl_dynlight.cpp gl/dynlights/gl_dynlight.cpp
gl/dynlights/gl_glow.cpp gl/dynlights/gl_glow.cpp
gl/dynlights/gl_dynlight1.cpp gl/dynlights/gl_dynlight1.cpp

View file

@ -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 */

View file

@ -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_ */

View file

@ -29,6 +29,7 @@
#include "gl/stereo3d/gl_stereo_leftright.h" #include "gl/stereo3d/gl_stereo_leftright.h"
#include "gl/stereo3d/gl_anaglyph.h" #include "gl/stereo3d/gl_anaglyph.h"
#include "gl/stereo3d/gl_quadstereo.h" #include "gl/stereo3d/gl_quadstereo.h"
#include "gl/stereo3d/gl_sidebyside3d.h"
#include "gl/system/gl_cvars.h" #include "gl/system/gl_cvars.h"
// Set up 3D-specific console variables: // Set up 3D-specific console variables:
@ -71,7 +72,10 @@ const Stereo3DMode& Stereo3DMode::getCurrentMode()
case 2: case 2:
setCurrentMode(RedCyan::getInstance(vr_ipd)); setCurrentMode(RedCyan::getInstance(vr_ipd));
break; 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: case 5:
setCurrentMode(LeftEyeView::getInstance(vr_ipd)); setCurrentMode(LeftEyeView::getInstance(vr_ipd));
break; break;

View file

@ -2701,6 +2701,7 @@ OPTVAL_REDCYAN = "Red/Cyan";
OPTVAL_AMBERBLUE = "Amber/Blue"; OPTVAL_AMBERBLUE = "Amber/Blue";
OPTVAL_LEFTEYE = "Left Eye"; OPTVAL_LEFTEYE = "Left Eye";
OPTVAL_RIGHTEYE = "Right Eye"; OPTVAL_RIGHTEYE = "Right Eye";
OPTVAL_SBSNARROW = "Side-by-side Narrow";
OPTVAL_QUADBUFFERED = "Quad-buffered"; OPTVAL_QUADBUFFERED = "Quad-buffered";
OPTVAL_UNCHARTED2 = "Uncharted 2"; OPTVAL_UNCHARTED2 = "Uncharted 2";
OPTVAL_HEJLDAWSON = "Hejl Dawson"; OPTVAL_HEJLDAWSON = "Hejl Dawson";

View file

@ -167,6 +167,7 @@ OptionValue VRMode
1, "$OPTVAL_GREENMAGENTA" 1, "$OPTVAL_GREENMAGENTA"
2, "$OPTVAL_REDCYAN" 2, "$OPTVAL_REDCYAN"
9, "$OPTVAL_AMBERBLUE" 9, "$OPTVAL_AMBERBLUE"
4, "$OPTVAL_SBSNARROW"
5, "$OPTVAL_LEFTEYE" 5, "$OPTVAL_LEFTEYE"
6, "$OPTVAL_RIGHTEYE" 6, "$OPTVAL_RIGHTEYE"
7, "$OPTVAL_QUADBUFFERED" 7, "$OPTVAL_QUADBUFFERED"