mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-26 06:01:14 +00:00
Refactor stereo3d classes to use TArray instead of std::vector.
This commit is contained in:
parent
5b7f9b04cd
commit
95f4134630
4 changed files with 16 additions and 19 deletions
|
@ -816,19 +816,19 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
|
|||
float viewShift[3];
|
||||
const s3d::Stereo3DMode& stereo3dMode = s3d::Stereo3DMode::getCurrentMode();
|
||||
stereo3dMode.SetUp();
|
||||
s3d::Stereo3DMode::const_iterator eye;
|
||||
for (eye = stereo3dMode.begin(); eye != stereo3dMode.end(); ++eye)
|
||||
for (int eye_ix = 0; eye_ix < stereo3dMode.eye_count(); ++eye_ix)
|
||||
{
|
||||
(*eye)->SetUp();
|
||||
const s3d::EyePose * eye = stereo3dMode.getEyePose(eye_ix);
|
||||
eye->SetUp();
|
||||
// TODO: stereo specific viewport - needed when implementing side-by-side modes etc.
|
||||
SetViewport(bounds);
|
||||
mCurrentFoV = fov;
|
||||
// Stereo mode specific perspective projection
|
||||
SetProjection( (*eye)->GetProjection(fov, ratio, fovratio) );
|
||||
SetProjection( eye->GetProjection(fov, ratio, fovratio) );
|
||||
// SetProjection(fov, ratio, fovratio); // switch to perspective mode and set up clipper
|
||||
SetViewAngle(viewangle);
|
||||
// Stereo mode specific viewpoint adjustment - temporarily shifts global viewx, viewy, viewz
|
||||
(*eye)->GetViewShift(GLRenderer->mAngles.Yaw, viewShift);
|
||||
eye->GetViewShift(GLRenderer->mAngles.Yaw, viewShift);
|
||||
s3d::ScopedViewShifter viewShifter(viewShift);
|
||||
SetViewMatrix(viewx, viewy, viewz, false, false);
|
||||
gl_RenderState.ApplyMatrices();
|
||||
|
@ -839,7 +839,7 @@ sector_t * FGLRenderer::RenderViewpoint (AActor * camera, GL_IRECT * bounds, flo
|
|||
|
||||
ProcessScene(toscreen);
|
||||
EndDrawScene(viewsector);
|
||||
(*eye)->TearDown();
|
||||
eye->TearDown();
|
||||
}
|
||||
stereo3dMode.TearDown();
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ namespace s3d {
|
|||
MaskAnaglyph::MaskAnaglyph(const ColorMask& leftColorMask, double ipdMeters)
|
||||
: leftEye(leftColorMask, ipdMeters), rightEye(leftColorMask.inverse(), ipdMeters)
|
||||
{
|
||||
eye_ptrs.push_back(&leftEye);
|
||||
eye_ptrs.push_back(&rightEye);
|
||||
eye_ptrs.Push(&leftEye);
|
||||
eye_ptrs.Push(&rightEye);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
#ifndef GL_STEREO3D_H_
|
||||
#define GL_STEREO3D_H_
|
||||
|
||||
#include <vector>
|
||||
#include <cstring> // needed for memcpy on linux, which is needed by VSMatrix copy ctor
|
||||
#include "tarray.h"
|
||||
#include "gl/data/gl_matrix.h"
|
||||
|
||||
|
||||
|
@ -72,23 +72,20 @@ public:
|
|||
class Stereo3DMode
|
||||
{
|
||||
public:
|
||||
/* const_iterator cycles through the various eye viewpoints */
|
||||
typedef std::vector<const EyePose *>::const_iterator const_iterator;
|
||||
|
||||
/* static methods for managing the selected stereoscopic view state */
|
||||
static const Stereo3DMode& getCurrentMode();
|
||||
|
||||
Stereo3DMode();
|
||||
virtual ~Stereo3DMode();
|
||||
/* const_iterator cycles through the various eye viewpoints */
|
||||
virtual const_iterator begin() const { return eye_ptrs.begin(); }
|
||||
virtual const_iterator end() const { return eye_ptrs.end(); }
|
||||
virtual int eye_count() const { return eye_ptrs.Size(); }
|
||||
virtual const EyePose * getEyePose(int ix) const { return eye_ptrs(ix); }
|
||||
|
||||
/* hooks for setup and cleanup operations for each stereo mode */
|
||||
virtual void SetUp() const {};
|
||||
virtual void TearDown() const {};
|
||||
|
||||
protected:
|
||||
std::vector<const EyePose *> eye_ptrs;
|
||||
TArray<const EyePose *> eye_ptrs;
|
||||
|
||||
private:
|
||||
static Stereo3DMode const * currentStereo3DMode;
|
||||
|
@ -105,7 +102,7 @@ public:
|
|||
static const MonoView& getInstance();
|
||||
|
||||
protected:
|
||||
MonoView() { eye_ptrs.push_back(¢ralEye); }
|
||||
MonoView() { eye_ptrs.Push(¢ralEye); }
|
||||
EyePose centralEye;
|
||||
};
|
||||
|
||||
|
|
|
@ -80,7 +80,7 @@ class LeftEyeView : public Stereo3DMode
|
|||
public:
|
||||
static const LeftEyeView& getInstance(FLOATTYPE ipd);
|
||||
|
||||
LeftEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.push_back(&eye); }
|
||||
LeftEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); }
|
||||
FLOATTYPE getIpd() const { return eye.getIpd(); }
|
||||
void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); }
|
||||
protected:
|
||||
|
@ -93,7 +93,7 @@ class RightEyeView : public Stereo3DMode
|
|||
public:
|
||||
static const RightEyeView& getInstance(FLOATTYPE ipd);
|
||||
|
||||
RightEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.push_back(&eye); }
|
||||
RightEyeView(FLOATTYPE ipd) : eye(ipd) { eye_ptrs.Push(&eye); }
|
||||
FLOATTYPE getIpd() const { return eye.getIpd(); }
|
||||
void setIpd(FLOATTYPE ipd) { eye.setIpd(ipd); }
|
||||
protected:
|
||||
|
|
Loading…
Reference in a new issue