Overte C++ Documentation
OculusMobileDisplayPlugin.h
1 //
2 // Created by Bradley Austin Davis on 2018/11/15
3 // Copyright 2013-2018 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 <EGL/egl.h>
13 
14 #include <QTimer>
15 #include <QtPlatformHeaders/QEGLNativeContext>
16 #include <QtAndroidExtras/QAndroidJniObject>
17 
18 #include <gl/Context.h>
19 #include <ovr/VrHandler.h>
20 
21 typedef struct ovrTextureSwapChain ovrTextureSwapChain;
22 typedef struct ovrMobile ovrMobile;
23 typedef struct ANativeWindow ANativeWindow;
24 
25 class OculusMobileDisplayPlugin : public HmdDisplayPlugin, public ovr::VrHandler {
26  using Parent = HmdDisplayPlugin;
27 public:
28  OculusMobileDisplayPlugin();
29  virtual ~OculusMobileDisplayPlugin();
30  bool isSupported() const override { return true; };
31  bool hasAsyncReprojection() const override { return true; }
32  bool getSupportsAutoSwitch() override final { return false; }
33  QThread::Priority getPresentPriority() override { return QThread::TimeCriticalPriority; }
34 
35  glm::mat4 getEyeProjection(Eye eye, const glm::mat4& baseProjection) const override;
36  glm::mat4 getCullingProjection(const glm::mat4& baseProjection) const override;
37 
38  // Stereo specific methods
39  void resetSensors() override final;
40  bool beginFrameRender(uint32_t frameIndex) override;
41 
42  QRectF getPlayAreaRect() override;
43  float getTargetFrameRate() const override;
44  void init() override;
45  void deinit() override;
46 
47 protected:
48  const QString getName() const override { return NAME; }
49 
50  bool internalActivate() override;
51  void internalDeactivate() override;
52 
53  void customizeContext() override;
54  void uncustomizeContext() override;
55 
56  void updatePresentPose() override;
57  void internalPresent() override;
58  void hmdPresent() override { throw std::runtime_error("Unused"); }
59  bool isHmdMounted() const override;
60  bool alwaysPresent() const override { return true; }
61 
62  static const char* NAME;
63  mutable gl::Context* _mainContext{ nullptr };
64  uint32_t _readFbo;
65 };
66