VTK  9.3.20240418
vtkOpenXRManagerOpenGLGraphics.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: Copyright (c) Ken Martin, Will Schroeder, Bill Lorensen
2 // SPDX-License-Identifier: BSD-3-Clause
11 #ifndef vtkOpenXRManagerOpenGLGraphics_h
12 #define vtkOpenXRManagerOpenGLGraphics_h
13 
15 #include "vtkRenderingOpenXRModule.h" // For export macro
16 
17 #include "vtkRenderingOpenGLConfigure.h" // For VTK_USE_X / WIN32
18 
19 #include <memory> // For shared_ptr
20 #include <vector> // For std::vector
21 
22 // Forward declare the graphics binding struct depending on the platform being used
23 #ifdef VTK_USE_X
24 struct XrGraphicsBindingOpenGLXlibKHR;
25 typedef XrGraphicsBindingOpenGLXlibKHR XrGraphicsBindingOpenGL;
26 #elif defined(_WIN32)
27 struct XrGraphicsBindingOpenGLWin32KHR;
28 typedef XrGraphicsBindingOpenGLWin32KHR XrGraphicsBindingOpenGL;
29 #endif
30 struct XrSwapchainImageOpenGLKHR;
31 
32 VTK_ABI_NAMESPACE_BEGIN
33 class VTKRENDERINGOPENXR_EXPORT vtkOpenXRManagerOpenGLGraphics : public vtkOpenXRManagerGraphics
34 {
35 public:
38 
42  void SetNumberOfSwapchains(uint32_t viewCount) override;
43 
45 
49  void GetColorSwapchainImage(uint32_t scIndex, uint32_t imgIndex, void* texture) override;
50  void GetDepthSwapchainImage(uint32_t scIndex, uint32_t imgIndex, void* texture) override;
52 
54 
57  void EnumerateColorSwapchainImages(XrSwapchain swapchain, uint32_t scIndex) override;
58  void EnumerateDepthSwapchainImages(XrSwapchain swapchain, uint32_t scIndex) override;
60 
62 
66  const std::vector<int64_t>& GetSupportedColorFormats() override;
67  const std::vector<int64_t>& GetSupportedDepthFormats() override;
69 
73  bool CreateGraphicsBinding(vtkOpenGLRenderWindow* helperWindow) override;
74 
78  const void* GetGraphicsBinding() override { return this->GraphicsBinding.get(); };
79 
83  bool CheckGraphicsRequirements(XrInstance instance, XrSystemId id) override;
84 
88  const char* GetBackendExtensionName() override;
89 
90 protected:
93 
98  {
99  std::vector<XrSwapchainImageOpenGLKHR> Images;
100  };
101 
105  void EnumerateSwapchainImages(XrSwapchain swapchain, SwapchainImagesOpenGL& swapchainImages);
106 
107  std::shared_ptr<XrGraphicsBindingOpenGL> GraphicsBinding;
108 
109 private:
111  void operator=(const vtkOpenXRManagerOpenGLGraphics&) = delete;
112 
113  class PIMPL;
114  PIMPL* Private;
115 };
116 
117 VTK_ABI_NAMESPACE_END
118 #endif
OpenGL rendering window.
OpenXR manager graphics implementation.
OpenXR manager OpenGL graphics implementation.
void EnumerateSwapchainImages(XrSwapchain swapchain, SwapchainImagesOpenGL &swapchainImages)
Acquire OpenGL swapchain images an store them in swapchainImages.
bool CreateGraphicsBinding(vtkOpenGLRenderWindow *helperWindow) override
Fill the pointer to the XrGraphicsBindingOpenGL structure.
const void * GetGraphicsBinding() override
Return pointer to the XrGraphicsBindingOpenGL structure required to create the OpenXR session.
void EnumerateDepthSwapchainImages(XrSwapchain swapchain, uint32_t scIndex) override
Acquire OpenGL swapchain images for the specified eye index.
const std::vector< int64_t > & GetSupportedDepthFormats() override
Return the list of GL formats supported by vtkOpenGLRenderWindow.
bool CheckGraphicsRequirements(XrInstance instance, XrSystemId id) override
Check OpenGL version supported by the runtime.
void GetColorSwapchainImage(uint32_t scIndex, uint32_t imgIndex, void *texture) override
Fill texture with the OpenGL texture id for the specified eye scIndex.
const std::vector< int64_t > & GetSupportedColorFormats() override
Return the list of GL formats supported by vtkOpenGLRenderWindow.
void GetDepthSwapchainImage(uint32_t scIndex, uint32_t imgIndex, void *texture) override
Fill texture with the OpenGL texture id for the specified eye scIndex.
void SetNumberOfSwapchains(uint32_t viewCount) override
Resize the internal vectors storing the color and depth swapchains.
std::shared_ptr< XrGraphicsBindingOpenGL > GraphicsBinding
static vtkOpenXRManagerOpenGLGraphics * New()
void EnumerateColorSwapchainImages(XrSwapchain swapchain, uint32_t scIndex) override
Acquire OpenGL swapchain images for the specified eye index.
const char * GetBackendExtensionName() override
Return the extension name corresponding to the OpenGL rendering backend.
~vtkOpenXRManagerOpenGLGraphics() override