Overte C++ Documentation
OculusBaseDisplayPlugin.h
1 //
2 // Created by Bradley Austin Davis on 2015/05/29
3 // Copyright 2015 High Fidelity, Inc.
4 //
5 // Distributed under the Apache License, Version 2.0.
6 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
7 //
8 #pragma once
9 
10 #include <display-plugins/hmd/HmdDisplayPlugin.h>
11 
12 #include <QTimer>
13 
14 #include <OVR_CAPI_GL.h>
15 
16 #define OVRPL_DISABLED
17 #include <OVR_Platform.h>
18 
19 #include <graphics/Geometry.h>
20 
21 class OculusBaseDisplayPlugin : public HmdDisplayPlugin {
22  using Parent = HmdDisplayPlugin;
23 public:
24  bool isSupported() const override;
25  bool hasAsyncReprojection() const override { return true; }
26  bool getSupportsAutoSwitch() override final { return true; }
27 
28  glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override;
29  glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override;
30 
31  // Stereo specific methods
32  void resetSensors() override final;
33  bool beginFrameRender(uint32_t frameIndex) override;
34  float getTargetFrameRate() const override { return _hmdDesc.DisplayRefreshRate; }
35 
36  QRectF getPlayAreaRect() override;
37  QVector<glm::vec3> getSensorPositions() override;
38 
39  virtual StencilMaskMode getStencilMaskMode() const override { return StencilMaskMode::MESH; }
40  virtual StencilMaskMeshOperator getStencilMaskMeshOperator() override;
41 
42 protected:
43  void customizeContext() override;
44  void uncustomizeContext() override;
45  bool internalActivate() override;
46  void internalDeactivate() override;
47  void updatePresentPose() override;
48 
49 protected:
50  ovrSession _session{ nullptr };
51  ovrGraphicsLuid _luid;
52  std::array<ovrEyeRenderDesc, 2> _eyeRenderDescs;
53  std::array<ovrFovPort, 2> _eyeFovs;
54  ovrHmdDesc _hmdDesc;
55  ovrLayerEyeFov _sceneLayer;
56  ovrViewScaleDesc _viewScaleDesc;
57  // ovrLayerEyeFovDepth _depthLayer;
58  bool _hmdMounted { false };
59  bool _visible { true };
60 
61  std::array<graphics::MeshPointer, 2> _stencilMeshes;
62  bool _stencilMeshesInitialized { false };
63 };