Skip to content

Commit

Permalink
Fix enableVR setting
Browse files Browse the repository at this point in the history
The setting `enableVR` was stored in `DisplaySettings` and `ViewerApp` but not kept synchronised. To fix this, `enableVR` is moved into `GLApplication`, the base class of `ViewerApp`.
  • Loading branch information
cr333 committed Dec 12, 2020
1 parent 63f6e82 commit 23abcdb
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 14 deletions.
3 changes: 0 additions & 3 deletions src/Core/DisplaySettings.hpp
Expand Up @@ -28,9 +28,6 @@ struct DisplaySettings
// Size of the window.
Eigen::Vector2i windowDims = Eigen::Vector2i(1280, 720);

// Whether or not VR rendering with a head-mounted display is enabled.
bool enableVR = false;

int switchGLProgram = 1;

// RenderModel = 0 -> render black screen
Expand Down
4 changes: 2 additions & 2 deletions src/Core/GL/GLApplication.cpp
Expand Up @@ -107,7 +107,7 @@ void GLApplication::postRender()
void GLApplication::render()
{
#ifdef WITH_OPENVR
if (settings->enableVR) // use OpenVR for VR rendering
if (enableVR) // use OpenVR for VR rendering
{
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
Expand Down Expand Up @@ -409,7 +409,7 @@ void GLApplication::sharedUserInput()

#ifdef WITH_OPENVR
// VR-specific keys.
if (settings->enableVR)
if (enableVR)
{
// Reset the HMD pose to the current pose.
if (inputHandler->s_key_pressed)
Expand Down
3 changes: 3 additions & 0 deletions src/Core/GL/GLApplication.hpp
Expand Up @@ -41,6 +41,9 @@ class GLApplication : public Application
*/
VRInterface* hmd = nullptr;

// Whether or not VR rendering with a head-mounted display is enabled.
bool enableVR = false;

/**
* This needs to be used in GLApplications. Each program is registered with a
* render model initially. GLPrograms can be re-used by just exchanging the used rendermodel.
Expand Down
15 changes: 7 additions & 8 deletions src/Viewer/ViewerApp.cpp
Expand Up @@ -40,7 +40,7 @@ ViewerApp::~ViewerApp()
{
// We don't use GUI in VR, so only clean it up if not in VR.
#ifdef WITH_OPENVR
if (settings->enableVR == true)
if (enableVR)
{
delete hmd;
hmd = nullptr;
Expand Down Expand Up @@ -175,7 +175,7 @@ int ViewerApp::init()
GLApplication::init();

#ifdef WITH_OPENVR
if (settings->enableVR)
if (enableVR)
{
Eigen::Matrix4f initRot = createRotationTransform44(Eigen::Vector3f::UnitY(), settings->lookAtDirection);
hmd = new VRInterface(0.1f, 1000.0f, initRot, this); // near/far clip distance [m]
Expand All @@ -199,7 +199,7 @@ int ViewerApp::init()

// GUI is only used outside the HMD.
#ifdef WITH_OPENVR
if (settings->enableVR == false)
if (enableVR == false)
#endif
{
if (!guiInit)
Expand Down Expand Up @@ -233,7 +233,7 @@ int ViewerApp::initPrograms()
VLOG(1) << "ViewerApp::initPrograms()";

#ifdef WITH_OPENVR
if (settings->enableVR)
if (enableVR)
{
hmd->initGLPrograms(&app_gl_programs);

Expand Down Expand Up @@ -306,7 +306,7 @@ int ViewerApp::initPrograms()

// Ignore the plane in VR.
// TODO: update the plane pose in VR.
if (settings->enableVR == false)
if (enableVR == false)
{
proxies_str.push_back("Plane");
proxies.push_back(std::pair<int, GLRenderModel*>(_proxy_id++, getGLCamera()->getPlane()->getRenderModel()));
Expand Down Expand Up @@ -428,7 +428,6 @@ void ViewerApp::loadDatasetCPU(const int dataset_idx)
// 0-2) Load new dataset and settings from disk.
CameraSetupDataset& dataset = datasetInfoList[dataset_idx];
datasetBackSetting.configFile = dataset.pathToConfigYAML;
datasetBackSetting.enableVR = enableVR;
LOG(INFO) << "Loading the dataset from:\n"
<< datasetBackSetting.configFile;
datasetBack->loadFromCache(&datasetBackSetting);
Expand Down Expand Up @@ -570,12 +569,12 @@ void ViewerApp::run()
GLApplication::render();

#ifdef WITH_OPENVR
if (settings->enableVR)
if (enableVR)
hmd->handleInput(&app_gl_programs);
///////////////////////////////////////////////////////////
//This belongs all to rendering...

if (settings->enableVR == false)
if (enableVR == false)
#endif
{
if (showImGui)
Expand Down
1 change: 0 additions & 1 deletion src/Viewer/ViewerApp.hpp
Expand Up @@ -136,7 +136,6 @@ class ViewerApp : public GLApplication
bool checkForDatasets();
void updateCamPhiDirTexture();

bool enableVR = false;
ViewerGUI* gui = nullptr;
CameraSetupDataset* appDataset = nullptr;
CameraSetupVisualization* appVisualization = nullptr;
Expand Down

0 comments on commit 23abcdb

Please sign in to comment.