Skip to content

Commit

Permalink
Stereo 3D: Only use a stereo GL format if necessary
Browse files Browse the repository at this point in the history
Whenever the VR mode changes, the canvas GL format is checked for
possible changes.
  • Loading branch information
skyjake committed Nov 20, 2013
1 parent d5bd255 commit 704c942
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 12 deletions.
17 changes: 9 additions & 8 deletions doomsday/client/include/render/vr.h
Expand Up @@ -80,14 +80,15 @@ void releaseViewPosition();
bool viewPositionHeld();

// Console variables
Stereo3DMode mode(); /// Currently active Stereo3DMode index
float riftFovX(); /// Horizontal field of view in Oculus Rift in degrees
float riftLatency(); /// Estimated head-motion->photons latency, in seconds

extern float ipd; /// Interpupillary distance in meters
extern float playerHeight; /// Human player's real world height in meters
extern float dominantEye; /// Kludge for aim-down-weapon-sight modes
extern byte swapEyes; /// When true, inverts stereoscopic effect
Stereo3DMode mode(); ///< Currently active Stereo3DMode index
bool modeNeedsStereoGLFormat(Stereo3DMode mode);
float riftFovX(); ///< Horizontal field of view in Oculus Rift in degrees
float riftLatency(); ///< Estimated head-motion->photons latency, in seconds

extern float ipd; ///< Interpupillary distance in meters
extern float playerHeight; ///< Human player's real world height in meters
extern float dominantEye; ///< Kludge for aim-down-weapon-sight modes
extern byte swapEyes; ///< When true, inverts stereoscopic effect

// Variables below are global, but not user visible //

Expand Down
9 changes: 8 additions & 1 deletion doomsday/client/src/render/vr.cpp
Expand Up @@ -80,6 +80,11 @@ VR::Stereo3DMode VR::mode()
return (VR::Stereo3DMode)vrMode;
}

bool VR::modeNeedsStereoGLFormat(VR::Stereo3DMode mode)
{
return mode == VR::MODE_QUAD_BUFFERED;
}

static float vrRiftFovX = 114.8;
float VR::riftFovX() /// Horizontal field of view in degrees
{
Expand Down Expand Up @@ -134,7 +139,9 @@ static void vrModeChanged()
if(ClientWindow::hasMain())
{
// The logical UI size may need to be changed.
ClientWindow::main().updateRootSize();
ClientWindow &win = ClientWindow::main();
win.updateRootSize();
win.updateCanvasFormat(); // possibly changes pixel format
}
if (VR::mode() == VR::MODE_OCULUS_RIFT) {
if(Con_GetFloat("rend-camera-fov") != vrRiftFovX)
Expand Down
11 changes: 8 additions & 3 deletions doomsday/client/src/ui/clientwindow.cpp
Expand Up @@ -242,8 +242,6 @@ DENG2_OBSERVES(App, GameChange)
switch(newMode)
{
case Busy:
//busy->renderTransitionFrame();

game->hide();
game->disable();
gameUI->hide();
Expand All @@ -258,6 +256,7 @@ DENG2_OBSERVES(App, GameChange)
default:
busy->hide();
busy->disable();

game->show();
game->enable();
gameUI->show();
Expand Down Expand Up @@ -669,7 +668,13 @@ bool ClientWindow::setDefaultGLFormat() // static
fmt.setDepthBufferSize(16);
fmt.setStencilBufferSize(8);
fmt.setDoubleBuffer(true);
fmt.setStereo(true);

if(VR::modeNeedsStereoGLFormat(VR::mode()))
{
// Only use a stereo format for modes that require it.
LOG_MSG("Using a stereoscopic format");
fmt.setStereo(true);
}

if(CommandLine_Exists("-novsync") || !Con_GetByte("vid-vsync"))
{
Expand Down

0 comments on commit 704c942

Please sign in to comment.