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