mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-29 07:22:07 +00:00
Implement vr_swap_eyes CVAR, now that side-by-side mode is mostly working.
This commit is contained in:
parent
a1cbd39f3f
commit
2e8d2ed626
4 changed files with 18 additions and 8 deletions
|
@ -58,7 +58,6 @@ public:
|
|||
virtual void GetViewShift(float yaw, float outViewShift[3]) const;
|
||||
virtual void SetUp() const {};
|
||||
virtual void TearDown() const {};
|
||||
// virtual void EndDrawScene(sector_t * viewsector) const {GLRenderer->EndDrawScene(viewsector);};
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -35,6 +35,9 @@
|
|||
// Set up 3D-specific console variables:
|
||||
CVAR(Int, vr_mode, 0, CVAR_GLOBALCONFIG)
|
||||
|
||||
// switch left and right eye views
|
||||
CVAR(Bool, vr_swap_eyes, false, CVAR_GLOBALCONFIG)
|
||||
|
||||
// For broadest GL compatibility, require user to explicitly enable quad-buffered stereo mode.
|
||||
// Setting vr_enable_quadbuffered_stereo does not automatically invoke quad-buffered stereo,
|
||||
// but makes it possible for subsequent "vr_mode 7" to invoke quad-buffered stereo
|
||||
|
|
|
@ -37,6 +37,7 @@
|
|||
|
||||
EXTERN_CVAR(Float, vr_screendist)
|
||||
EXTERN_CVAR(Float, vr_hunits_per_meter)
|
||||
EXTERN_CVAR(Bool, vr_swap_eyes)
|
||||
|
||||
namespace s3d {
|
||||
|
||||
|
@ -50,7 +51,7 @@ VSMatrix ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRa
|
|||
// For stereo 3D, use asymmetric frustum shift in projection matrix
|
||||
// Q: shouldn't shift vary with roll angle, at least for desktop display?
|
||||
// A: No. (lab) roll is not measured on desktop display (yet)
|
||||
double frustumShift = zNear * shift / vr_screendist; // meters cancel, leaving doom units
|
||||
double frustumShift = zNear * getShift() / vr_screendist; // meters cancel, leaving doom units
|
||||
// double frustumShift = 0; // Turning off shift for debugging
|
||||
double fH = zNear * tan(DEG2RAD(fov) / 2) / fovRatio;
|
||||
double fW = fH * aspectRatio;
|
||||
|
@ -68,13 +69,17 @@ VSMatrix ShiftedEyePose::GetProjection(float fov, float aspectRatio, float fovRa
|
|||
/* virtual */
|
||||
void ShiftedEyePose::GetViewShift(float yaw, float outViewShift[3]) const
|
||||
{
|
||||
float dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * shift;
|
||||
float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * shift;
|
||||
float dx = -cos(DEG2RAD(yaw)) * vr_hunits_per_meter * getShift();
|
||||
float dy = sin(DEG2RAD(yaw)) * vr_hunits_per_meter * getShift();
|
||||
outViewShift[0] = dx;
|
||||
outViewShift[1] = dy;
|
||||
outViewShift[2] = 0;
|
||||
}
|
||||
|
||||
float ShiftedEyePose::getShift() const
|
||||
{
|
||||
return vr_swap_eyes ? -shift : shift;
|
||||
}
|
||||
|
||||
/* static */
|
||||
const LeftEyeView& LeftEyeView::getInstance(float ipd)
|
||||
|
|
|
@ -37,11 +37,14 @@ class ShiftedEyePose : public EyePose
|
|||
{
|
||||
public:
|
||||
ShiftedEyePose(float shift) : shift(shift) {};
|
||||
float getShift() const { return shift; }
|
||||
void setShift(float shift) { this->shift = shift; }
|
||||
float getShift() const;
|
||||
virtual VSMatrix GetProjection(float fov, float aspectRatio, float fovRatio) const;
|
||||
virtual void GetViewShift(float yaw, float outViewShift[3]) const;
|
||||
|
||||
protected:
|
||||
void setShift(float shift) { this->shift = shift; }
|
||||
|
||||
private:
|
||||
float shift;
|
||||
};
|
||||
|
||||
|
@ -50,7 +53,7 @@ class LeftEyePose : public ShiftedEyePose
|
|||
{
|
||||
public:
|
||||
LeftEyePose(float ipd) : ShiftedEyePose( float(-0.5) * ipd) {}
|
||||
float getIpd() const { return float(-2.0)*getShift(); }
|
||||
float getIpd() const { return float(fabs(2.0f*getShift())); }
|
||||
void setIpd(float ipd) { setShift(float(-0.5)*ipd); }
|
||||
};
|
||||
|
||||
|
@ -59,7 +62,7 @@ class RightEyePose : public ShiftedEyePose
|
|||
{
|
||||
public:
|
||||
RightEyePose(float ipd) : ShiftedEyePose(float(+0.5)*ipd) {}
|
||||
float getIpd() const { return float(+2.0)*shift; }
|
||||
float getIpd() const { return float(fabs(2.0f*getShift())); }
|
||||
void setIpd(float ipd) { setShift(float(+0.5)*ipd); }
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue