Overte C++ Documentation
VrHandler.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 <glm/glm.hpp>
11 #include <jni.h>
12 #include <VrApi_Types.h>
13 
14 #include "TaskQueue.h"
15 
16 typedef struct ovrMobile ovrMobile;
17 namespace ovr {
18 
19 class VrHandler {
20 public:
21  using HandlerTask = std::function<void(VrHandler*)>;
22  using OvrMobileTask = std::function<void(ovrMobile*)>;
23  using OvrJavaTask = std::function<void(const ovrJava*)>;
24  static void setHandler(VrHandler* handler, bool noError = false);
25  static bool withOvrMobile(const OvrMobileTask& task);
26 
27 protected:
28  static void initVr(const char* appId = nullptr);
29  static void shutdownVr();
30  static bool withOvrJava(const OvrJavaTask& task);
31 
32  uint32_t currentPresentIndex() const;
33  ovrTracking2 beginFrame();
34  void presentFrame(uint32_t textureId, const glm::uvec2& size, const ovrTracking2& tracking) const;
35 
36  bool vrActive() const;
37  void pollTask();
38  void makeCurrent();
39  void doneCurrent();
40 };
41 
42 }
43 
44 
45 
46 
47