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_stereo3d.cpp
|
|
|
|
** Stereoscopic 3D API
|
|
|
|
**
|
|
|
|
*/
|
|
|
|
|
2016-03-21 01:57:02 +00:00
|
|
|
#include "gl/system/gl_system.h"
|
2015-10-26 13:08:18 +00:00
|
|
|
#include "gl/stereo3d/gl_stereo3d.h"
|
2016-03-21 01:57:02 +00:00
|
|
|
#include "gl/renderer/gl_renderer.h"
|
2015-10-26 13:08:18 +00:00
|
|
|
#include "vectors.h" // RAD2DEG
|
|
|
|
#include "doomtype.h" // M_PI
|
|
|
|
|
|
|
|
namespace s3d {
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */
|
2016-04-26 12:03:10 +00:00
|
|
|
VSMatrix EyePose::GetProjection(float fov, float aspectRatio, float fovRatio) const
|
2015-10-26 13:08:18 +00:00
|
|
|
{
|
2015-10-31 11:46:36 +00:00
|
|
|
VSMatrix result;
|
2015-10-26 13:08:18 +00:00
|
|
|
|
2015-10-31 11:46:36 +00:00
|
|
|
// Lifted from gl_scene.cpp FGLRenderer::SetProjection()
|
2015-12-30 22:54:54 +00:00
|
|
|
float fovy = (float)(2 * RAD2DEG(atan(tan(DEG2RAD(fov) / 2) / fovRatio)));
|
2015-10-31 11:46:36 +00:00
|
|
|
result.perspective(fovy, aspectRatio, 5.f, 65536.f);
|
2015-10-26 13:08:18 +00:00
|
|
|
|
2015-10-31 11:46:36 +00:00
|
|
|
return result;
|
2015-10-26 13:08:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* virtual */
|
|
|
|
Viewport EyePose::GetViewport(const Viewport& fullViewport) const
|
|
|
|
{
|
|
|
|
return fullViewport;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* virtual */
|
2016-04-26 12:03:10 +00:00
|
|
|
void EyePose::GetViewShift(float yaw, float outViewShift[3]) const
|
2015-10-26 13:08:18 +00:00
|
|
|
{
|
|
|
|
// pass-through for Mono view
|
|
|
|
outViewShift[0] = 0;
|
|
|
|
outViewShift[1] = 0;
|
|
|
|
outViewShift[2] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Stereo3DMode::Stereo3DMode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
Stereo3DMode::~Stereo3DMode()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
// Avoid static initialization order fiasco by declaring first Mode type (Mono) here in the
|
|
|
|
// same source file as Stereo3DMode::getCurrentMode()
|
|
|
|
// https://isocpp.org/wiki/faq/ctors#static-init-order
|
|
|
|
|
|
|
|
/* static */
|
|
|
|
const MonoView& MonoView::getInstance()
|
|
|
|
{
|
|
|
|
static MonoView instance;
|
|
|
|
return instance;
|
|
|
|
}
|
|
|
|
|
|
|
|
} /* namespace s3d */
|