Blender  V2.93
GHOST_XrSession.h
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  */
16 
21 #pragma once
22 
23 #include <map>
24 #include <memory>
25 
26 #include "GHOST_Xr_intern.h"
27 
28 class GHOST_XrContext;
29 class GHOST_XrSwapchain;
30 struct GHOST_XrDrawInfo;
31 struct OpenXRSessionData;
32 
34  public:
38  };
39 
40  GHOST_XrSession(GHOST_XrContext &xr_context);
42 
43  void start(const GHOST_XrSessionBeginInfo *begin_info);
44  void requestEnd();
45 
46  LifeExpectancy handleStateChangeEvent(const XrEventDataSessionStateChanged &lifecycle);
47 
48  bool isRunning() const;
49  bool needsUpsideDownDrawing() const;
50 
51  void unbindGraphicsContext(); /* Public so context can ensure it's unbound as needed. */
52 
53  void draw(void *draw_customdata);
54 
55  private:
58  class GHOST_XrContext *m_context;
59 
60  std::unique_ptr<OpenXRSessionData> m_oxr; /* Could use stack, but PImpl is preferable. */
61 
63  class GHOST_Context *m_gpu_ctx = nullptr;
64  std::unique_ptr<class GHOST_IXrGraphicsBinding> m_gpu_binding;
65 
67  std::unique_ptr<GHOST_XrDrawInfo> m_draw_info;
68 
69  void initSystem();
70  void beginSession();
71  void endSession();
72 
73  void bindGraphicsContext();
74 
75  void prepareDrawing();
76  XrCompositionLayerProjection drawLayer(
77  std::vector<XrCompositionLayerProjectionView> &r_proj_layer_views, void *draw_customdata);
78  void drawView(GHOST_XrSwapchain &swapchain,
79  XrCompositionLayerProjectionView &r_proj_layer_view,
80  XrSpaceLocation &view_location,
81  XrView &view,
82  void *draw_customdata);
83  void beginFrameDrawing();
84  void endFrameDrawing(std::vector<XrCompositionLayerBaseHeader *> &layers);
85 };
static AppView * view
static void initSystem(LaplacianDeformModifierData *lmd, Object *ob, Mesh *mesh, float(*vertexCos)[3], int numVerts)
Main GHOST container to manage OpenXR through.
void draw(void *draw_customdata)
GHOST_XrSession(GHOST_XrContext &xr_context)
bool isRunning() const
LifeExpectancy handleStateChangeEvent(const XrEventDataSessionStateChanged &lifecycle)
bool needsUpsideDownDrawing() const
void start(const GHOST_XrSessionBeginInfo *begin_info)