2016-09-14 18:01:13 +00:00
|
|
|
//
|
|
|
|
//---------------------------------------------------------------------------
|
|
|
|
//
|
|
|
|
// 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/
|
|
|
|
//
|
|
|
|
//--------------------------------------------------------------------------
|
|
|
|
//
|
2015-12-31 14:06:44 +00:00
|
|
|
/*
|
|
|
|
** gl_anaglyph.cpp
|
|
|
|
** Color mask based stereoscopic 3D modes for GZDoom
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2015-10-26 13:08:18 +00:00
|
|
|
#include "gl_anaglyph.h"
|
2016-09-08 17:02:13 +00:00
|
|
|
#include "gl/renderer/gl_renderer.h"
|
|
|
|
#include "gl/renderer/gl_renderbuffers.h"
|
2015-10-26 13:08:18 +00:00
|
|
|
|
|
|
|
namespace s3d {
|
|
|
|
|
|
|
|
MaskAnaglyph::MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters)
|
|
|
|
: leftEye(leftColorMask, ipdMeters), rightEye(leftColorMask.inverse(), ipdMeters)
|
|
|
|
{
|
2015-12-31 14:36:37 +00:00
|
|
|
eye_ptrs.Push(&leftEye);
|
|
|
|
eye_ptrs.Push(&rightEye);
|
2015-10-26 13:08:18 +00:00
|
|
|
}
|
|
|
|
|
2016-09-08 17:02:13 +00:00
|
|
|
void MaskAnaglyph::Present() const
|
|
|
|
{
|
|
|
|
GLRenderer->mBuffers->BindOutputFB();
|
|
|
|
GLRenderer->ClearBorders();
|
|
|
|
|
|
|
|
gl_RenderState.SetColorMask(leftEye.GetColorMask().r, leftEye.GetColorMask().g, leftEye.GetColorMask().b, true);
|
|
|
|
gl_RenderState.ApplyColorMask();
|
|
|
|
GLRenderer->mBuffers->BindEyeTexture(0, 0);
|
|
|
|
GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true);
|
|
|
|
|
|
|
|
gl_RenderState.SetColorMask(rightEye.GetColorMask().r, rightEye.GetColorMask().g, rightEye.GetColorMask().b, true);
|
|
|
|
gl_RenderState.ApplyColorMask();
|
|
|
|
GLRenderer->mBuffers->BindEyeTexture(1, 0);
|
|
|
|
GLRenderer->DrawPresentTexture(GLRenderer->mOutputLetterbox, true);
|
|
|
|
|
|
|
|
gl_RenderState.ResetColorMask();
|
|
|
|
gl_RenderState.ApplyColorMask();
|
|
|
|
}
|
|
|
|
|
2015-10-26 13:08:18 +00:00
|
|
|
|
|
|
|
/* static */
|
2016-04-26 12:03:10 +00:00
|
|
|
const GreenMagenta& GreenMagenta::getInstance(float ipd)
|
2015-10-26 13:08:18 +00:00
|
|
|
{
|
|
|
|
static GreenMagenta instance(ipd);
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* static */
|
2016-04-26 12:03:10 +00:00
|
|
|
const RedCyan& RedCyan::getInstance(float ipd)
|
2015-10-26 13:08:18 +00:00
|
|
|
{
|
|
|
|
static RedCyan instance(ipd);
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2016-04-09 19:40:55 +00:00
|
|
|
/* static */
|
2016-04-26 12:03:10 +00:00
|
|
|
const AmberBlue& AmberBlue::getInstance(float ipd)
|
2016-04-09 19:40:55 +00:00
|
|
|
{
|
|
|
|
static AmberBlue instance(ipd);
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-10-26 13:08:18 +00:00
|
|
|
} /* namespace s3d */
|