| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 28 |
|
| 29 |
|
| 30 |
|
| 31 |
#pragma once |
| 32 |
|
| 33 |
#ifdef GLES3_ENABLED |
| 34 |
|
| 35 |
#include "../../openxr_api.h" |
| 36 |
#include "../../util.h" |
| 37 |
#include "../openxr_extension_wrapper.h" |
| 38 |
|
| 39 |
#include "core/templates/vector.h" |
| 40 |
|
| 41 |
|
| 42 |
#include "../../openxr_platform_inc.h" |
| 43 |
|
| 44 |
class OpenXROpenGLExtension : public OpenXRGraphicsExtensionWrapper { |
| 45 |
public: |
| 46 |
virtual HashMap<String, bool *> get_requested_extensions(XrVersion p_version) override; |
| 47 |
|
| 48 |
virtual void on_instance_created(const XrInstance p_instance) override; |
| 49 |
virtual void *set_session_create_and_get_next_pointer(void *p_next_pointer) override; |
| 50 |
|
| 51 |
virtual void get_usable_swapchain_formats(Vector<int64_t> &p_usable_swap_chains) override; |
| 52 |
virtual void get_usable_depth_formats(Vector<int64_t> &p_usable_swap_chains) override; |
| 53 |
virtual String get_swapchain_format_name(int64_t p_swapchain_format) const override; |
| 54 |
virtual bool get_swapchain_image_data(XrSwapchain p_swapchain, int64_t p_swapchain_format, uint32_t p_width, uint32_t p_height, uint32_t p_sample_count, uint32_t p_array_size, void **r_swapchain_graphics_data) override; |
| 55 |
virtual void cleanup_swapchain_graphics_data(void **p_swapchain_graphics_data) override; |
| 56 |
virtual bool create_projection_fov(const XrFovf p_fov, double p_z_near, double p_z_far, Projection &r_camera_matrix) override; |
| 57 |
virtual RID get_texture(void *p_swapchain_graphics_data, int p_image_index) override; |
| 58 |
virtual RID get_density_map(void *p_swapchain_graphics_data, int p_image_index) override { return RID(); } |
| 59 |
|
| 60 |
private: |
| 61 |
static OpenXROpenGLExtension *singleton; |
| 62 |
|
| 63 |
#ifdef WIN32 |
| 64 |
static XrGraphicsBindingOpenGLWin32KHR graphics_binding_gl; |
| 65 |
#elif defined(ANDROID_ENABLED) |
| 66 |
static XrGraphicsBindingOpenGLESAndroidKHR graphics_binding_gl; |
| 67 |
#elif defined(LINUXBSD_ENABLED) |
| 68 |
#ifdef X11_ENABLED |
| 69 |
static XrGraphicsBindingOpenGLXlibKHR graphics_binding_gl; |
| 70 |
#endif |
| 71 |
#if defined(EGL_ENABLED) && defined(WAYLAND_ENABLED) |
| 72 |
static XrGraphicsBindingEGLMNDX graphics_binding_egl; |
| 73 |
|
| 74 |
bool egl_extension_enabled = false; |
| 75 |
#endif |
| 76 |
#else |
| 77 |
#error "OpenXR with OpenGL isn't supported on this platform" |
| 78 |
#endif |
| 79 |
|
| 80 |
struct SwapchainGraphicsData { |
| 81 |
bool is_multiview; |
| 82 |
Vector<RID> texture_rids; |
| 83 |
}; |
| 84 |
|
| 85 |
bool check_graphics_api_support(XrVersion p_desired_version); |
| 86 |
|
| 87 |
#ifdef ANDROID_ENABLED |
| 88 |
EXT_PROTO_XRRESULT_FUNC3(xrGetOpenGLESGraphicsRequirementsKHR, (XrInstance), p_instance, (XrSystemId), p_system_id, (XrGraphicsRequirementsOpenGLESKHR *), p_graphics_requirements) |
| 89 |
#else |
| 90 |
EXT_PROTO_XRRESULT_FUNC3(xrGetOpenGLGraphicsRequirementsKHR, (XrInstance), p_instance, (XrSystemId), p_system_id, (XrGraphicsRequirementsOpenGLKHR *), p_graphics_requirements) |
| 91 |
#endif |
| 92 |
EXT_PROTO_XRRESULT_FUNC4(xrEnumerateSwapchainImages, (XrSwapchain), p_swapchain, (uint32_t), p_image_capacity_input, (uint32_t *), p_image_count_output, (XrSwapchainImageBaseHeader *), p_images) |
| 93 |
}; |
| 94 |
|
| 95 |
#endif |